diff --git a/cli/internal/cmd/configfetchmeasurements.go b/cli/internal/cmd/configfetchmeasurements.go index 7ee557289..d2d586247 100644 --- a/cli/internal/cmd/configfetchmeasurements.go +++ b/cli/internal/cmd/configfetchmeasurements.go @@ -161,6 +161,7 @@ func (cfm *configFetchMeasurementsCmd) configFetchMeasurements( return err } cfm.log.Debugf("Configuration written to %s", flags.configPath) + cmd.Print("Successfully fetched measurements and updated Configuration\n") return nil } diff --git a/cli/internal/cmd/create.go b/cli/internal/cmd/create.go index cd67ceeb2..8d834e31d 100644 --- a/cli/internal/cmd/create.go +++ b/cli/internal/cmd/create.go @@ -91,6 +91,11 @@ func (c *createCmd) create(cmd *cobra.Command, creator cloudCreator, fileHandler printedAWarning = true } + if conf.IsNamedLikeDebugImage() && !conf.IsDebugCluster() { + cmd.PrintErrln("WARNING: A debug image is used but debugCluster is false.") + printedAWarning = true + } + if conf.IsDebugCluster() { cmd.PrintErrln("WARNING: Creating a debug cluster. This cluster is not secure and should only be used for debugging purposes.") cmd.PrintErrln("DO NOT USE THIS CLUSTER IN PRODUCTION.") diff --git a/internal/config/config.go b/internal/config/config.go index 1d7f6640c..7e8ca54a4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -36,6 +36,7 @@ import ( "gopkg.in/yaml.v3" "github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi" + "github.com/edgelesssys/constellation/v2/internal/api/versionsapi" "github.com/edgelesssys/constellation/v2/internal/attestation/idkeydigest" "github.com/edgelesssys/constellation/v2/internal/attestation/measurements" "github.com/edgelesssys/constellation/v2/internal/attestation/variant" @@ -542,6 +543,15 @@ func (c *Config) IsReleaseImage() bool { return strings.HasPrefix(c.Image, "v") } +// IsNamedLikeDebugImage checks whether image name looks like a debug image. +func (c *Config) IsNamedLikeDebugImage() bool { + v, err := versionsapi.NewVersionFromShortPath(c.Image, versionsapi.VersionKindImage) + if err != nil { + return false + } + return v.Stream == "debug" +} + // GetProvider returns the configured cloud provider. func (c *Config) GetProvider() cloudprovider.Provider { if c.Provider.AWS != nil { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 0e43fd8f0..d77e6d9b3 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -854,6 +854,24 @@ func TestConfigVersionCompatibility(t *testing.T) { } } +func TestIsDebugImage(t *testing.T) { + cases := map[string]struct { + image string + expected bool + }{ + "debug image": {"ref/test/stream/debug/v2.9.0-pre.0.20230613084544-eeea7b1f56f4", true}, + "release image": {"v2.8.0", false}, + "empty image": {"", false}, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + c := &Config{Image: tc.image} + assert.Equal(t, tc.expected, c.IsNamedLikeDebugImage()) + }) + } +} + func TestIsAppClientIDError(t *testing.T) { testCases := map[string]struct { err error