cli: fix upgrade by passing placeholder values for images (#2250)

Co-authored-by: Leonard Cohnen <lc@edgeless.systems>
This commit is contained in:
Adrian Stobbe 2023-08-17 07:16:09 +02:00 committed by GitHub
parent 587ae6a575
commit ca47d26634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,17 +19,21 @@ import (
// TerraformUpgradeVars returns variables required to execute the Terraform scripts. // TerraformUpgradeVars returns variables required to execute the Terraform scripts.
func TerraformUpgradeVars(conf *config.Config) (terraform.Variables, error) { func TerraformUpgradeVars(conf *config.Config) (terraform.Variables, error) {
// Note that we pass "" as imageRef, as we ignore changes to the image in the terraform. // Note that we don't pass any real image as imageRef, as we ignore changes to the image in the terraform.
// The image is updates via our operator. // The image is updates via our operator.
// Still, the terraform variable verification must accept the values.
// For AWS, we enforce some basic constraints on the image variable.
// For Azure, the provider enforces the format below.
// For GCP, any placeholder works.
switch conf.GetProvider() { switch conf.GetProvider() {
case cloudprovider.AWS: case cloudprovider.AWS:
vars := awsTerraformVars(conf, "") vars := awsTerraformVars(conf, "ami-placeholder")
return vars, nil return vars, nil
case cloudprovider.Azure: case cloudprovider.Azure:
vars := azureTerraformVars(conf, "") vars := azureTerraformVars(conf, "/communityGalleries/myGalleryName/images/myImageName/versions/latest")
return vars, nil return vars, nil
case cloudprovider.GCP: case cloudprovider.GCP:
vars := gcpTerraformVars(conf, "") vars := gcpTerraformVars(conf, "placeholder")
return vars, nil return vars, nil
default: default:
return nil, fmt.Errorf("unsupported provider: %s", conf.GetProvider()) return nil, fmt.Errorf("unsupported provider: %s", conf.GetProvider())