Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pkg/sync/sync_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,10 @@ func WithResourceModificationChecker(enabled bool, diffResults *diff.DiffResultL
}

// WithNamespaceCreation will create non-exist namespace
func WithNamespaceCreation(createNamespace bool, namespaceModifier func(*unstructured.Unstructured) bool, namespaceCreator func(*unstructured.Unstructured) bool) SyncOpt {
func WithNamespaceCreation(createNamespace bool, namespaceModifier func(*unstructured.Unstructured) bool) SyncOpt {
return func(ctx *syncContext) {
ctx.createNamespace = createNamespace
ctx.namespaceModifier = namespaceModifier
ctx.namespaceCreator = namespaceCreator
}
}

Expand Down Expand Up @@ -352,7 +351,6 @@ type syncContext struct {

createNamespace bool
namespaceModifier func(*unstructured.Unstructured) bool
namespaceCreator func(*unstructured.Unstructured) bool

syncWaveHook common.SyncWaveHook

Expand Down Expand Up @@ -818,9 +816,7 @@ func (sc *syncContext) autoCreateNamespace(tasks syncTasks) syncTasks {
}
}
} else if apierr.IsNotFound(err) {
if sc.namespaceCreator(unstructuredObj) {
tasks = append(tasks, &syncTask{phase: common.SyncPhasePreSync, targetObj: unstructuredObj, liveObj: nil})
}
tasks = append(tasks, &syncTask{phase: common.SyncPhasePreSync, targetObj: unstructuredObj, liveObj: nil})
} else {
task := &syncTask{phase: common.SyncPhasePreSync, targetObj: unstructuredObj}
sc.setResourceResult(task, common.ResultCodeSyncFailed, common.OperationError, fmt.Sprintf("Namespace auto creation failed: %s", err))
Expand Down
Loading