Skip to content

Commit

Permalink
[wip] Move unit tests to new apply backend
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Weiße <[email protected]>
  • Loading branch information
daniel-weisse committed Oct 12, 2023
1 parent 607d568 commit fd19bc9
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 1,031 deletions.
21 changes: 15 additions & 6 deletions cli/internal/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi"
"github.com/edgelesssys/constellation/v2/internal/atls"
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
"github.com/edgelesssys/constellation/v2/internal/compatibility"
"github.com/edgelesssys/constellation/v2/internal/config"
"github.com/edgelesssys/constellation/v2/internal/constants"
Expand Down Expand Up @@ -64,8 +65,7 @@ func (f *applyFlags) parse(flags *pflag.FlagSet) error {

rawSkipPhases, err := flags.GetStringSlice("skip-phases")
if err != nil {
rawSkipPhases = []string{}
// return fmt.Errorf("getting 'skip-phases' flag: %w", err)
return fmt.Errorf("getting 'skip-phases' flag: %w", err)
}
var skipPhases []skipPhase
for _, phase := range rawSkipPhases {
Expand All @@ -80,8 +80,7 @@ func (f *applyFlags) parse(flags *pflag.FlagSet) error {

f.yes, err = flags.GetBool("yes")
if err != nil {
f.yes = false
// return fmt.Errorf("getting 'yes' flag: %w", err)
return fmt.Errorf("getting 'yes' flag: %w", err)
}

f.upgradeTimeout, err = flags.GetDuration("timeout")
Expand All @@ -106,8 +105,7 @@ func (f *applyFlags) parse(flags *pflag.FlagSet) error {

f.mergeConfigs, err = flags.GetBool("merge-kubeconfig")
if err != nil {
f.mergeConfigs = false
// return fmt.Errorf("getting 'merge-kubeconfig' flag: %w", err)
return fmt.Errorf("getting 'merge-kubeconfig' flag: %w", err)
}
return nil
}
Expand Down Expand Up @@ -339,6 +337,17 @@ func (a *applyCmd) apply(cmd *cobra.Command, configFetcher attestationconfigapi.
}
}

// Constellation on QEMU or OpenStack don't support upgrades
// If using one of those providers, make sure the command is only used to initialize a cluster
if !(conf.GetProvider() == cloudprovider.AWS || conf.GetProvider() == cloudprovider.Azure || conf.GetProvider() == cloudprovider.GCP) {
if !initRequired {
return fmt.Errorf("upgrades are not supported for provider %s", conf.GetProvider())
}
// Skip Terraform phase
a.log.Debugf("Skipping Infrastructure phase for provider %s", conf.GetProvider())
a.flags.skipPhases = append(a.flags.skipPhases, skipInfrastructurePhase)
}

// Print warning about AWS attestation
// TODO(derpsteb): remove once AWS fixes SEV-SNP attestation provisioning issues
if initRequired && conf.GetAttestationConfig().GetVariant().Equal(variant.AWSSEVSNP{}) {
Expand Down
Loading

0 comments on commit fd19bc9

Please sign in to comment.