From 3bbd10964947a1458d662fb6956afdc8dd1ca57e Mon Sep 17 00:00:00 2001 From: Chris Stephenson Date: Wed, 31 Jan 2024 20:02:23 +0100 Subject: [PATCH] fix: add immage flag for . image convention Signed-off-by: Chris Stephenson --- internal/command/consts.go | 1 + internal/command/delta.go | 1 + internal/command/draft.go | 1 + internal/command/run.go | 13 +++++++++++++ 4 files changed, 16 insertions(+) diff --git a/internal/command/consts.go b/internal/command/consts.go index 18fbb76..f506c24 100644 --- a/internal/command/consts.go +++ b/internal/command/consts.go @@ -29,6 +29,7 @@ var ( workloadSourceURL string overrideParams []string + currentImage string message string // deltaID is a cli flag receiver used to support "score-humanitec delta --use foo" diff --git a/internal/command/delta.go b/internal/command/delta.go index 6c7457d..b0869aa 100644 --- a/internal/command/delta.go +++ b/internal/command/delta.go @@ -42,6 +42,7 @@ func init() { deltaCmd.MarkFlagRequired("env") deltaCmd.Flags().StringArrayVarP(&overrideParams, "property", "p", nil, "Overrides selected property value") + deltaCmd.Flags().StringVarP(¤tImage, "image", "i", ".", "Image to use for the current image, signified by \".\"") deltaCmd.Flags().StringVarP(&message, "message", "m", messageDefault, "Message") deltaCmd.Flags().BoolVar(&deploy, "deploy", false, "Trigger a new delta deployment at the end") diff --git a/internal/command/draft.go b/internal/command/draft.go index bfd1c84..b04be2e 100644 --- a/internal/command/draft.go +++ b/internal/command/draft.go @@ -28,6 +28,7 @@ func init() { draftCmd.MarkFlagRequired("env") draftCmd.Flags().StringArrayVarP(&overrideParams, "property", "p", nil, "Overrides selected property value") + draftCmd.Flags().StringVarP(¤tImage, "image", "i", ".", "Image to use for the current image, signified by \".\"") draftCmd.Flags().BoolVar(&deploy, "deploy", false, "Trigger a new draft deployment at the end") draftCmd.Flags().BoolVar(&verbose, "verbose", false, "Enable diagnostic messages (written to STDERR)") diff --git a/internal/command/run.go b/internal/command/run.go index eeb5d95..77efd99 100644 --- a/internal/command/run.go +++ b/internal/command/run.go @@ -39,6 +39,7 @@ func init() { runCmd.MarkFlagRequired("env") runCmd.Flags().StringArrayVarP(&overrideParams, "property", "p", nil, "Overrides selected property value") + runCmd.Flags().StringVarP(¤tImage, "image", "i", ".", "Image to use for the current image, signified by \".\"") runCmd.Flags().StringVarP(&message, "message", "m", messageDefault, "Message") runCmd.Flags().BoolVar(&skipValidation, "skip-validation", false, "DEPRECATED: Disables Score file schema validation.") @@ -158,6 +159,18 @@ func loadSpec(scoreFile, overridesFile, extensionsFile string, skipValidation bo } } + // Replace images defined by . (optional) + // + if containers, ok := srcMap["containers"].(map[string]interface{}); ok { + for _, containerVal := range containers { + if container, ok := containerVal.(map[string]interface{}); ok { + if image, ok := container["image"].(string); ok && image == "." { + container["image"] = currentImage + } + } + } + } + // Load extensions (optional) // var extMap = make(map[string]interface{})