constellation/cli/internal/cmd/validargs.go

35 lines
845 B
Go
Raw Normal View History

/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package cmd
import (
2022-04-13 13:01:38 +02:00
"errors"
"fmt"
2022-09-21 13:47:57 +02:00
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
"github.com/spf13/cobra"
)
2022-04-13 13:01:38 +02:00
// warnAWS warns that AWS isn't supported.
func warnAWS(providerPos int) cobra.PositionalArgs {
2022-04-04 15:55:58 +02:00
return func(cmd *cobra.Command, args []string) error {
2022-04-13 13:01:38 +02:00
if cloudprovider.FromString(args[providerPos]) == cloudprovider.AWS {
2022-05-13 11:29:41 +02:00
return errors.New("AWS isn't supported by this version of Constellation")
2022-04-04 16:44:15 +02:00
}
return nil
2022-04-04 15:55:58 +02:00
}
2022-04-04 16:44:15 +02:00
}
func isCloudProvider(arg int) cobra.PositionalArgs {
return func(cmd *cobra.Command, args []string) error {
if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown {
return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg])
}
return nil
}
}