mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 16:25:21 -04:00
fix panic in status cmd (#2625)
This commit is contained in:
parent
0c1e6e97e4
commit
9af514d08e
3 changed files with 36 additions and 13 deletions
|
@ -84,6 +84,9 @@ func (s *statusCmd) status(
|
||||||
if errors.As(err, &configValidationErr) {
|
if errors.As(err, &configValidationErr) {
|
||||||
cmd.PrintErrln(configValidationErr.LongMessage())
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("loading config file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
nodeVersion, err := kubeClient.GetConstellationVersion(cmd.Context())
|
nodeVersion, err := kubeClient.GetConstellationVersion(cmd.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -265,10 +265,10 @@ func TestStatus(t *testing.T) {
|
||||||
cmd.SetErr(&errOut)
|
cmd.SetErr(&errOut)
|
||||||
|
|
||||||
fileHandler := file.NewHandler(afero.NewMemMapFs())
|
fileHandler := file.NewHandler(afero.NewMemMapFs())
|
||||||
cfg, err := createConfigWithAttestationVariant(cloudprovider.QEMU, "", variant.QEMUVTPM{})
|
cfg, err := createConfigWithAttestationVariant(cloudprovider.Azure, "", variant.AzureSEVSNP{})
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
modifyConfigForAzureToPassValidate(cfg)
|
||||||
require.NoError(fileHandler.WriteYAML(constants.ConfigFilename, cfg))
|
require.NoError(fileHandler.WriteYAML(constants.ConfigFilename, cfg))
|
||||||
|
|
||||||
s := statusCmd{fileHandler: fileHandler}
|
s := statusCmd{fileHandler: fileHandler}
|
||||||
|
|
||||||
err = s.status(
|
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 {
|
type stubKubeClient struct {
|
||||||
status map[string]kubecmd.NodeStatus
|
status map[string]kubecmd.NodeStatus
|
||||||
statusErr error
|
statusErr error
|
||||||
|
|
|
@ -397,17 +397,6 @@ func TestValidate(t *testing.T) {
|
||||||
cnf := Default()
|
cnf := Default()
|
||||||
cnf.RemoveProviderAndAttestationExcept(cloudprovider.Azure)
|
cnf.RemoveProviderAndAttestationExcept(cloudprovider.Azure)
|
||||||
cnf.Image = constants.BinaryVersion().String()
|
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)
|
modifyConfigForAzureToPassValidate(cnf)
|
||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue