Skip to content

Commit 9ffd4d7

Browse files
Merge pull request #554 from radiofrance/revert-548-fix/GenerateDAG-skipbuild-Dockerfiles-should-be-ignored
Revert "fix(GenerateDAG): Dockerfiles with skipbuild label should be ignored"
2 parents b1ba72e + 39013f4 commit 9ffd4d7

File tree

5 files changed

+105
-286
lines changed

5 files changed

+105
-286
lines changed

pkg/dag/dag.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package dag
22

33
import (
4-
"cmp"
5-
"slices"
6-
"strings"
74
"sync"
85

9-
"github.com/radiofrance/dib/internal/logger"
106
"golang.org/x/sync/errgroup"
117
"gopkg.in/yaml.v3"
128
)
@@ -207,23 +203,3 @@ func createUniqueVisitorErr(visitor NodeVisitorFuncErr) NodeVisitorFuncErr {
207203

208204
return uniqueVisitor
209205
}
210-
211-
func sort(a, b *Node) int {
212-
return cmp.Compare(strings.ToLower(a.Image.ShortName), strings.ToLower(b.Image.ShortName))
213-
}
214-
215-
func (d *DAG) Sprint(name string) string {
216-
d.WalkInDepth(func(node *Node) {
217-
slices.SortFunc(node.Children(), sort)
218-
})
219-
slices.SortFunc(d.nodes, sort)
220-
rootNode := &Node{
221-
Image: &Image{Name: name},
222-
children: d.nodes,
223-
}
224-
res, err := defaultPrinter.WithRoot(rootNode).Srender()
225-
if err != nil {
226-
logger.Fatalf(err.Error())
227-
}
228-
return res
229-
}

pkg/dag/node.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type NodeVisitorFuncErr func(*Node) error
1515
// Node represents a node of a graph.
1616
type Node struct {
1717
Image *Image
18-
Files []string
1918

2019
waitCond *sync.Cond
2120
done bool

pkg/dag/printer.go

Lines changed: 0 additions & 97 deletions
This file was deleted.

pkg/dib/generate_dag.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func GenerateDAG(buildPath, registryPrefix, customHashListPath string, buildArgs
4747

4848
skipBuild, hasSkipLabel := dckfile.Labels["skipbuild"]
4949
if hasSkipLabel && skipBuild == "true" {
50-
allFiles = allFiles[:len(allFiles)-1] // remove the last Dockerfile with skipbuild label
5150
return nil
5251
}
5352
imageShortName, hasNameLabel := dckfile.Labels["name"]
@@ -219,8 +218,7 @@ func generateHashes(graph *dag.DAG, allFiles []string, customHashListPath string
219218
}
220219
}()
221220

222-
node.Files = nodeFiles[node]
223-
hash, err := HashFiles(node.Image.Dockerfile.ContextPath, node.Files, parentHashes, humanizedKeywords)
221+
hash, err := hashFiles(node.Image.Dockerfile.ContextPath, nodeFiles[node], parentHashes, humanizedKeywords)
224222
if err != nil {
225223
return fmt.Errorf("could not hash files for node %s: %w", node.Image.Name, err)
226224
}
@@ -254,10 +252,10 @@ func matchPattern(node *dag.Node, file string) bool {
254252
return match
255253
}
256254

257-
// HashFiles computes the sha256 from the contents of the files passed as argument.
255+
// hashFiles computes the sha256 from the contents of the files passed as argument.
258256
// The files are alphabetically sorted so the returned hash is always the same.
259257
// This also means the hash will change if the file names change but the contents don't.
260-
func HashFiles(
258+
func hashFiles(
261259
baseDir string,
262260
files []string,
263261
parentHashes []string,

0 commit comments

Comments
 (0)