mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-27 00:19:36 -05:00
2d8fcd9bf4
Co-authored-by: Malte Poll <mp@edgeless.systems> Co-authored-by: katexochen <katexochen@users.noreply.github.com> Co-authored-by: Daniel Weiße <dw@edgeless.systems> Co-authored-by: Thomas Tendyck <tt@edgeless.systems> Co-authored-by: Benedict Schlueter <bs@edgeless.systems> Co-authored-by: leongross <leon.gross@rub.de> Co-authored-by: Moritz Eckert <m1gh7ym0@gmail.com>
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package cmd
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"io/fs"
|
|
|
|
"github.com/edgelesssys/constellation/cli/file"
|
|
"github.com/edgelesssys/constellation/internal/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newCreateCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "create aws|gcp|azure",
|
|
Short: "Create instances on a cloud platform for your Constellation.",
|
|
Long: "Create instances on a cloud platform for your Constellation.",
|
|
}
|
|
cmd.PersistentFlags().String("name", "constell", "Set this flag to create the Constellation with the specified name.")
|
|
cmd.PersistentFlags().BoolP("yes", "y", false, "Set this flag to create the Constellation without further confirmation.")
|
|
|
|
cmd.AddCommand(newCreateAWSCmd())
|
|
cmd.AddCommand(newCreateGCPCmd())
|
|
cmd.AddCommand(newCreateAzureCmd())
|
|
return cmd
|
|
}
|
|
|
|
// checkDirClean checks if files of a previous Constellation are left in the current working dir.
|
|
func checkDirClean(fileHandler file.Handler, config *config.Config) error {
|
|
if _, err := fileHandler.Stat(*config.StatePath); !errors.Is(err, fs.ErrNotExist) {
|
|
return fmt.Errorf("file '%s' already exists in working directory, run 'constellation terminate' before creating a new one", *config.StatePath)
|
|
}
|
|
if _, err := fileHandler.Stat(*config.AdminConfPath); !errors.Is(err, fs.ErrNotExist) {
|
|
return fmt.Errorf("file '%s' already exists in working directory, run 'constellation terminate' before creating a new one", *config.AdminConfPath)
|
|
}
|
|
if _, err := fileHandler.Stat(*config.MasterSecretPath); !errors.Is(err, fs.ErrNotExist) {
|
|
return fmt.Errorf("file '%s' already exists in working directory, clean it up first", *config.MasterSecretPath)
|
|
}
|
|
|
|
return nil
|
|
}
|