Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
h3adex committed Oct 29, 2024
1 parent 06dd8dd commit 4b62216
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
17 changes: 17 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,23 @@ func TestValidInstanceTypeForProvider(t *testing.T) {
expectedResult: false,
providerConfig: ProviderConfig{OpenStack: &OpenStackConfig{Cloud: "stackit"}},
},
"openstack test": {
variant: variant.QEMUVTPM{},
instanceTypes: []string{
"foo.bar",
"foo.bar1",
},
expectedResult: true,
providerConfig: ProviderConfig{OpenStack: &OpenStackConfig{Cloud: "test"}},
},
"no provider config": {
variant: variant.QEMUVTPM{},
instanceTypes: []string{
"foo.bar",
},
expectedResult: true,
providerConfig: ProviderConfig{},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
Expand Down
12 changes: 7 additions & 5 deletions internal/config/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,15 @@ func validInstanceTypeForProvider(insType string, attestation variant.Variant, p
}
case variant.QEMUVTPM{}, variant.QEMUTDX{}:
// only allow confidential instances on stackit cloud using QEMU vTPM
if cloud := provider.OpenStack.Cloud; strings.ToLower(cloud) == "stackit" {
for _, instanceType := range instancetypes.STACKITInstanceTypes {
if insType == instanceType {
return true
if provider.OpenStack != nil {
if cloud := provider.OpenStack.Cloud; strings.ToLower(cloud) == "stackit" {
for _, instanceType := range instancetypes.STACKITInstanceTypes {
if insType == instanceType {
return true
}
}
return false
}
return false
}

return true
Expand Down

0 comments on commit 4b62216

Please sign in to comment.