@@ -107,7 +107,81 @@ func main() {
107107 }()
108108
109109 configsByRepo := make (configsByRepo )
110- callback := func (rbc * api.ReleaseBuildConfiguration , repoInfo * config.Info ) error {
110+ callback := ciOperatorConfigsCallback (o , configsByRepo )
111+
112+ if err := o .OperateOnCIOperatorConfigDir (o .ConfigDir , callback ); err != nil {
113+ logrus .WithError (err ).Fatal ("error while operating in the ci-operator configuration files" )
114+ }
115+
116+ dest := filepath .Join (o .ConfigDir , o .toOrg )
117+ logger := logrus .WithField ("destination" , dest )
118+ if o .clean {
119+ logger .Info ("Cleaning destination's sub directories" )
120+ if err := configsByRepo .cleanDestinationSubdirs (dest ); err != nil {
121+ logger .WithError (err ).Fatal ("couldn't cleanup destination's subdirectories" )
122+ }
123+ }
124+
125+ logger .Info ("Generating configurations..." )
126+ if err := configsByRepo .generateConfigs (o .ConfigDir ); err != nil {
127+ logger .WithError (err ).Fatal ("couldn't generate configurations" )
128+ }
129+ }
130+
131+ func privateReleaseTagConfiguration (tagSpecification * api.ReleaseTagConfiguration ) {
132+ if tagSpecification .Namespace == ocpNamespace {
133+ tagSpecification .Name = fmt .Sprintf ("%s-priv" , tagSpecification .Name )
134+ tagSpecification .Namespace = privatePromotionNamespace
135+ }
136+ }
137+
138+ func privateIntegrationRelease (release * api.Integration ) {
139+ if release .Namespace == ocpNamespace {
140+ release .Name = fmt .Sprintf ("%s-priv" , release .Name )
141+ release .Namespace = privatePromotionNamespace
142+ }
143+ }
144+
145+ func privateBuildRoot (buildRoot * api.BuildRootImageConfiguration ) {
146+ if buildRoot .ImageStreamTagReference .Namespace == ocpNamespace {
147+ buildRoot .ImageStreamTagReference .Name = fmt .Sprintf ("%s-priv" , buildRoot .ImageStreamTagReference .Name )
148+ buildRoot .ImageStreamTagReference .Namespace = privatePromotionNamespace
149+ }
150+ }
151+
152+ func privateBaseImages (baseImages map [string ]api.ImageStreamTagReference ) {
153+ for name , reference := range baseImages {
154+ if reference .Namespace == ocpNamespace && api .IsValidOCPVersion (reference .Name ) {
155+ reference .Name = fmt .Sprintf ("%s-priv" , reference .Name )
156+ reference .Namespace = privatePromotionNamespace
157+ baseImages [name ] = reference
158+ }
159+ }
160+ }
161+
162+ func privatePromotionConfiguration (promotion * api.PromotionConfiguration ) {
163+ for i := range promotion .Targets {
164+ if promotion .Targets [i ].Namespace == ocpNamespace {
165+ if promotion .Targets [i ].Name != "" {
166+ promotion .Targets [i ].Name = fmt .Sprintf ("%s-priv" , promotion .Targets [i ].Name )
167+ } else { // promotion.Targets[i].Tag must be set
168+ promotion .Targets [i ].Tag = fmt .Sprintf ("%s-priv" , promotion .Targets [i ].Tag )
169+ }
170+ promotion .Targets [i ].TagByCommit = false // Never use tag_by_commit for mirrored repos
171+ promotion .Targets [i ].Namespace = privatePromotionNamespace
172+ } else {
173+ // Disable this target or it will conflict with its non `-priv` counterpart
174+ promotion .Targets [i ].Disabled = true
175+ }
176+ }
177+ }
178+
179+ func strP (str string ) * string {
180+ return & str
181+ }
182+
183+ func ciOperatorConfigsCallback (o options , configsByRepo configsByRepo ) func (rbc * api.ReleaseBuildConfiguration , repoInfo * config.Info ) error {
184+ return func (rbc * api.ReleaseBuildConfiguration , repoInfo * config.Info ) error {
111185 logger := logrus .WithFields (logrus.Fields {"org" : repoInfo .Org , "repo" : repoInfo .Repo , "branch" : repoInfo .Branch })
112186
113187 if repoInfo .Org == o .toOrg {
@@ -186,81 +260,14 @@ func main() {
186260
187261 repoInfo .Org = o .toOrg
188262 rbc .Metadata .Org = o .toOrg
189- configsByRepo [repoInfo .Repo ] = append (configsByRepo [repoInfo .Repo ], config.DataWithInfo {
190- Configuration : * rbc ,
191- Info : * repoInfo ,
192- })
193263
194- return nil
195- }
196-
197- if err := o .OperateOnCIOperatorConfigDir (o .ConfigDir , callback ); err != nil {
198- logrus .WithError (err ).Fatal ("error while operating in the ci-operator configuration files" )
199- }
200-
201- dest := filepath .Join (o .ConfigDir , o .toOrg )
202- logger := logrus .WithField ("destination" , dest )
203- if o .clean {
204- logger .Info ("Cleaning destination's sub directories" )
205- if err := configsByRepo .cleanDestinationSubdirs (dest ); err != nil {
206- logger .WithError (err ).Fatal ("couldn't cleanup destination's subdirectories" )
264+ if len (rbc .Tests ) > 0 || len (rbc .Images ) > 0 {
265+ configsByRepo [repoInfo .Repo ] = append (configsByRepo [repoInfo .Repo ], config.DataWithInfo {
266+ Configuration : * rbc ,
267+ Info : * repoInfo ,
268+ })
207269 }
208- }
209-
210- logger .Info ("Generating configurations..." )
211- if err := configsByRepo .generateConfigs (o .ConfigDir ); err != nil {
212- logger .WithError (err ).Fatal ("couldn't generate configurations" )
213- }
214- }
215-
216- func privateReleaseTagConfiguration (tagSpecification * api.ReleaseTagConfiguration ) {
217- if tagSpecification .Namespace == ocpNamespace {
218- tagSpecification .Name = fmt .Sprintf ("%s-priv" , tagSpecification .Name )
219- tagSpecification .Namespace = privatePromotionNamespace
220- }
221- }
222270
223- func privateIntegrationRelease (release * api.Integration ) {
224- if release .Namespace == ocpNamespace {
225- release .Name = fmt .Sprintf ("%s-priv" , release .Name )
226- release .Namespace = privatePromotionNamespace
227- }
228- }
229-
230- func privateBuildRoot (buildRoot * api.BuildRootImageConfiguration ) {
231- if buildRoot .ImageStreamTagReference .Namespace == ocpNamespace {
232- buildRoot .ImageStreamTagReference .Name = fmt .Sprintf ("%s-priv" , buildRoot .ImageStreamTagReference .Name )
233- buildRoot .ImageStreamTagReference .Namespace = privatePromotionNamespace
234- }
235- }
236-
237- func privateBaseImages (baseImages map [string ]api.ImageStreamTagReference ) {
238- for name , reference := range baseImages {
239- if reference .Namespace == ocpNamespace && api .IsValidOCPVersion (reference .Name ) {
240- reference .Name = fmt .Sprintf ("%s-priv" , reference .Name )
241- reference .Namespace = privatePromotionNamespace
242- baseImages [name ] = reference
243- }
244- }
245- }
246-
247- func privatePromotionConfiguration (promotion * api.PromotionConfiguration ) {
248- for i := range promotion .Targets {
249- if promotion .Targets [i ].Namespace == ocpNamespace {
250- if promotion .Targets [i ].Name != "" {
251- promotion .Targets [i ].Name = fmt .Sprintf ("%s-priv" , promotion .Targets [i ].Name )
252- } else { // promotion.Targets[i].Tag must be set
253- promotion .Targets [i ].Tag = fmt .Sprintf ("%s-priv" , promotion .Targets [i ].Tag )
254- }
255- promotion .Targets [i ].TagByCommit = false // Never use tag_by_commit for mirrored repos
256- promotion .Targets [i ].Namespace = privatePromotionNamespace
257- } else {
258- // Disable this target or it will conflict with its non `-priv` counterpart
259- promotion .Targets [i ].Disabled = true
260- }
271+ return nil
261272 }
262273}
263-
264- func strP (str string ) * string {
265- return & str
266- }
0 commit comments