mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 14:26:23 -04:00
cli: add Terraform log support (#1620)
* add Terraform logging * add TF logging to CLI * fix path * only create file if logging is enabled * update bazel files * register persistent flags manually * clidocgen * move logging code to separate file * reword yes flag parsing error * update bazel buildfile * factor out log level setting
This commit is contained in:
parent
ca1400819d
commit
1d0ee796e8
30 changed files with 688 additions and 238 deletions
|
@ -153,7 +153,15 @@ func (c *createCmd) create(cmd *cobra.Command, creator cloudCreator, fileHandler
|
|||
}
|
||||
|
||||
spinner.Start("Creating", false)
|
||||
idFile, err := creator.Create(cmd.Context(), provider, conf, instanceType, flags.controllerCount, flags.workerCount)
|
||||
opts := cloudcmd.CreateOptions{
|
||||
Provider: provider,
|
||||
Config: conf,
|
||||
InsType: instanceType,
|
||||
ControlPlaneCount: flags.controllerCount,
|
||||
WorkerCount: flags.workerCount,
|
||||
TFLogLevel: flags.tfLogLevel,
|
||||
}
|
||||
idFile, err := creator.Create(cmd.Context(), opts)
|
||||
spinner.Stop()
|
||||
if err != nil {
|
||||
return translateCreateErrors(cmd, err)
|
||||
|
@ -190,7 +198,7 @@ func (c *createCmd) parseCreateFlags(cmd *cobra.Command) (createFlags, error) {
|
|||
|
||||
yes, err := cmd.Flags().GetBool("yes")
|
||||
if err != nil {
|
||||
return createFlags{}, fmt.Errorf("%w; Set '-yes' without a value to automatically confirm", err)
|
||||
return createFlags{}, fmt.Errorf("parsing yes bool: %w", err)
|
||||
}
|
||||
c.log.Debugf("Yes flag is %t", yes)
|
||||
|
||||
|
@ -206,10 +214,21 @@ func (c *createCmd) parseCreateFlags(cmd *cobra.Command) (createFlags, error) {
|
|||
}
|
||||
c.log.Debugf("force flag is %t", force)
|
||||
|
||||
logLevelString, err := cmd.Flags().GetString("tf-log")
|
||||
if err != nil {
|
||||
return createFlags{}, fmt.Errorf("parsing tf-log string: %w", err)
|
||||
}
|
||||
logLevel, err := terraform.ParseLogLevel(logLevelString)
|
||||
if err != nil {
|
||||
return createFlags{}, fmt.Errorf("parsing Terraform log level %s: %w", logLevelString, err)
|
||||
}
|
||||
c.log.Debugf("Terraform logs will be written into %s at level %s", constants.TerraformLogFile, logLevel.String())
|
||||
|
||||
return createFlags{
|
||||
controllerCount: controllerCount,
|
||||
workerCount: workerCount,
|
||||
configPath: configPath,
|
||||
tfLogLevel: logLevel,
|
||||
force: force,
|
||||
yes: yes,
|
||||
}, nil
|
||||
|
@ -220,6 +239,7 @@ type createFlags struct {
|
|||
controllerCount int
|
||||
workerCount int
|
||||
configPath string
|
||||
tfLogLevel terraform.LogLevel
|
||||
force bool
|
||||
yes bool
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue