Add 'constellation config instance-types'

This commit is contained in:
Nils Hanke 2022-09-01 16:46:24 +02:00 committed by Nils Hanke
parent 39eb58b403
commit c0bfb9b61e
3 changed files with 38 additions and 0 deletions

View File

@ -14,6 +14,7 @@ func NewConfigCmd() *cobra.Command {
cmd.AddCommand(newConfigGenerateCmd()) cmd.AddCommand(newConfigGenerateCmd())
cmd.AddCommand(newConfigFetchMeasurementsCmd()) cmd.AddCommand(newConfigFetchMeasurementsCmd())
cmd.AddCommand(NewConfigInstanceTypesCmd())
return cmd return cmd
} }

View File

@ -63,6 +63,8 @@ func configGenerate(cmd *cobra.Command, fileHandler file.Handler, provider cloud
} }
cmd.Println("Config file written to", flags.file) cmd.Println("Config file written to", flags.file)
cmd.Println("Please fill in your CSP specific configuration before proceeding.") cmd.Println("Please fill in your CSP specific configuration before proceeding.")
cmd.Println("You can find the list of supported virtual machine types by executing:")
cmd.Println("\tconstellation config instance-types")
return nil return nil
} }

View File

@ -0,0 +1,35 @@
package cmd
import (
"fmt"
"strings"
"github.com/edgelesssys/constellation/internal/config/instancetypes"
"github.com/spf13/cobra"
)
func NewConfigInstanceTypesCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "instance-types",
Short: "Prints the supported instance types for all cloud providers",
Long: "Prints the supported instance types for all cloud providers.",
Args: cobra.ArbitraryArgs,
Run: printSupportedInstanceTypes,
}
return cmd
}
func printSupportedInstanceTypes(cmd *cobra.Command, args []string) {
fmt.Printf(`Azure Confidential VM instance types:
%v
Azure Trusted Launch instance types:
%v
GCP instance types:
%v
`, formatInstanceTypes(instancetypes.AzureCVMInstanceTypes), formatInstanceTypes(instancetypes.AzureTrustedLaunchInstanceTypes), formatInstanceTypes(instancetypes.GCPInstanceTypes))
}
func formatInstanceTypes(types []string) string {
return "\t" + strings.Join(types, "\n\t")
}