mirror of
https://github.com/argoproj/argo-cd
synced 2026-05-24 01:38:43 +00:00
Use hook strategy as the default when performing a sync (#368)
This commit is contained in:
parent
adb84f3d03
commit
eb1caf2231
2 changed files with 8 additions and 8 deletions
|
|
@ -780,10 +780,10 @@ func NewApplicationSyncCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
|
|||
Prune: prune,
|
||||
}
|
||||
switch strategy {
|
||||
case "", "apply":
|
||||
case "apply":
|
||||
syncReq.Strategy = &argoappv1.SyncStrategy{Apply: &argoappv1.SyncStrategyApply{}}
|
||||
syncReq.Strategy.Apply.Force = force
|
||||
case "hook":
|
||||
case "", "hook":
|
||||
syncReq.Strategy = &argoappv1.SyncStrategy{Hook: &argoappv1.SyncStrategyHook{}}
|
||||
syncReq.Strategy.Hook.Force = force
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -184,13 +184,13 @@ func (sc *syncContext) sync() {
|
|||
}
|
||||
|
||||
// All objects passed a `kubectl apply --dry-run`, so we are now ready to actually perform the sync.
|
||||
if sc.syncOp.SyncStrategy == nil {
|
||||
// default sync strategy to hook if no strategy
|
||||
sc.syncOp.SyncStrategy = &appv1.SyncStrategy{Hook: &appv1.SyncStrategyHook{}}
|
||||
}
|
||||
if sc.syncOp.SyncStrategy.Apply != nil {
|
||||
forceApply := false
|
||||
if sc.syncOp.SyncStrategy != nil && sc.syncOp.SyncStrategy.Apply != nil {
|
||||
forceApply = sc.syncOp.SyncStrategy.Apply.Force
|
||||
}
|
||||
sc.doApplySync(syncTasks, false, forceApply)
|
||||
} else if sc.syncOp.SyncStrategy.Hook != nil || sc.syncOp.SyncStrategy == nil {
|
||||
sc.doApplySync(syncTasks, false, sc.syncOp.SyncStrategy.Apply.Force)
|
||||
} else if sc.syncOp.SyncStrategy.Hook != nil {
|
||||
hooks, err := sc.getHooks()
|
||||
if err != nil {
|
||||
sc.setOperationPhase(appv1.OperationError, fmt.Sprintf("failed to generate hooks resources: %v", err))
|
||||
|
|
|
|||
Loading…
Reference in a new issue