Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
Open
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
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func main() {
if err != nil {
klog.Fatalf("Error initializing plugin: %v", err)
}
if registerCtx.TargetNamespace == "" {
registerCtx.TargetNamespace = registerCtx.CurrentNamespace
}

c := os.Getenv(ConfigurationEnvVar)
if c == "" {
Expand Down
16 changes: 4 additions & 12 deletions pkg/syncer/from_virtual_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,11 @@ func (f *fromVirtualController) SyncDown(ctx *synccontext.SyncContext, vObj clie
if isControlled(vObj) || !f.objectMatches(vObj) {
return ctrl.Result{}, nil
}

// apply object to physical cluster
ctx.Log.Infof("Create physical %s %s/%s, since it is missing, but virtual object exists", f.config.Kind, vObj.GetNamespace(), vObj.GetName())
_, err := f.patcher.ApplyPatches(ctx.Context, vObj, nil, f.config.Patches, f.config.ReversePatches, func(vObj client.Object) (client.Object, error) {
return f.TranslateMetadata(vObj), nil
}, &virtualToHostNameResolver{namespace: vObj.GetNamespace(), targetNamespace: f.targetNamespace})
if err != nil {
f.EventRecorder().Eventf(vObj, "Warning", "SyncError", "Error syncing to physical cluster: %v", err)
return ctrl.Result{}, fmt.Errorf("error applying patches: %v", err)
}

return ctrl.Result{}, nil
// create object in physical cluster
ctx.Log.Infof("SyncDown called for %s", vObj.GetName())
return f.SyncDownCreate(ctx, vObj, f.TranslateMetadata(vObj))
}

func (f *fromVirtualController) isExcluded(pObj client.Object) bool {
labels := pObj.GetLabels()
return labels == nil || labels[controlledByLabel] != f.getControllerID()
Expand Down