mirror of https://github.com/databricks/cli.git
address comments round 1
This commit is contained in:
parent
f8d3c1d50c
commit
6170289a49
|
@ -28,10 +28,10 @@ func (w *apply) Name() string {
|
||||||
func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) ([]bundle.Mutator, error) {
|
func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) ([]bundle.Mutator, error) {
|
||||||
// return early if plan is empty
|
// return early if plan is empty
|
||||||
if b.Plan.IsEmpty {
|
if b.Plan.IsEmpty {
|
||||||
if w.goal == ApplyDeploy {
|
switch w.goal {
|
||||||
|
case ApplyDeploy:
|
||||||
cmdio.LogString(ctx, "No resource changes to apply. Skipping deploy!")
|
cmdio.LogString(ctx, "No resource changes to apply. Skipping deploy!")
|
||||||
}
|
case ApplyDestroy:
|
||||||
if w.goal == ApplyDestroy {
|
|
||||||
cmdio.LogString(ctx, "No resources to destroy in plan. Skipping destroy!")
|
cmdio.LogString(ctx, "No resources to destroy in plan. Skipping destroy!")
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -72,10 +72,10 @@ func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) ([]bundle.Mutator,
|
||||||
return nil, fmt.Errorf("no plan found")
|
return nil, fmt.Errorf("no plan found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.goal == ApplyDeploy {
|
switch w.goal {
|
||||||
|
case ApplyDeploy:
|
||||||
cmdio.LogString(ctx, "\nStarting resource deployment")
|
cmdio.LogString(ctx, "\nStarting resource deployment")
|
||||||
}
|
case ApplyDestroy:
|
||||||
if w.goal == ApplyDestroy {
|
|
||||||
cmdio.LogString(ctx, "\nStarting resource destruction")
|
cmdio.LogString(ctx, "\nStarting resource destruction")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +85,10 @@ func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) ([]bundle.Mutator,
|
||||||
return nil, fmt.Errorf("terraform apply: %w", err)
|
return nil, fmt.Errorf("terraform apply: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.goal == ApplyDeploy {
|
switch w.goal {
|
||||||
|
case ApplyDeploy:
|
||||||
cmdio.LogString(ctx, "Successfully deployed resources!")
|
cmdio.LogString(ctx, "Successfully deployed resources!")
|
||||||
}
|
case ApplyDestroy:
|
||||||
if w.goal == ApplyDestroy {
|
|
||||||
cmdio.LogString(ctx, "Successfully destroyed resources!")
|
cmdio.LogString(ctx, "Successfully destroyed resources!")
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
@ -22,11 +22,11 @@ const (
|
||||||
ActionUpdate = Action("update")
|
ActionUpdate = Action("update")
|
||||||
ActionDelete = Action("delete")
|
ActionDelete = Action("delete")
|
||||||
ActionReplace = Action("replace")
|
ActionReplace = Action("replace")
|
||||||
ActionNoop = Action("no-op")
|
ActionNoOp = Action("no-op")
|
||||||
)
|
)
|
||||||
|
|
||||||
func toAction(actions tfjson.Actions) Action {
|
func toAction(actions tfjson.Actions) Action {
|
||||||
action := ActionNoop
|
action := ActionNoOp
|
||||||
switch {
|
switch {
|
||||||
case actions.Create():
|
case actions.Create():
|
||||||
action = ActionCreate
|
action = ActionCreate
|
||||||
|
|
|
@ -19,9 +19,9 @@ func Deploy() bundle.Mutator {
|
||||||
terraform.Interpolate(),
|
terraform.Interpolate(),
|
||||||
terraform.Write(),
|
terraform.Write(),
|
||||||
terraform.StatePull(),
|
terraform.StatePull(),
|
||||||
terraform.Plan("deploy"),
|
terraform.Plan(terraform.PlanDeploy),
|
||||||
terraform.ShowPlan(),
|
terraform.ShowPlan(),
|
||||||
terraform.Apply("deploy"),
|
terraform.Apply(terraform.ApplyDeploy),
|
||||||
terraform.StatePush(),
|
terraform.StatePush(),
|
||||||
lock.Release(),
|
lock.Release(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,9 +14,9 @@ func Destroy() bundle.Mutator {
|
||||||
[]bundle.Mutator{
|
[]bundle.Mutator{
|
||||||
lock.Acquire(),
|
lock.Acquire(),
|
||||||
terraform.StatePull(),
|
terraform.StatePull(),
|
||||||
terraform.Plan("destroy"),
|
terraform.Plan(terraform.PlanDestroy),
|
||||||
terraform.ShowPlan(),
|
terraform.ShowPlan(),
|
||||||
terraform.Apply("destroy"),
|
terraform.Apply(terraform.ApplyDestroy),
|
||||||
terraform.StatePush(),
|
terraform.StatePush(),
|
||||||
lock.Release(),
|
lock.Release(),
|
||||||
files.Delete(),
|
files.Delete(),
|
||||||
|
|
|
@ -23,14 +23,14 @@ var deployCmd = &cobra.Command{
|
||||||
b := bundle.Get(cmd.Context())
|
b := bundle.Get(cmd.Context())
|
||||||
|
|
||||||
// If `--force` is specified, force acquisition of the deployment lock.
|
// If `--force` is specified, force acquisition of the deployment lock.
|
||||||
b.Config.Bundle.Lock.Force = force
|
b.Config.Bundle.Lock.Force = forceDeploy
|
||||||
|
|
||||||
// If `--auto-approve`` is specified, we skip confirmation checks
|
// If `--auto-approve`` is specified, we skip confirmation checks
|
||||||
b.AutoApprove = autoApprove
|
b.AutoApprove = autoApproveDeploy
|
||||||
|
|
||||||
// we require auto-approve for non tty terminals since interactive consent
|
// we require auto-approve for non tty terminals since interactive consent
|
||||||
// is not possible
|
// is not possible
|
||||||
if !term.IsTerminal(int(os.Stderr.Fd())) && !autoApprove {
|
if !term.IsTerminal(int(os.Stderr.Fd())) && !autoApproveDeploy {
|
||||||
return fmt.Errorf("please specify --auto-approve to skip interactive confirmation checks for non tty consoles")
|
return fmt.Errorf("please specify --auto-approve to skip interactive confirmation checks for non tty consoles")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ var deployCmd = &cobra.Command{
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("progress logger not found")
|
return fmt.Errorf("progress logger not found")
|
||||||
}
|
}
|
||||||
if logger.Mode == flags.ModeJson && !autoApprove {
|
if logger.Mode == flags.ModeJson && !autoApproveDeploy {
|
||||||
return fmt.Errorf("please specify --auto-approve since selected logging format is json")
|
return fmt.Errorf("please specify --auto-approve since selected logging format is json")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ var deployCmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var force bool
|
var forceDeploy bool
|
||||||
|
|
||||||
var autoApprove bool
|
var autoApproveDeploy bool
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
AddCommand(deployCmd)
|
AddCommand(deployCmd)
|
||||||
deployCmd.Flags().BoolVar(&force, "force", false, "Force acquisition of deployment lock.")
|
deployCmd.Flags().BoolVar(&forceDeploy, "force", false, "Force acquisition of deployment lock.")
|
||||||
deployCmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals")
|
deployCmd.Flags().BoolVar(&autoApproveDeploy, "auto-approve", false, "Skip interactive approvals")
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,14 @@ var destroyCmd = &cobra.Command{
|
||||||
b := bundle.Get(ctx)
|
b := bundle.Get(ctx)
|
||||||
|
|
||||||
// If `--force` is specified, force acquisition of the deployment lock.
|
// If `--force` is specified, force acquisition of the deployment lock.
|
||||||
b.Config.Bundle.Lock.Force = force
|
b.Config.Bundle.Lock.Force = forceDestroy
|
||||||
|
|
||||||
// If `--auto-approve`` is specified, we skip confirmation checks
|
// If `--auto-approve`` is specified, we skip confirmation checks
|
||||||
b.AutoApprove = autoApprove
|
b.AutoApprove = autoApproveDestroy
|
||||||
|
|
||||||
// we require auto-approve for non tty terminals since interactive consent
|
// we require auto-approve for non tty terminals since interactive consent
|
||||||
// is not possible
|
// is not possible
|
||||||
if !term.IsTerminal(int(os.Stderr.Fd())) && !autoApprove {
|
if !term.IsTerminal(int(os.Stderr.Fd())) && !autoApproveDestroy {
|
||||||
return fmt.Errorf("please specify --auto-approve to skip interactive confirmation checks for non tty consoles")
|
return fmt.Errorf("please specify --auto-approve to skip interactive confirmation checks for non tty consoles")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ var destroyCmd = &cobra.Command{
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("progress logger not found")
|
return fmt.Errorf("progress logger not found")
|
||||||
}
|
}
|
||||||
if logger.Mode == flags.ModeJson && !autoApprove {
|
if logger.Mode == flags.ModeJson && !autoApproveDestroy {
|
||||||
return fmt.Errorf("please specify --auto-approve since selected logging format is json")
|
return fmt.Errorf("please specify --auto-approve since selected logging format is json")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,12 @@ var destroyCmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var forceDestroy bool
|
||||||
|
|
||||||
|
var autoApproveDestroy bool
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
AddCommand(destroyCmd)
|
AddCommand(destroyCmd)
|
||||||
destroyCmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals")
|
destroyCmd.Flags().BoolVar(&autoApproveDestroy, "auto-approve", false, "Skip interactive approvals")
|
||||||
destroyCmd.Flags().BoolVar(&force, "force", false, "Force acquisition of deployment lock.")
|
destroyCmd.Flags().BoolVar(&forceDestroy, "force", false, "Force acquisition of deployment lock.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue