@@ -39,10 +39,12 @@ type FileImagesLister struct {
39
39
FilePath string
40
40
Arch string
41
41
Tag string
42
+ Target string
42
43
}
43
44
44
45
type RepoImagesLister struct {
45
- repo string
46
+ repo string
47
+ httpOnly bool // set to true for mocking tests
46
48
}
47
49
48
50
type ImageKey string
@@ -74,9 +76,8 @@ func (im ImagesMap) findImage(target Type, gccVers semver.Version) (Image, bool)
74
76
}
75
77
76
78
func NewFileImagesLister (filePath string , build * Build ) * FileImagesLister {
77
- // Create the proper regexes to load "any" and target-specific images for requested arch
78
79
arch := kernelrelease .Architecture (build .Architecture ).ToNonDeb ()
79
- return & FileImagesLister {FilePath : filePath , Arch : arch , Tag : build .builderImageTag ()}
80
+ return & FileImagesLister {FilePath : filePath , Arch : arch , Tag : build .builderImageTag (), Target : build . TargetType . String () }
80
81
}
81
82
82
83
func (f * FileImagesLister ) LoadImages () []Image {
@@ -103,14 +104,6 @@ func (f *FileImagesLister) LoadImages() []Image {
103
104
}
104
105
105
106
for _ , image := range imageList .Images {
106
- // Fixup empty fields using default values
107
- if image .Arch == "" {
108
- image .Arch = f .Arch
109
- }
110
- if image .Tag == "" {
111
- image .Tag = f .Tag
112
- }
113
-
114
107
// Values checks
115
108
if image .Arch != f .Arch {
116
109
logger .WithField ("FilePath" , f .FilePath ).WithField ("image" , image ).Debug ("Skipping wrong-arch image" )
@@ -120,8 +113,8 @@ func (f *FileImagesLister) LoadImages() []Image {
120
113
logger .WithField ("FilePath" , f .FilePath ).WithField ("image" , image ).Debug ("Skipping wrong-tag image" )
121
114
continue
122
115
}
123
- if image .Target != "any" && BuilderByTarget [ Type ( image .Target )] == nil {
124
- logger .WithField ("FilePath" , f .FilePath ).WithField ("image" , image ).Debug ("Skipping unexistent target image" )
116
+ if image .Target != "any" && image .Target != f . Target {
117
+ logger .WithField ("FilePath" , f .FilePath ).WithField ("image" , image ).Debug ("Skipping wrong- target image" )
125
118
continue
126
119
}
127
120
if image .Name == "" {
@@ -154,25 +147,26 @@ func NewRepoImagesLister(repo string, build *Build) *RepoImagesLister {
154
147
targetFmt := fmt .Sprintf ("^(?P<target>%s|any)-%s(?P<gccVers>(_gcc[0-9]+.[0-9]+.[0-9]+)+)-%s$" , build .TargetType .String (), arch , imageTag )
155
148
tagReg = regexp .MustCompile (targetFmt )
156
149
}
157
- return & RepoImagesLister {repo : repo }
150
+ return & RepoImagesLister {repo : repo , httpOnly : false }
158
151
}
159
152
160
153
func (repo * RepoImagesLister ) LoadImages () []Image {
161
154
noCredentials := func (r * repository.Repository ) {
162
155
// The default client will be used by oras.
163
156
// TODO: we don't support private repositories for now.
164
157
r .Client = nil
158
+ r .PlainHTTP = repo .httpOnly
165
159
}
166
160
167
161
repoOCI , err := repository .NewRepository (repo .repo , noCredentials )
168
162
if err != nil {
169
- logger .WithField ("Repo" , repo .repo ).Warnf ("Skipping repo %s: %s\n " , repo , err .Error ())
163
+ logger .WithField ("Repo" , repo .repo ).Warnf ("Skipping repo %s: %s\n " , repo . repo , err .Error ())
170
164
return nil
171
165
}
172
166
173
167
tags , err := repoOCI .Tags (context .Background ())
174
168
if err != nil {
175
- logger .WithField ("Repo" , repo .repo ).Warnf ("Skipping repo %s: %s\n " , repo , err .Error ())
169
+ logger .WithField ("Repo" , repo .repo ).Warnf ("Skipping repo %s: %s\n " , repo . repo , err .Error ())
176
170
return nil
177
171
}
178
172
0 commit comments