mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-20 15:35:55 -04:00
Use error variable for QEMU cluster on non-Linux amd64
This commit is contained in:
parent
48d08f4d47
commit
7500eb3e39
@ -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 {
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user