Skip to content

Commit ea412da

Browse files
Restore separate --force-lock option
1 parent ffaacec commit ea412da

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

bundle/config/bundle.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ type Bundle struct {
2525
// Lock configures locking behavior on deployment.
2626
Lock Lock `json:"lock" bundle:"readonly"`
2727

28-
// Force-override deployment lock and Git branch validation.
29-
// This may be necessary if a prior deployment failed to release the lock.
30-
Force bool `json:"-" bundle:"readonly"`
28+
// Force-override Git branch validation.
29+
Force bool `json:"force" bundle:"readonly"`
3130

3231
// Contains Git information like current commit, current branch and
3332
// origin url. Automatically loaded by reading .git directory if not specified

bundle/config/lock.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ type Lock struct {
55
// Use a pointer value so that only explicitly configured values are set
66
// and we don't merge configuration with zero-initialized values.
77
Enabled *bool `json:"enabled"`
8+
9+
// Force acquisition of deployment lock even if it is currently held.
10+
// This may be necessary if a prior deployment failed to release the lock.
11+
Force bool `json:"force"`
812
}
913

1014
func (lock Lock) IsEnabled() bool {

bundle/deploy/lock/acquire.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error {
4242
return err
4343
}
4444

45-
force := b.Config.Bundle.Force
45+
force := b.Config.Bundle.Lock.Force
4646
log.Infof(ctx, "Acquiring deployment lock (force: %v)", force)
4747
err = b.Locker.Lock(ctx, force)
4848
if err != nil {

cmd/bundle/deploy.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ func newDeployCommand() *cobra.Command {
1313
PreRunE: ConfigureBundleWithVariables,
1414
}
1515

16-
var forceDeploy bool
16+
var force bool
17+
var forceLock bool
1718
var computeID string
18-
cmd.Flags().BoolVar(&forceDeploy, "force", false, "Force acquisition of deployment lock.")
19+
cmd.Flags().BoolVar(&force, "force", false, "Force-override Git branch validation.")
20+
cmd.Flags().BoolVar(&forceLock, "force-deploy", false, "Force acquisition of deployment lock.")
1921
cmd.Flags().StringVarP(&computeID, "compute-id", "c", "", "Override compute in the deployment with the given compute ID.")
2022

2123
cmd.RunE = func(cmd *cobra.Command, args []string) error {
2224
b := bundle.Get(cmd.Context())
2325

24-
// If `--force` is specified, force acquisition of the deployment lock.
25-
b.Config.Bundle.Force = forceDeploy
26+
b.Config.Bundle.Force = force
27+
b.Config.Bundle.Lock.Force = forceLock
2628
b.Config.Bundle.ComputeID = computeID
2729

2830
return bundle.Apply(cmd.Context(), b, bundle.Seq(
@@ -31,12 +33,4 @@ func newDeployCommand() *cobra.Command {
3133
phases.Deploy(),
3234
))
3335
}
34-
35-
var forceDeploy bool
36-
var computeID string
37-
38-
func init() {
39-
AddCommand(deployCmd)
40-
deployCmd.Flags().BoolVar(&forceDeploy, "force", false, "Force-override deployment lock and Git branch validation.")
41-
deployCmd.Flags().StringVarP(&computeID, "compute-id", "c", "", "Override compute in the deployment with the given compute ID.")
4236
}

cmd/bundle/destroy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ func newDestroyCommand() *cobra.Command {
2323
var autoApprove bool
2424
var forceDestroy bool
2525
cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals for deleting resources and files")
26-
cmd.Flags().BoolVar(&forceDestroy, "force", false, "Force acquisition of deployment lock.")
26+
cmd.Flags().BoolVar(&forceDestroy, "force-lock", false, "Force acquisition of deployment lock.")
2727

2828
cmd.RunE = func(cmd *cobra.Command, args []string) error {
2929
ctx := cmd.Context()
3030
b := bundle.Get(ctx)
3131

32-
// If `--force` is specified, force acquisition of the deployment lock.
33-
b.Config.Bundle.Force = forceDestroy
32+
// If `--force-lock` is specified, force acquisition of the deployment lock.
33+
b.Config.Bundle.Lock.Force = forceDestroy
3434

3535
// If `--auto-approve`` is specified, we skip confirmation checks
3636
b.AutoApprove = autoApprove

0 commit comments

Comments
 (0)