Use hook strategy as the default when performing a sync (#368)

This commit is contained in:
Jesse Suen 2018-07-10 16:02:55 -07:00 committed by GitHub
parent adb84f3d03
commit eb1caf2231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -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:

View file

@ -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))