cli: correct measurements in config generate stackit

This commit is contained in:
Malte Poll 2024-03-01 17:45:12 +01:00
parent f94c6ca0d4
commit 8b41bcaecc
3 changed files with 7 additions and 3 deletions

View File

@ -128,7 +128,7 @@ func (cg *configGenerateCmd) configGenerate(cmd *cobra.Command, fileHandler file
// createConfigWithAttestationVariant creates a config file for the given provider. // createConfigWithAttestationVariant creates a config file for the given provider.
func createConfigWithAttestationVariant(provider cloudprovider.Provider, rawProvider string, attestationVariant variant.Variant) (*config.Config, error) { func createConfigWithAttestationVariant(provider cloudprovider.Provider, rawProvider string, attestationVariant variant.Variant) (*config.Config, error) {
conf := config.Default().WithOpenStackProviderDefaults(rawProvider) conf := config.Default().WithOpenStackProviderDefaults(provider, rawProvider)
conf.RemoveProviderExcept(provider) conf.RemoveProviderExcept(provider)
// set a lower default for QEMU's state disk // set a lower default for QEMU's state disk

View File

@ -140,7 +140,7 @@ func TestConfigGenerateDefaultProviderSpecific(t *testing.T) {
fileHandler := file.NewHandler(afero.NewMemMapFs()) fileHandler := file.NewHandler(afero.NewMemMapFs())
cmd := newConfigGenerateCmd() cmd := newConfigGenerateCmd()
wantConf := config.Default().WithOpenStackProviderDefaults(tc.rawProvider) wantConf := config.Default().WithOpenStackProviderDefaults(cloudprovider.OpenStack, tc.rawProvider)
wantConf.RemoveProviderAndAttestationExcept(tc.provider) wantConf.RemoveProviderAndAttestationExcept(tc.provider)
cg := &configGenerateCmd{ cg := &configGenerateCmd{

View File

@ -900,7 +900,11 @@ func (c *Config) Validate(force bool) error {
// WithOpenStackProviderDefaults fills the default values for the specific OpenStack provider. // WithOpenStackProviderDefaults fills the default values for the specific OpenStack provider.
// If the provider is not supported or not an OpenStack provider, the config is returned unchanged. // If the provider is not supported or not an OpenStack provider, the config is returned unchanged.
func (c *Config) WithOpenStackProviderDefaults(openStackProvider string) *Config { func (c *Config) WithOpenStackProviderDefaults(csp cloudprovider.Provider, openStackProvider string) *Config {
if csp != cloudprovider.OpenStack {
return c
}
c.Attestation.QEMUVTPM = &QEMUVTPM{Measurements: measurements.DefaultsFor(cloudprovider.OpenStack, variant.QEMUVTPM{})}
switch openStackProvider { switch openStackProvider {
case "stackit": case "stackit":
c.Provider.OpenStack.Cloud = "stackit" c.Provider.OpenStack.Cloud = "stackit"