diff --git a/cli/internal/cmd/status.go b/cli/internal/cmd/status.go index 41467e888..a80c2a7c1 100644 --- a/cli/internal/cmd/status.go +++ b/cli/internal/cmd/status.go @@ -84,6 +84,9 @@ func (s *statusCmd) status( if errors.As(err, &configValidationErr) { cmd.PrintErrln(configValidationErr.LongMessage()) } + if err != nil { + return fmt.Errorf("loading config file: %w", err) + } nodeVersion, err := kubeClient.GetConstellationVersion(cmd.Context()) if err != nil { diff --git a/cli/internal/cmd/status_test.go b/cli/internal/cmd/status_test.go index 6d94b6a41..51f305f7c 100644 --- a/cli/internal/cmd/status_test.go +++ b/cli/internal/cmd/status_test.go @@ -265,10 +265,10 @@ func TestStatus(t *testing.T) { cmd.SetErr(&errOut) fileHandler := file.NewHandler(afero.NewMemMapFs()) - cfg, err := createConfigWithAttestationVariant(cloudprovider.QEMU, "", variant.QEMUVTPM{}) + cfg, err := createConfigWithAttestationVariant(cloudprovider.Azure, "", variant.AzureSEVSNP{}) require.NoError(err) + modifyConfigForAzureToPassValidate(cfg) require.NoError(fileHandler.WriteYAML(constants.ConfigFilename, cfg)) - s := statusCmd{fileHandler: fileHandler} err = s.status( @@ -287,6 +287,37 @@ func TestStatus(t *testing.T) { } } +func modifyConfigForAzureToPassValidate(c *config.Config) { + c.RemoveProviderAndAttestationExcept(cloudprovider.Azure) + c.Image = constants.BinaryVersion().String() + c.Provider.Azure.SubscriptionID = "11111111-1111-1111-1111-111111111111" + c.Provider.Azure.TenantID = "11111111-1111-1111-1111-111111111111" + c.Provider.Azure.Location = "westus" + c.Provider.Azure.ResourceGroup = "test" + c.Provider.Azure.UserAssignedIdentity = "/subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/constellation-identity/providers/Microsoft.ManagedIdentity/userAssignedIdentities/constellation-identity" + c.Attestation.AzureSEVSNP.Measurements = measurements.M{ + 0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength), + } + c.NodeGroups = map[string]config.NodeGroup{ + constants.ControlPlaneDefault: { + Role: "control-plane", + Zone: "", + InstanceType: "Standard_DC4as_v5", + StateDiskSizeGB: 30, + StateDiskType: "StandardSSD_LRS", + InitialCount: 3, + }, + constants.WorkerDefault: { + Role: "worker", + Zone: "", + InstanceType: "Standard_DC4as_v5", + StateDiskSizeGB: 30, + StateDiskType: "StandardSSD_LRS", + InitialCount: 3, + }, + } +} + type stubKubeClient struct { status map[string]kubecmd.NodeStatus statusErr error diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 678730f71..7c4c5c015 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -397,17 +397,6 @@ func TestValidate(t *testing.T) { cnf := Default() cnf.RemoveProviderAndAttestationExcept(cloudprovider.Azure) cnf.Image = constants.BinaryVersion().String() - az := cnf.Provider.Azure - az.SubscriptionID = "01234567-0123-0123-0123-0123456789ab" - az.TenantID = "01234567-0123-0123-0123-0123456789ab" - az.Location = "test-location" - az.UserAssignedIdentity = "test-identity" - az.ResourceGroup = "test-resource-group" - cnf.Provider = ProviderConfig{} - cnf.Provider.Azure = az - cnf.Attestation.AzureSEVSNP.Measurements = measurements.M{ - 0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength), - } modifyConfigForAzureToPassValidate(cnf) return cnf }(),