diff --git a/cli/internal/cloudcmd/create.go b/cli/internal/cloudcmd/create.go index 490cc84a5..889c8291b 100644 --- a/cli/internal/cloudcmd/create.go +++ b/cli/internal/cloudcmd/create.go @@ -22,6 +22,9 @@ import ( "github.com/edgelesssys/constellation/v2/internal/config" ) +// ErrQEMUCreationNotSupportedOnPlatform is returned when trying to create a QEMU cluster on a platform other than linux/amd64 +var ErrQEMUCreationNotSupportedOnPlatform = fmt.Errorf("creation of a QEMU based Constellation is not supported for %s/%s (only linux/amd64 is supported)", runtime.GOOS, runtime.GOARCH) + // Creator creates cloud resources. type Creator struct { out io.Writer @@ -73,7 +76,7 @@ func (c *Creator) Create(ctx context.Context, provider cloudprovider.Provider, c return c.createAzure(ctx, cl, config, name, insType, controlPlaneCount, workerCount) case cloudprovider.QEMU: if runtime.GOARCH != "amd64" || runtime.GOOS != "linux" { - return clusterid.File{}, fmt.Errorf("creation of a QEMU based Constellation is not supported for %s/%s", runtime.GOOS, runtime.GOARCH) + return clusterid.File{}, ErrQEMUCreationNotSupportedOnPlatform } cl, err := c.newTerraformClient(ctx, provider) if err != nil { diff --git a/cli/internal/cloudcmd/terminate.go b/cli/internal/cloudcmd/terminate.go index 40a3eb10f..d1d1c8fc2 100644 --- a/cli/internal/cloudcmd/terminate.go +++ b/cli/internal/cloudcmd/terminate.go @@ -17,6 +17,9 @@ import ( "github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider" ) +// ErrQEMUCreationNotSupportedOnPlatform is returned when trying to destroy a QEMU cluster on a platform other than linux/amd64 +var ErrQEMUTerminationNotSupportedOnPlatform = fmt.Errorf("termination of a QEMU based Constellation is not supported for %s/%s (only linux/amd64 is supported)", runtime.GOOS, runtime.GOARCH) + // Terminator deletes cloud provider resources. type Terminator struct { newTerraformClient func(ctx context.Context, provider cloudprovider.Provider) (terraformClient, error) @@ -43,7 +46,7 @@ func (t *Terminator) Terminate(ctx context.Context, provider cloudprovider.Provi if provider == cloudprovider.QEMU { if runtime.GOARCH != "amd64" || runtime.GOOS != "linux" { - return fmt.Errorf("termination of a QEMU based Constellation is not supported for %s/%s", runtime.GOOS, runtime.GOARCH) + return ErrQEMUTerminationNotSupportedOnPlatform } libvirt := t.newLibvirtRunner() diff --git a/cli/internal/cmd/minidown.go b/cli/internal/cmd/minidown.go index 9b869c0b8..e0a77e0d6 100644 --- a/cli/internal/cmd/minidown.go +++ b/cli/internal/cmd/minidown.go @@ -10,6 +10,9 @@ import ( "errors" "fmt" "os" + "runtime" + + "github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd" "github.com/edgelesssys/constellation/v2/cli/internal/clusterid" "github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider" @@ -33,6 +36,10 @@ func newMiniDownCmd() *cobra.Command { } func runDown(cmd *cobra.Command, args []string) error { + if runtime.GOARCH != "amd64" || runtime.GOOS != "linux" { + return cloudcmd.ErrQEMUTerminationNotSupportedOnPlatform + } + if err := checkForMiniCluster(file.NewHandler(afero.NewOsFs())); err != nil { return fmt.Errorf("failed to destroy cluster: %w. Are you in the correct working directory?", err) } diff --git a/cli/internal/cmd/minidown_windows.go b/cli/internal/cmd/minidown_windows.go index 2788e6b2b..8e5f01098 100644 --- a/cli/internal/cmd/minidown_windows.go +++ b/cli/internal/cmd/minidown_windows.go @@ -10,9 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only package cmd import ( - "fmt" - "runtime" - + "github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd" "github.com/spf13/cobra" ) @@ -29,5 +27,5 @@ func newMiniDownCmd() *cobra.Command { } func runDown(cmd *cobra.Command, args []string) error { - return fmt.Errorf("termination of a QEMU based Constellation is not supported for %s/%s", runtime.GOOS, runtime.GOARCH) + return cloudcmd.ErrQEMUTerminationNotSupportedOnPlatform } diff --git a/cli/internal/cmd/miniup.go b/cli/internal/cmd/miniup.go index b37311050..324713533 100644 --- a/cli/internal/cmd/miniup.go +++ b/cli/internal/cmd/miniup.go @@ -106,7 +106,7 @@ func up(cmd *cobra.Command, creator cloudCreator, spinner spinnerInterf) error { func checkSystemRequirements(out io.Writer) error { // check arch/os if runtime.GOARCH != "amd64" || runtime.GOOS != "linux" { - return fmt.Errorf("creation of a QEMU based Constellation is not supported for %s/%s", runtime.GOOS, runtime.GOARCH) + return cloudcmd.ErrQEMUCreationNotSupportedOnPlatform } // check if /dev/kvm exists diff --git a/cli/internal/cmd/miniup_windows.go b/cli/internal/cmd/miniup_windows.go index 7aa1a8ba1..08494ca84 100644 --- a/cli/internal/cmd/miniup_windows.go +++ b/cli/internal/cmd/miniup_windows.go @@ -10,9 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only package cmd import ( - "fmt" - "runtime" - + "github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd" "github.com/spf13/cobra" ) @@ -33,5 +31,5 @@ func newMiniUpCmd() *cobra.Command { } func runUp(cmd *cobra.Command, args []string) error { - return fmt.Errorf("creation of a QEMU based Constellation is not supported for %s/%s", runtime.GOOS, runtime.GOARCH) + return cloudcmd.ErrQEMUCreationNotSupportedOnPlatform }