mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-25 06:30:45 -04:00
cli: improve user warning / information (#1933)
* print success * warn when debug img but !debugCluster * malte feedback * rename to IsNamedLikeDebugImage
This commit is contained in:
parent
2808012c9c
commit
be4a636361
4 changed files with 34 additions and 0 deletions
|
@ -161,6 +161,7 @@ func (cfm *configFetchMeasurementsCmd) configFetchMeasurements(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cfm.log.Debugf("Configuration written to %s", flags.configPath)
|
cfm.log.Debugf("Configuration written to %s", flags.configPath)
|
||||||
|
cmd.Print("Successfully fetched measurements and updated Configuration\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,11 @@ func (c *createCmd) create(cmd *cobra.Command, creator cloudCreator, fileHandler
|
||||||
printedAWarning = true
|
printedAWarning = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if conf.IsNamedLikeDebugImage() && !conf.IsDebugCluster() {
|
||||||
|
cmd.PrintErrln("WARNING: A debug image is used but debugCluster is false.")
|
||||||
|
printedAWarning = true
|
||||||
|
}
|
||||||
|
|
||||||
if conf.IsDebugCluster() {
|
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("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.")
|
cmd.PrintErrln("DO NOT USE THIS CLUSTER IN PRODUCTION.")
|
||||||
|
|
|
@ -36,6 +36,7 @@ import (
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi"
|
"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/idkeydigest"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
|
@ -542,6 +543,15 @@ func (c *Config) IsReleaseImage() bool {
|
||||||
return strings.HasPrefix(c.Image, "v")
|
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.
|
// GetProvider returns the configured cloud provider.
|
||||||
func (c *Config) GetProvider() cloudprovider.Provider {
|
func (c *Config) GetProvider() cloudprovider.Provider {
|
||||||
if c.Provider.AWS != nil {
|
if c.Provider.AWS != nil {
|
||||||
|
|
|
@ -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) {
|
func TestIsAppClientIDError(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
err error
|
err error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue