Skip to content

Commit 0c5ec50

Browse files
mclasmeierMoritz Clasmeier
andauthored
New command line flag --tag / -t as an alternative to MAIN_IMAGE_TAG. (#57)
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
1 parent 799943b commit 0c5ec50

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

cmd/deploy.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Examples:
4444
cmd.Flags().StringVar(&shell, "shell", "", "Shell to spawn after Central deployment")
4545
cmd.Flags().StringVar(&envrc, "envrc", "", "Write environment to file instead of spawning sub-shell")
4646
cmd.Flags().BoolVar(&singleNamespace, "single-namespace", false, "Deploy all components in a single namespace ('stackrox' by default)")
47+
cmd.Flags().StringVarP(&tag, "tag", "t", "", "Main image tag to use for deployment (takes precedence over MAIN_IMAGE_TAG environment variable)")
4748

4849
return cmd
4950
}
@@ -178,9 +179,16 @@ func runDeploy(cmd *cobra.Command, args []string) error {
178179
d.SetPauseReconciliation(pauseReconciliation)
179180
d.SetSingleNamespace(singleNamespace)
180181

181-
mainImageTag, err := helpers.LookupMainImageTag(log)
182-
if err != nil {
183-
return fmt.Errorf("looking up main image tag: %w", err)
182+
var mainImageTag string
183+
if tag != "" {
184+
log.Dimf("Using main image tag from --tag flag: %s", tag)
185+
mainImageTag = tag
186+
}
187+
if mainImageTag == "" {
188+
mainImageTag, err = helpers.LookupMainImageTag(log)
189+
if err != nil {
190+
return fmt.Errorf("looking up main image tag: %w", err)
191+
}
184192
}
185193
d.SetMainImageTag(mainImageTag)
186194

cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
shell string
2525
envrc string
2626
singleNamespace bool
27+
tag string
2728
)
2829

2930
func main() {

0 commit comments

Comments
 (0)