2022-09-05 07:06:08 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-03-22 15:03:15 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2022-04-13 11:01:38 +00:00
|
|
|
"errors"
|
2022-03-22 15:03:15 +00:00
|
|
|
"fmt"
|
2022-10-21 10:24:18 +00:00
|
|
|
"os"
|
2022-03-22 15:03:15 +00:00
|
|
|
|
2022-09-21 11:47:57 +00:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
2022-03-22 15:03:15 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2022-04-13 11:01:38 +00:00
|
|
|
// warnAWS warns that AWS isn't supported.
|
|
|
|
func warnAWS(providerPos int) cobra.PositionalArgs {
|
2022-04-04 13:55:58 +00:00
|
|
|
return func(cmd *cobra.Command, args []string) error {
|
2022-10-21 10:24:18 +00:00
|
|
|
if cloudprovider.FromString(args[providerPos]) == cloudprovider.AWS && os.Getenv("CONSTELLATION_AWS_DEV") != "1" {
|
|
|
|
return errors.New("AWS isn't supported yet")
|
2022-04-04 14:44:15 +00:00
|
|
|
}
|
|
|
|
return nil
|
2022-04-04 13:55:58 +00:00
|
|
|
}
|
2022-04-04 14:44:15 +00:00
|
|
|
}
|
|
|
|
|
2022-05-04 06:50:50 +00:00
|
|
|
func isCloudProvider(arg int) cobra.PositionalArgs {
|
2022-03-22 15:03:15 +00:00
|
|
|
return func(cmd *cobra.Command, args []string) error {
|
2022-05-04 06:50:50 +00:00
|
|
|
if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown {
|
|
|
|
return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg])
|
2022-03-22 15:03:15 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|