cli: upgrade apply uses correct measurements key (#1223)

Apply still used the obsolete upgrade key's measurements.
The new, desired behavior is to use the Provider's measurements
key
This commit is contained in:
Otto Bittner 2023-02-20 10:32:33 +01:00 committed by GitHub
parent 91c251090f
commit 87fdb47caa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -149,7 +149,7 @@ func (u *upgradeApplyCmd) handleImageUpgrade(ctx context.Context, conf *config.C
return fmt.Errorf("parsing version from image short path: %w", err)
}
err = u.upgrader.UpgradeImage(ctx, imageReference, imageVersion.Version, conf.Upgrade.Measurements)
err = u.upgrader.UpgradeImage(ctx, imageReference, imageVersion.Version, conf.GetMeasurements())
if err != nil {
return fmt.Errorf("upgrading image: %w", err)
}

View File

@ -436,6 +436,23 @@ func (c *Config) GetProvider() cloudprovider.Provider {
return cloudprovider.Unknown
}
// GetMeasurements returns the configured measurements or nil if no provder is set.
func (c *Config) GetMeasurements() measurements.M {
if c.Provider.AWS != nil {
return c.Provider.AWS.Measurements
}
if c.Provider.Azure != nil {
return c.Provider.Azure.Measurements
}
if c.Provider.GCP != nil {
return c.Provider.GCP.Measurements
}
if c.Provider.QEMU != nil {
return c.Provider.QEMU.Measurements
}
return nil
}
// EnforcesIDKeyDigest checks whether ID Key Digest should be enforced for respective cloud provider.
func (c *Config) EnforcesIDKeyDigest() bool {
return c.Provider.Azure != nil && c.Provider.Azure.EnforceIDKeyDigest != nil && *c.Provider.Azure.EnforceIDKeyDigest