@@ -17,7 +17,7 @@ import (
17
17
"github.com/docker-library/go-dockerlibrary/manifest"
18
18
)
19
19
20
- type DockerfileMetadata struct {
20
+ type dockerfileMetadata struct {
21
21
StageFroms []string // every image "FROM" instruction value (or the parent stage's FROM value in the case of a named stage)
22
22
StageNames []string // the name of any named stage (in order)
23
23
StageNameFroms map [string ]string // map of stage names to FROM values (or the parent stage's FROM value in the case of a named stage), useful for resolving stage names to FROM values
@@ -30,21 +30,33 @@ func (r Repo) DockerFrom(entry *manifest.Manifest2822Entry) (string, error) {
30
30
}
31
31
32
32
func (r Repo ) ArchDockerFrom (arch string , entry * manifest.Manifest2822Entry ) (string , error ) {
33
- dockerfileMeta , err := r .ArchDockerfileMetadata (arch , entry )
33
+ dockerfileMeta , err := r .archDockerfileMetadata (arch , entry )
34
34
if err != nil {
35
35
return "" , err
36
36
}
37
37
38
38
return dockerfileMeta .StageFroms [len (dockerfileMeta .StageFroms )- 1 ], nil
39
39
}
40
40
41
- func (r Repo ) DockerfileMetadata (entry * manifest.Manifest2822Entry ) (* DockerfileMetadata , error ) {
42
- return r .ArchDockerfileMetadata (arch , entry )
41
+ func (r Repo ) DockerFroms (entry * manifest.Manifest2822Entry ) ([] string , error ) {
42
+ return r .ArchDockerFroms (arch , entry )
43
43
}
44
44
45
- var dockerfileMetadataCache = map [string ]* DockerfileMetadata {}
45
+ func (r Repo ) ArchDockerFroms (arch string , entry * manifest.Manifest2822Entry ) ([]string , error ) {
46
+ dockerfileMeta , err := r .archDockerfileMetadata (arch , entry )
47
+ if err != nil {
48
+ return nil , err
49
+ }
50
+ return dockerfileMeta .Froms , nil
51
+ }
52
+
53
+ func (r Repo ) dockerfileMetadata (entry * manifest.Manifest2822Entry ) (* dockerfileMetadata , error ) {
54
+ return r .archDockerfileMetadata (arch , entry )
55
+ }
56
+
57
+ var dockerfileMetadataCache = map [string ]* dockerfileMetadata {}
46
58
47
- func (r Repo ) ArchDockerfileMetadata (arch string , entry * manifest.Manifest2822Entry ) (* DockerfileMetadata , error ) {
59
+ func (r Repo ) archDockerfileMetadata (arch string , entry * manifest.Manifest2822Entry ) (* dockerfileMetadata , error ) {
48
60
commit , err := r .fetchGitRepo (arch , entry )
49
61
if err != nil {
50
62
return nil , err
@@ -79,8 +91,8 @@ func (r Repo) ArchDockerfileMetadata(arch string, entry *manifest.Manifest2822En
79
91
return meta , nil
80
92
}
81
93
82
- func parseDockerfileMetadata (dockerfile io.Reader ) (* DockerfileMetadata , error ) {
83
- meta := & DockerfileMetadata {
94
+ func parseDockerfileMetadata (dockerfile io.Reader ) (* dockerfileMetadata , error ) {
95
+ meta := & dockerfileMetadata {
84
96
// panic: assignment to entry in nil map
85
97
StageNameFroms : map [string ]string {},
86
98
// (nil slices work fine)
@@ -215,7 +227,7 @@ func (r Repo) dockerBuildUniqueBits(entry *manifest.Manifest2822Entry) ([]string
215
227
entry .ArchDirectory (arch ),
216
228
entry .ArchFile (arch ),
217
229
}
218
- meta , err := r .DockerfileMetadata (entry )
230
+ meta , err := r .dockerfileMetadata (entry )
219
231
if err != nil {
220
232
return nil , err
221
233
}
0 commit comments