From 3ca4eec52f5fb9cada98413ed3e9ab7eea9f1ac9 Mon Sep 17 00:00:00 2001 From: Fabian Kramm Date: Thu, 1 Feb 2024 19:49:27 +0100 Subject: [PATCH] chore: bump example sdk --- e2e/test_plugin/syncers/car.go | 8 +- e2e/test_plugin/syncers/import_secrets.go | 14 +- examples/crd-sync/syncers/car.go | 6 +- .../import-secrets/syncers/import_secrets.go | 12 +- go.mod | 4 +- go.sum | 8 +- .../cmd/vclusterctl/cmd/telemetry/disable.go | 2 +- .../cmd/vclusterctl/cmd/telemetry/enable.go | 2 +- .../vclusterctl/cmd/telemetry/telemetry.go | 2 +- .../pkg/controllers/generic/export_syncer.go | 6 +- .../pkg/controllers/generic/import_syncer.go | 12 +- .../resources/configmaps/syncer.go | 6 +- .../resources/csidrivers/syncer.go | 6 +- .../controllers/resources/csinodes/syncer.go | 6 +- .../resources/csistoragecapacities/syncer.go | 8 +- .../csistoragecapacities/translator.go | 8 +- .../controllers/resources/endpoints/syncer.go | 8 +- .../controllers/resources/events/syncer.go | 221 ++++++++++-------- .../resources/ingressclasses/syncer.go | 6 +- .../resources/ingresses/legacy/syncer.go | 6 +- .../controllers/resources/ingresses/syncer.go | 6 +- .../resources/namespaces/syncer.go | 2 +- .../resources/networkpolicies/syncer.go | 6 +- .../resources/nodes/fake_syncer.go | 2 +- .../pkg/controllers/resources/nodes/syncer.go | 10 +- .../persistentvolumeclaims/syncer.go | 6 +- .../persistentvolumes/fake_syncer.go | 2 +- .../resources/persistentvolumes/syncer.go | 10 +- .../resources/poddisruptionbudgets/syncer.go | 6 +- .../pkg/controllers/resources/pods/syncer.go | 6 +- .../resources/priorityclasses/syncer.go | 2 +- .../controllers/resources/secrets/syncer.go | 6 +- .../resources/serviceaccounts/syncer.go | 6 +- .../controllers/resources/services/syncer.go | 10 +- .../storageclasses/host_sc_syncer.go | 6 +- .../resources/storageclasses/syncer.go | 2 +- .../volumesnapshotclasses/syncer.go | 6 +- .../volumesnapshotcontents/syncer.go | 10 +- .../volumesnapshots/volumesnapshots/syncer.go | 6 +- .../pkg/controllers/syncer/fake_syncer.go | 2 +- .../vcluster/pkg/controllers/syncer/syncer.go | 18 +- .../syncer/translator/cluster_translator.go | 4 +- .../translator/mirror_name_translator.go | 4 +- .../translator/namespaced_translator.go | 10 +- .../syncer/translator/translator.go | 18 +- .../loft-sh/vcluster/pkg/types/types.go | 12 +- vendor/modules.txt | 4 +- 47 files changed, 279 insertions(+), 254 deletions(-) diff --git a/e2e/test_plugin/syncers/car.go b/e2e/test_plugin/syncers/car.go index e3c77425..ebf0159d 100644 --- a/e2e/test_plugin/syncers/car.go +++ b/e2e/test_plugin/syncers/car.go @@ -43,12 +43,14 @@ func (s *carSyncer) Init(ctx *synccontext.RegisterContext) error { return err } -func (s *carSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.TranslateMetadata(ctx.Context, vObj).(*examplev1.Car)) +var _ synctypes.Syncer = &carSyncer{} + +func (s *carSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.TranslateMetadata(ctx.Context, vObj).(*examplev1.Car)) } func (s *carSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownUpdate(ctx, vObj, s.translateUpdate(ctx.Context, pObj.(*examplev1.Car), vObj.(*examplev1.Car))) + return s.SyncToHostUpdate(ctx, vObj, s.translateUpdate(ctx.Context, pObj.(*examplev1.Car), vObj.(*examplev1.Car))) } func (s *carSyncer) translateUpdate(ctx context.Context, pObj, vObj *examplev1.Car) *examplev1.Car { diff --git a/e2e/test_plugin/syncers/import_secrets.go b/e2e/test_plugin/syncers/import_secrets.go index 4c70ff6c..e502a600 100644 --- a/e2e/test_plugin/syncers/import_secrets.go +++ b/e2e/test_plugin/syncers/import_secrets.go @@ -38,9 +38,9 @@ func (s *importSecretSyncer) Resource() client.Object { return &corev1.Secret{} } -var _ synctypes.UpSyncer = &importSecretSyncer{} +var _ synctypes.ToVirtualSyncer = &importSecretSyncer{} -func (s *importSecretSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *importSecretSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { pSecret := pObj.(*corev1.Secret) // ignore Secrets synced to the host by the vcluster @@ -124,7 +124,7 @@ func (s *importSecretSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Obje return ctrl.Result{}, err } -func (s *importSecretSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *importSecretSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { // this is called when the secret in the host gets removed // or if the vObj is an unrelated Secret created in vcluster @@ -152,8 +152,8 @@ func (s *importSecretSyncer) IsManaged(ctx context.Context, pObj client.Object) return parseFromAnnotation(pObj.GetAnnotations(), pImportAnnotation).Name != "", nil } -// VirtualToPhysical translates a virtual name to a physical name -func (s *importSecretSyncer) VirtualToPhysical(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +// VirtualToHost translates a virtual name to a physical name +func (s *importSecretSyncer) VirtualToHost(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { if vObj == nil { return types.NamespacedName{} } @@ -167,8 +167,8 @@ func (s *importSecretSyncer) VirtualToPhysical(ctx context.Context, req types.Na return name } -// PhysicalToVirtual translates a physical name to a virtual name -func (s *importSecretSyncer) PhysicalToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { +// HostToVirtual translates a physical name to a virtual name +func (s *importSecretSyncer) HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { if pObj == nil { return types.NamespacedName{} } diff --git a/examples/crd-sync/syncers/car.go b/examples/crd-sync/syncers/car.go index ced3cf8f..a191cbf1 100644 --- a/examples/crd-sync/syncers/car.go +++ b/examples/crd-sync/syncers/car.go @@ -38,12 +38,12 @@ func (s *carSyncer) Init(ctx *synccontext.RegisterContext) error { var _ synctypes.Syncer = &carSyncer{} -func (s *carSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.TranslateMetadata(ctx.Context, vObj).(*examplev1.Car)) +func (s *carSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.TranslateMetadata(ctx.Context, vObj).(*examplev1.Car)) } func (s *carSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownUpdate(ctx, vObj, s.translateUpdate(ctx.Context, pObj.(*examplev1.Car), vObj.(*examplev1.Car))) + return s.SyncToHostUpdate(ctx, vObj, s.translateUpdate(ctx.Context, pObj.(*examplev1.Car), vObj.(*examplev1.Car))) } func (s *carSyncer) translateUpdate(ctx context.Context, pObj, vObj *examplev1.Car) *examplev1.Car { diff --git a/examples/import-secrets/syncers/import_secrets.go b/examples/import-secrets/syncers/import_secrets.go index 4c70ff6c..eccfa8ed 100644 --- a/examples/import-secrets/syncers/import_secrets.go +++ b/examples/import-secrets/syncers/import_secrets.go @@ -40,7 +40,7 @@ func (s *importSecretSyncer) Resource() client.Object { var _ synctypes.UpSyncer = &importSecretSyncer{} -func (s *importSecretSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *importSecretSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { pSecret := pObj.(*corev1.Secret) // ignore Secrets synced to the host by the vcluster @@ -124,7 +124,7 @@ func (s *importSecretSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Obje return ctrl.Result{}, err } -func (s *importSecretSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *importSecretSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { // this is called when the secret in the host gets removed // or if the vObj is an unrelated Secret created in vcluster @@ -152,8 +152,8 @@ func (s *importSecretSyncer) IsManaged(ctx context.Context, pObj client.Object) return parseFromAnnotation(pObj.GetAnnotations(), pImportAnnotation).Name != "", nil } -// VirtualToPhysical translates a virtual name to a physical name -func (s *importSecretSyncer) VirtualToPhysical(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +// VirtualToHost translates a virtual name to a physical name +func (s *importSecretSyncer) VirtualToHost(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { if vObj == nil { return types.NamespacedName{} } @@ -167,8 +167,8 @@ func (s *importSecretSyncer) VirtualToPhysical(ctx context.Context, req types.Na return name } -// PhysicalToVirtual translates a physical name to a virtual name -func (s *importSecretSyncer) PhysicalToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { +// HostToVirtual translates a physical name to a virtual name +func (s *importSecretSyncer) HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { if pObj == nil { return types.NamespacedName{} } diff --git a/go.mod b/go.mod index 2ebc2cab..11ba3039 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/hashicorp/go-plugin v1.6.0 github.com/loft-sh/log v0.0.0-20230824104949-bd516c25712a - github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201075718-1f1fb0a70d6e + github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201171603-e3abc343e685 github.com/onsi/ginkgo/v2 v2.14.0 github.com/onsi/gomega v1.30.0 github.com/pkg/errors v0.9.1 @@ -98,7 +98,7 @@ require ( github.com/loft-sh/jspolicy v0.2.2 // indirect github.com/loft-sh/loftctl/v3 v3.4.0-beta.11 // indirect github.com/loft-sh/utils v0.0.29 // indirect - github.com/loft-sh/vcluster-values v0.0.0-20240131102942-9de6e2694279 // indirect + github.com/loft-sh/vcluster-values v0.0.0-20240131133548-d47237f9bcbe // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/go.sum b/go.sum index 18c06951..208d25c1 100644 --- a/go.sum +++ b/go.sum @@ -628,10 +628,10 @@ github.com/loft-sh/log v0.0.0-20230824104949-bd516c25712a h1:/gqqjKpcHEdFXIX41lx github.com/loft-sh/log v0.0.0-20230824104949-bd516c25712a/go.mod h1:YImeRjXH34Yf5E79T7UHBQpDZl9fIaaFRgyZ/bkY+UQ= github.com/loft-sh/utils v0.0.29 h1:P/MObccXToAZy2QoJSQDJ+OJx1qHitpFHEVj3QBSNJs= github.com/loft-sh/utils v0.0.29/go.mod h1:9hlX9cGpWHg3mNi/oBlv3X4ePGDMK66k8MbOZGFMDTI= -github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201075718-1f1fb0a70d6e h1:npJHpsXpIF1+ohPx3zE1vskuYIfE+4/gxpx2CuTgTow= -github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201075718-1f1fb0a70d6e/go.mod h1:yihiHNlFde+mw3mh6ghvc8sQum6Grf7reHhcrAzf8fM= -github.com/loft-sh/vcluster-values v0.0.0-20240131102942-9de6e2694279 h1:GCY9QS317jJIIsnfJ8ZoJ8axHRStIJ+fbsqOS+Fuy2o= -github.com/loft-sh/vcluster-values v0.0.0-20240131102942-9de6e2694279/go.mod h1:J34xtWyMbjM+NRgVWxO0IVDB5XYUaX52jPQNqEAhu4M= +github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201171603-e3abc343e685 h1:GhwDFggNqnVy/G96p5Cfi2yw9/WVrYA2YNs55CHWfRA= +github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201171603-e3abc343e685/go.mod h1:TS2klm4ta0hO5qiUbEUGQEZ06UBofgroSSOziY+P01E= +github.com/loft-sh/vcluster-values v0.0.0-20240131133548-d47237f9bcbe h1:F1jR+Gs8q2VH0MVVn5TFV8YuNvue/piLmg12zQlDYns= +github.com/loft-sh/vcluster-values v0.0.0-20240131133548-d47237f9bcbe/go.mod h1:J34xtWyMbjM+NRgVWxO0IVDB5XYUaX52jPQNqEAhu4M= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/disable.go b/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/disable.go index b2acc53d..bc076bee 100644 --- a/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/disable.go +++ b/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/disable.go @@ -25,7 +25,7 @@ func disable() *cobra.Command { Disables collection of anonymized vcluster telemetry. More information about the collected telmetry is in the -docs: https://www.vcluster.com/docs/telemetry +docs: https://www.vcluster.com/docs/advanced-topics/telemetry ####################################################### `, diff --git a/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/enable.go b/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/enable.go index 254ccdf9..aae938df 100644 --- a/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/enable.go +++ b/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/enable.go @@ -25,7 +25,7 @@ func enable() *cobra.Command { Enables collection of anonymized vcluster telemetry More information about the collected telmetry is in the -docs: https://www.vcluster.com/docs/telemetry +docs: https://www.vcluster.com/docs/advanced-topics/telemetry ####################################################### `, diff --git a/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/telemetry.go b/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/telemetry.go index 16af56e3..98350cef 100644 --- a/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/telemetry.go +++ b/vendor/github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/telemetry/telemetry.go @@ -16,7 +16,7 @@ Sets your vcluster telemetry preferences. Default: enabled. More information about the collected telmetry is in the -docs: https://www.vcluster.com/docs/telemetry +docs: https://www.vcluster.com/docs/advanced-topics/telemetry `, Args: cobra.NoArgs, } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/export_syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/export_syncer.go index c684b49e..cb167730 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/export_syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/export_syncer.go @@ -132,7 +132,7 @@ type exporter struct { name string } -func (f *exporter) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (f *exporter) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { // check if selector matches if !f.objectMatches(vObj) { return ctrl.Result{}, nil @@ -261,9 +261,9 @@ func (f *exporter) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj c return ctrl.Result{}, nil } -var _ syncertypes.UpSyncer = &exporter{} +var _ syncertypes.ToVirtualSyncer = &exporter{} -func (f *exporter) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (f *exporter) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { if !translate.Default.IsManaged(pObj) { return ctrl.Result{}, nil } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/import_syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/import_syncer.go index 6c76943c..e20de637 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/import_syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/generic/import_syncer.go @@ -177,9 +177,9 @@ func (s *importer) excludeObject(obj client.Object) bool { return false } -var _ syncertypes.UpSyncer = &importer{} +var _ syncertypes.ToVirtualSyncer = &importer{} -func (s *importer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *importer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { // check if annotation is already present if pObj.GetAnnotations() != nil { if pObj.GetAnnotations()[translate.ControllerLabel] == s.Name() && @@ -234,7 +234,7 @@ func (s *importer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctr var _ syncertypes.Syncer = &importer{} -func (s *importer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *importer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { // ignore all virtual resources that were not created by this controller if !s.IsVirtualManaged(vObj) { return ctrl.Result{}, nil @@ -354,11 +354,11 @@ func (s *importer) IsVirtualManaged(vObj client.Object) bool { return vObj.GetAnnotations() != nil && vObj.GetAnnotations()[translate.ControllerLabel] != "" && vObj.GetAnnotations()[translate.ControllerLabel] == s.Name() } -func (s *importer) VirtualToPhysical(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (s *importer) VirtualToHost(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { return types.NamespacedName{Name: translate.Default.PhysicalName(req.Name, req.Namespace), Namespace: translate.Default.PhysicalNamespace(req.Namespace)} } -func (s *importer) PhysicalToVirtual(ctx context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (s *importer) HostToVirtual(ctx context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { if s.syncerOptions.IsClusterScopedCRD { return types.NamespacedName{ Name: req.Name, @@ -382,7 +382,7 @@ func (s *importer) TranslateMetadata(ctx context.Context, pObj client.Object) cl vObj.SetOwnerReferences(nil) vObj.SetFinalizers(nil) vObj.SetAnnotations(s.updateVirtualAnnotations(vObj.GetAnnotations())) - nn := s.PhysicalToVirtual(ctx, types.NamespacedName{Name: pObj.GetName(), Namespace: pObj.GetNamespace()}, pObj) + nn := s.HostToVirtual(ctx, types.NamespacedName{Name: pObj.GetName(), Namespace: pObj.GetNamespace()}, pObj) vObj.SetName(nn.Name) vObj.SetNamespace(nn.Namespace) diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/configmaps/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/configmaps/syncer.go index 73523499..ae71c0e2 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/configmaps/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/configmaps/syncer.go @@ -66,7 +66,7 @@ func (s *configMapSyncer) ModifyController(_ *synccontext.RegisterContext, build return builder.Watches(&corev1.Pod{}, handler.EnqueueRequestsFromMapFunc(mapPods)), nil } -func (s *configMapSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *configMapSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { createNeeded, err := s.isConfigMapUsed(ctx, vObj) if err != nil { return ctrl.Result{}, err @@ -74,7 +74,7 @@ func (s *configMapSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Obj return ctrl.Result{}, nil } - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.ConfigMap))) + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.ConfigMap))) } func (s *configMapSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -99,7 +99,7 @@ func (s *configMapSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, } // did the configmap change? - return s.SyncDownUpdate(ctx, vObj, newConfigMap) + return s.SyncToHostUpdate(ctx, vObj, newConfigMap) } func (s *configMapSyncer) isConfigMapUsed(ctx *synccontext.SyncContext, vObj runtime.Object) (bool, error) { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csidrivers/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csidrivers/syncer.go index 8058bd76..4ddd570a 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csidrivers/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csidrivers/syncer.go @@ -19,10 +19,10 @@ type csidriverSyncer struct { translator.Translator } -var _ syncer.UpSyncer = &csidriverSyncer{} +var _ syncer.ToVirtualSyncer = &csidriverSyncer{} var _ syncer.Syncer = &csidriverSyncer{} -func (s *csidriverSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *csidriverSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { vObj := s.translateBackwards(ctx.Context, pObj.(*storagev1.CSIDriver)) ctx.Log.Infof("create CSIDriver %s, because it does not exist in virtual cluster", vObj.Name) return ctrl.Result{}, ctx.VirtualClient.Create(ctx.Context, vObj) @@ -40,7 +40,7 @@ func (s *csidriverSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, return ctrl.Result{}, nil } -func (s *csidriverSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *csidriverSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { ctx.Log.Infof("delete virtual CSIDriver %s, because physical object is missing", vObj.GetName()) return ctrl.Result{}, ctx.VirtualClient.Delete(ctx.Context, vObj) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csinodes/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csinodes/syncer.go index d35e06c9..111f06d1 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csinodes/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csinodes/syncer.go @@ -24,10 +24,10 @@ type csinodeSyncer struct { virtualClient client.Client } -var _ syncertypes.UpSyncer = &csinodeSyncer{} +var _ syncertypes.ToVirtualSyncer = &csinodeSyncer{} var _ syncertypes.Syncer = &csinodeSyncer{} -func (s *csinodeSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *csinodeSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { // look up matching node name, don't sync if not found node := &corev1.Node{} err := s.virtualClient.Get(ctx.Context, types.NamespacedName{Name: pObj.GetName()}, node) @@ -62,7 +62,7 @@ func (s *csinodeSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, v return ctrl.Result{}, nil } -func (s *csinodeSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *csinodeSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { ctx.Log.Infof("delete virtual CSINode %s, because physical object is missing", vObj.GetName()) return ctrl.Result{}, ctx.VirtualClient.Delete(ctx.Context, vObj) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/syncer.go index 335d81b4..6255b66b 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/syncer.go @@ -34,10 +34,10 @@ type csistoragecapacitySyncer struct { physicalClient client.Client } -var _ syncertypes.UpSyncer = &csistoragecapacitySyncer{} +var _ syncertypes.ToVirtualSyncer = &csistoragecapacitySyncer{} var _ syncertypes.Syncer = &csistoragecapacitySyncer{} -func (s *csistoragecapacitySyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *csistoragecapacitySyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { vObj, shouldSkip, err := s.translateBackwards(ctx, pObj.(*storagev1.CSIStorageCapacity)) if err != nil || shouldSkip { return ctrl.Result{}, err @@ -67,7 +67,7 @@ func (s *csistoragecapacitySyncer) Sync(ctx *synccontext.SyncContext, pObj clien return ctrl.Result{}, nil } -func (s *csistoragecapacitySyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *csistoragecapacitySyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { ctx.Log.Infof("delete virtual CSIStorageCapacity %s, because physical object is missing", vObj.GetName()) return ctrl.Result{}, ctx.VirtualClient.Delete(ctx.Context, vObj) } @@ -109,7 +109,7 @@ func (s *csistoragecapacitySyncer) enqueuePhysical(ctx context.Context, obj clie return } - name := s.PhysicalToVirtual(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, obj) + name := s.HostToVirtual(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, obj) if name.Name != "" && name.Namespace != "" { q.Add(reconcile.Request{NamespacedName: name}) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/translator.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/translator.go index 02c4844a..8ab343cd 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/translator.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/csistoragecapacities/translator.go @@ -31,15 +31,15 @@ func (s *csistoragecapacitySyncer) IsManaged(context.Context, client.Object) (bo func (s *csistoragecapacitySyncer) RegisterIndices(ctx *synccontext.RegisterContext) error { return ctx.PhysicalManager.GetFieldIndexer().IndexField(ctx.Context, &storagev1.CSIStorageCapacity{}, constants.IndexByVirtualName, func(rawObj client.Object) []string { - return []string{s.PhysicalToVirtual(ctx.Context, types.NamespacedName{Name: rawObj.GetName(), Namespace: rawObj.GetNamespace()}, rawObj).Name} + return []string{s.HostToVirtual(ctx.Context, types.NamespacedName{Name: rawObj.GetName(), Namespace: rawObj.GetNamespace()}, rawObj).Name} }) } // translate namespace -func (s *csistoragecapacitySyncer) PhysicalToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (s *csistoragecapacitySyncer) HostToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { return types.NamespacedName{Name: translate.SafeConcatName(req.Name, "x", req.Namespace), Namespace: "kube-system"} } -func (s *csistoragecapacitySyncer) VirtualToPhysical(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +func (s *csistoragecapacitySyncer) VirtualToHost(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { // if the virtual object is annotated with the physical name and namespace, return that if vObj != nil { vAnnotations := vObj.GetAnnotations() @@ -66,7 +66,7 @@ func (s *csistoragecapacitySyncer) VirtualToPhysical(ctx context.Context, req ty // TranslateMetadata translates the object's metadata func (s *csistoragecapacitySyncer) TranslateMetadata(ctx context.Context, pObj client.Object) (client.Object, error) { - name := s.PhysicalToVirtual(ctx, types.NamespacedName{Name: pObj.GetName(), Namespace: pObj.GetNamespace()}, pObj) + name := s.HostToVirtual(ctx, types.NamespacedName{Name: pObj.GetName(), Namespace: pObj.GetNamespace()}, pObj) pObjCopy := pObj.DeepCopyObject() vObj, ok := pObjCopy.(client.Object) if !ok { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/endpoints/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/endpoints/syncer.go index 1062d967..0856d909 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/endpoints/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/endpoints/syncer.go @@ -24,8 +24,8 @@ type endpointsSyncer struct { translator.NamespacedTranslator } -func (s *endpointsSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj)) +func (s *endpointsSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj)) } func (s *endpointsSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -34,7 +34,7 @@ func (s *endpointsSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, translator.PrintChanges(pObj, newEndpoints, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newEndpoints) + return s.SyncToHostUpdate(ctx, vObj, newEndpoints) } var _ syncer.Starter = &endpointsSyncer{} @@ -60,7 +60,7 @@ func (s *endpointsSyncer) ReconcileStart(ctx *synccontext.SyncContext, req ctrl. } else if svc.Spec.Selector != nil { // check if it was a managed endpoints object before and delete it endpoints := &corev1.Endpoints{} - err := ctx.PhysicalClient.Get(ctx.Context, s.NamespacedTranslator.VirtualToPhysical(ctx.Context, req.NamespacedName, nil), endpoints) + err := ctx.PhysicalClient.Get(ctx.Context, s.NamespacedTranslator.VirtualToHost(ctx.Context, req.NamespacedName, nil), endpoints) if err != nil { if !kerrors.IsNotFound(err) { klog.Infof("Error retrieving endpoints: %v", err) diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/events/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/events/syncer.go index daf627db..60efc5f1 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/events/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/events/syncer.go @@ -2,22 +2,23 @@ package events import ( "context" + "fmt" "strings" - "github.com/loft-sh/vcluster/pkg/util/translate" - "k8s.io/apimachinery/pkg/api/equality" - + "github.com/loft-sh/vcluster/pkg/constants" synccontext "github.com/loft-sh/vcluster/pkg/controllers/syncer/context" "github.com/loft-sh/vcluster/pkg/controllers/syncer/translator" syncer "github.com/loft-sh/vcluster/pkg/types" - - "github.com/loft-sh/vcluster/pkg/constants" "github.com/loft-sh/vcluster/pkg/util/clienthelper" + "github.com/loft-sh/vcluster/pkg/util/translate" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" kerrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" + "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -33,11 +34,13 @@ var AcceptedKinds = map[schema.GroupVersionKind]bool{ func New(ctx *synccontext.RegisterContext) (syncer.Object, error) { return &eventSyncer{ virtualClient: ctx.VirtualManager.GetClient(), + hostClient: ctx.PhysicalManager.GetClient(), }, nil } type eventSyncer struct { virtualClient client.Client + hostClient client.Client } func (s *eventSyncer) Resource() client.Object { @@ -48,81 +51,107 @@ func (s *eventSyncer) Name() string { return "event" } -func (s *eventSyncer) IsManaged(context.Context, client.Object) (bool, error) { - return true, nil +func (s *eventSyncer) IsManaged(ctx context.Context, pObj client.Object) (bool, error) { + return s.HostToVirtual(ctx, types.NamespacedName{Namespace: pObj.GetNamespace(), Name: pObj.GetName()}, pObj).Name != "", nil } -func (s *eventSyncer) VirtualToPhysical(context.Context, types.NamespacedName, client.Object) types.NamespacedName { +func (s *eventSyncer) VirtualToHost(context.Context, types.NamespacedName, client.Object) types.NamespacedName { + // we ignore virtual events here, we only react on host events and sync them to the virtual cluster return types.NamespacedName{} } -func (s *eventSyncer) PhysicalToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { - return req +func (s *eventSyncer) HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { + involvedObject, err := s.getInvolvedObject(ctx, pObj) + if err != nil { + klog.Infof("Error retrieving involved object for %s/%s: %v", req.Namespace, req.Name, err) + return types.NamespacedName{} + } else if involvedObject == nil { + return types.NamespacedName{} + } + + return types.NamespacedName{ + Namespace: involvedObject.GetNamespace(), + Name: req.Name, + } } -var _ syncer.Starter = &eventSyncer{} +var _ syncer.Syncer = &eventSyncer{} -func (s *eventSyncer) ReconcileStart(ctx *synccontext.SyncContext, req ctrl.Request) (bool, error) { - return true, s.reconcile(ctx, req) // true will tell the syncer to return after this reconcile +func (s *eventSyncer) SyncToHost(_ *synccontext.SyncContext, _ client.Object) (ctrl.Result, error) { + // this should never happen since we ignore virtual events and don't handle objects we can't find + panic("unimplemented") } -func (s *eventSyncer) reconcile(ctx *synccontext.SyncContext, req ctrl.Request) error { - pObj := s.Resource() - err := ctx.PhysicalClient.Get(ctx.Context, req.NamespacedName, pObj) - if err != nil { - if !kerrors.IsNotFound(err) && !strings.Contains(err.Error(), "because of unknown namespace for the cache") { - return err - } +func (s *eventSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { + // convert current events + pEvent := pObj.(*corev1.Event) + vEvent := vObj.(*corev1.Event) - return nil + // update event + vOldEvent := vEvent.DeepCopy() + vEvent, err := s.buildVirtualEvent(ctx.Context, pEvent) + if err != nil { + return ctrl.Result{}, err + } else if vEvent == nil { + return ctrl.Result{}, nil } - pEvent, ok := pObj.(*corev1.Event) - if !ok { - return nil - } + // reset metadata + vEvent.TypeMeta = vOldEvent.TypeMeta + vEvent.ObjectMeta = vOldEvent.ObjectMeta - // check if the involved object is accepted - gvk := pEvent.InvolvedObject.GroupVersionKind() - if !AcceptedKinds[gvk] { - return nil + // update existing event only if changed + if equality.Semantic.DeepEqual(vEvent, vOldEvent) { + return ctrl.Result{}, nil } - vInvolvedObj, err := ctx.VirtualClient.Scheme().New(gvk) + // check if updated + ctx.Log.Infof("update virtual event %s/%s", vEvent.Namespace, vEvent.Name) + translator.PrintChanges(vOldEvent, vEvent, ctx.Log) + err = ctx.VirtualClient.Update(ctx.Context, vEvent) if err != nil { - return err + return ctrl.Result{}, err } - index := "" - switch pEvent.InvolvedObject.Kind { - case "Pod": - index = constants.IndexByPhysicalName - case "Service": - index = constants.IndexByPhysicalName - case "Endpoint": - index = constants.IndexByPhysicalName - case "Secret": - index = constants.IndexByPhysicalName - case "ConfigMap": - index = constants.IndexByPhysicalName - default: - return nil + return ctrl.Result{}, nil +} + +var _ syncer.ToVirtualSyncer = &eventSyncer{} + +func (s *eventSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { + // build the virtual event + vObj, err := s.buildVirtualEvent(ctx.Context, pObj.(*corev1.Event)) + if err != nil { + return ctrl.Result{}, err + } else if vObj == nil { + return ctrl.Result{}, nil } - // get involved object - err = clienthelper.GetByIndex(ctx.Context, ctx.VirtualClient, vInvolvedObj, index, pEvent.Namespace+"/"+pEvent.InvolvedObject.Name) + // make sure namespace is not being deleted + namespace := &corev1.Namespace{} + err = ctx.VirtualClient.Get(ctx.Context, client.ObjectKey{Name: vObj.Namespace}, namespace) if err != nil { if kerrors.IsNotFound(err) { - return nil + return ctrl.Result{}, nil } - return err + return ctrl.Result{}, err + } else if namespace.DeletionTimestamp != nil { + // cannot create events in terminating namespaces + return ctrl.Result{}, nil } - // we found the related object - m, err := meta.Accessor(vInvolvedObj) + ctx.Log.Infof("create virtual event %s/%s", vObj.Namespace, vObj.Name) + return ctrl.Result{}, ctx.VirtualClient.Create(ctx.Context, vObj) +} + +func (s *eventSyncer) buildVirtualEvent(ctx context.Context, pEvent *corev1.Event) (*corev1.Event, error) { + // retrieve involved object + involvedObject, err := s.getInvolvedObject(ctx, pEvent) if err != nil { - return err + return nil, err + } else if involvedObject == nil { + return nil, nil } // copy physical object @@ -130,11 +159,11 @@ func (s *eventSyncer) reconcile(ctx *synccontext.SyncContext, req ctrl.Request) translate.ResetObjectMetadata(vObj) // set the correct involved object meta - vObj.Namespace = m.GetNamespace() - vObj.InvolvedObject.Namespace = m.GetNamespace() - vObj.InvolvedObject.Name = m.GetName() - vObj.InvolvedObject.UID = m.GetUID() - vObj.InvolvedObject.ResourceVersion = m.GetResourceVersion() + vObj.Namespace = involvedObject.GetNamespace() + vObj.InvolvedObject.Namespace = involvedObject.GetNamespace() + vObj.InvolvedObject.Name = involvedObject.GetName() + vObj.InvolvedObject.UID = involvedObject.GetUID() + vObj.InvolvedObject.ResourceVersion = involvedObject.GetResourceVersion() // replace name of object if strings.HasPrefix(vObj.Name, pEvent.InvolvedObject.Name) { @@ -144,59 +173,53 @@ func (s *eventSyncer) reconcile(ctx *synccontext.SyncContext, req ctrl.Request) // we replace namespace/name & name in messages so that it seems correct vObj.Message = strings.ReplaceAll(vObj.Message, pEvent.InvolvedObject.Namespace+"/"+pEvent.InvolvedObject.Name, vObj.InvolvedObject.Namespace+"/"+vObj.InvolvedObject.Name) vObj.Message = strings.ReplaceAll(vObj.Message, pEvent.InvolvedObject.Name, vObj.InvolvedObject.Name) + return vObj, nil +} - // make sure namespace is not being deleted - namespace := &corev1.Namespace{} - err = ctx.VirtualClient.Get(ctx.Context, client.ObjectKey{Name: vObj.Namespace}, namespace) +func (s *eventSyncer) getInvolvedObject(ctx context.Context, pObj client.Object) (metav1.Object, error) { + if pObj == nil { + return nil, nil + } + + pEvent, ok := pObj.(*corev1.Event) + if !ok { + return nil, fmt.Errorf("object is not of type event") + } + + // check if the involved object is accepted + gvk := pEvent.InvolvedObject.GroupVersionKind() + if !AcceptedKinds[gvk] { + return nil, nil + } + + vInvolvedObj, err := s.virtualClient.Scheme().New(gvk) if err != nil { - if kerrors.IsNotFound(err) { - return nil - } + return nil, err + } - return err - } else if namespace.DeletionTimestamp != nil { - // cannot create events in terminating namespaces - return nil + index := "" + switch pEvent.InvolvedObject.Kind { + case "Pod", "Service", "Endpoint", "Secret", "ConfigMap": + index = constants.IndexByPhysicalName + default: + return nil, nil } - // check if there is such an event already - vOldObj := &corev1.Event{} - err = ctx.VirtualClient.Get(ctx.Context, types.NamespacedName{ - Namespace: vObj.Namespace, - Name: vObj.Name, - }, vOldObj) + // get involved object + err = clienthelper.GetByIndex(ctx, s.virtualClient, vInvolvedObj, index, pEvent.Namespace+"/"+pEvent.InvolvedObject.Name) if err != nil { if !kerrors.IsNotFound(err) { - return err + return nil, err } - ctx.Log.Infof("create virtual event %s/%s", vObj.Namespace, vObj.Name) - return ctx.VirtualClient.Create(ctx.Context, vObj) + return nil, nil } - // copy metadata - vObj.ObjectMeta = *vOldObj.ObjectMeta.DeepCopy() - - // update existing event only if changed - if equality.Semantic.DeepEqual(vObj, vOldObj) { - return nil + // we found the related object + m, err := meta.Accessor(vInvolvedObj) + if err != nil { + return nil, err } - ctx.Log.Infof("update virtual event %s/%s", vObj.Namespace, vObj.Name) - translator.PrintChanges(vOldObj, vObj, ctx.Log) - return ctx.VirtualClient.Update(ctx.Context, vObj) -} - -var _ syncer.Syncer = &eventSyncer{} - -func (s *eventSyncer) SyncDown(*synccontext.SyncContext, client.Object) (ctrl.Result, error) { - // Noop, we do nothing here - return ctrl.Result{}, nil + return m, nil } - -func (s *eventSyncer) Sync(*synccontext.SyncContext, client.Object, client.Object) (ctrl.Result, error) { - // Noop, we do nothing here - return ctrl.Result{}, nil -} - -func (s *eventSyncer) ReconcileEnd() {} diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingressclasses/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingressclasses/syncer.go index e9a45394..2804027d 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingressclasses/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingressclasses/syncer.go @@ -19,10 +19,10 @@ type ingressClassSyncer struct { translator.Translator } -var _ syncer.UpSyncer = &ingressClassSyncer{} +var _ syncer.ToVirtualSyncer = &ingressClassSyncer{} var _ syncer.Syncer = &ingressClassSyncer{} -func (i *ingressClassSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (i *ingressClassSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { vObj := i.translateBackwards(ctx.Context, pObj.(*networkingv1.IngressClass)) ctx.Log.Infof("create ingress class %s, because it does not exist in virtual cluster", vObj.Name) return ctrl.Result{}, ctx.VirtualClient.Create(ctx.Context, vObj) @@ -39,7 +39,7 @@ func (i *ingressClassSyncer) Sync(ctx *synccontext.SyncContext, pObj, vObj clien return ctrl.Result{}, nil } -func (i *ingressClassSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (i *ingressClassSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { ctx.Log.Infof("delete virtual ingress class %s, because physical object is missing", vObj.GetName()) return ctrl.Result{}, ctx.VirtualClient.Delete(ctx.Context, vObj) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/legacy/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/legacy/syncer.go index 7e81a09b..e3a04ba2 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/legacy/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/legacy/syncer.go @@ -23,8 +23,8 @@ type ingressSyncer struct { var _ syncertypes.Syncer = &ingressSyncer{} -func (s *ingressSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*networkingv1beta1.Ingress))) +func (s *ingressSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*networkingv1beta1.Ingress))) } func (s *ingressSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -63,7 +63,7 @@ func (s *ingressSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, v translator.PrintChanges(pObj, newIngress, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newIngress) + return s.SyncToHostUpdate(ctx, vObj, newIngress) } func SecretNamesFromIngress(ingress *networkingv1beta1.Ingress) []string { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/syncer.go index 8cf8cc5e..6add8635 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/ingresses/syncer.go @@ -25,8 +25,8 @@ type ingressSyncer struct { var _ syncertypes.Syncer = &ingressSyncer{} -func (s *ingressSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*networkingv1.Ingress))) +func (s *ingressSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*networkingv1.Ingress))) } func (s *ingressSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -65,7 +65,7 @@ func (s *ingressSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, v translator.PrintChanges(pObj, newIngress, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newIngress) + return s.SyncToHostUpdate(ctx, vObj, newIngress) } func SecretNamesFromIngress(ingress *networkingv1.Ingress) []string { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/namespaces/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/namespaces/syncer.go index 34c67f1b..c38f8fa3 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/namespaces/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/namespaces/syncer.go @@ -62,7 +62,7 @@ func (s *namespaceSyncer) RegisterIndices(ctx *synccontext.RegisterContext) erro var _ syncertypes.Syncer = &namespaceSyncer{} -func (s *namespaceSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *namespaceSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { newNamespace := s.translate(ctx.Context, vObj.(*corev1.Namespace)) ctx.Log.Infof("create physical namespace %s", newNamespace.Name) err := ctx.PhysicalClient.Create(ctx.Context, newNamespace) diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/networkpolicies/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/networkpolicies/syncer.go index a3899844..ed614d2d 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/networkpolicies/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/networkpolicies/syncer.go @@ -22,8 +22,8 @@ type networkPolicySyncer struct { var _ syncertypes.Syncer = &networkPolicySyncer{} -func (s *networkPolicySyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*networkingv1.NetworkPolicy))) +func (s *networkPolicySyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*networkingv1.NetworkPolicy))) } func (s *networkPolicySyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -32,5 +32,5 @@ func (s *networkPolicySyncer) Sync(ctx *synccontext.SyncContext, pObj client.Obj translator.PrintChanges(pObj, newNetworkPolicy, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newNetworkPolicy) + return s.SyncToHostUpdate(ctx, vObj, newNetworkPolicy) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/fake_syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/fake_syncer.go index 38cb6c33..8ee8321f 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/fake_syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/fake_syncer.go @@ -65,7 +65,7 @@ func (r *fakeNodeSyncer) ModifyController(ctx *synccontext.RegisterContext, buil var _ syncer.FakeSyncer = &fakeNodeSyncer{} -func (r *fakeNodeSyncer) FakeSyncUp(ctx *synccontext.SyncContext, name types.NamespacedName) (ctrl.Result, error) { +func (r *fakeNodeSyncer) FakeSyncToVirtual(ctx *synccontext.SyncContext, name types.NamespacedName) (ctrl.Result, error) { needed, err := r.nodeNeeded(ctx, name.Name) if err != nil { return ctrl.Result{}, err diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/syncer.go index fd882c9f..63fecd7e 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/nodes/syncer.go @@ -251,11 +251,11 @@ func registerIndices(ctx *synccontext.RegisterContext) error { }) } -func (s *nodeSyncer) VirtualToPhysical(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (s *nodeSyncer) VirtualToHost(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { return req } -func (s *nodeSyncer) PhysicalToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (s *nodeSyncer) HostToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { return types.NamespacedName{Name: req.Name} } @@ -270,7 +270,7 @@ func (s *nodeSyncer) IsManaged(ctx context.Context, pObj client.Object) (bool, e var _ syncertypes.Syncer = &nodeSyncer{} -func (s *nodeSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *nodeSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { vNode := vObj.(*corev1.Node) ctx.Log.Infof("delete virtual node %s, because it is not needed anymore", vNode.Name) return ctrl.Result{}, ctx.VirtualClient.Delete(ctx.Context, vObj) @@ -314,9 +314,9 @@ func (s *nodeSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj return ctrl.Result{}, nil } -var _ syncertypes.UpSyncer = &nodeSyncer{} +var _ syncertypes.ToVirtualSyncer = &nodeSyncer{} -func (s *nodeSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *nodeSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { pNode := pObj.(*corev1.Node) shouldSync, err := s.shouldSync(ctx.Context, pNode) if err != nil { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumeclaims/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumeclaims/syncer.go index e2a28f29..e64bf534 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumeclaims/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumeclaims/syncer.go @@ -62,7 +62,7 @@ func (s *persistentVolumeClaimSyncer) WithOptions() *syncer.Options { var _ syncer.Syncer = &persistentVolumeClaimSyncer{} -func (s *persistentVolumeClaimSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *persistentVolumeClaimSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { vPvc := vObj.(*corev1.PersistentVolumeClaim) if vPvc.DeletionTimestamp != nil { // delete pvc immediately @@ -82,7 +82,7 @@ func (s *persistentVolumeClaimSyncer) SyncDown(ctx *synccontext.SyncContext, vOb return ctrl.Result{}, err } - return s.SyncDownCreate(ctx, vObj, newPvc) + return s.SyncToHostCreate(ctx, vObj, newPvc) } func (s *persistentVolumeClaimSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -163,7 +163,7 @@ func (s *persistentVolumeClaimSyncer) Sync(ctx *synccontext.SyncContext, pObj cl translator.PrintChanges(pPvc, newPvc, ctx.Log) } - return s.SyncDownUpdate(ctx, vPvc, newPvc) + return s.SyncToHostUpdate(ctx, vPvc, newPvc) } func (s *persistentVolumeClaimSyncer) ensurePersistentVolume(ctx *synccontext.SyncContext, pObj *corev1.PersistentVolumeClaim, vObj *corev1.PersistentVolumeClaim, log loghelper.Logger) (bool, error) { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/fake_syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/fake_syncer.go index 9d269ddc..6b12d7e0 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/fake_syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/fake_syncer.go @@ -63,7 +63,7 @@ func (r *fakePersistentVolumeSyncer) ModifyController(_ *synccontext.RegisterCon var _ syncer.FakeSyncer = &fakePersistentVolumeSyncer{} -func (r *fakePersistentVolumeSyncer) FakeSyncUp(ctx *synccontext.SyncContext, req types.NamespacedName) (ctrl.Result, error) { +func (r *fakePersistentVolumeSyncer) FakeSyncToVirtual(ctx *synccontext.SyncContext, req types.NamespacedName) (ctrl.Result, error) { needed, err := r.pvNeeded(ctx, req.Name) if err != nil { return ctrl.Result{}, err diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/syncer.go index 0c80062a..db2c2d77 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/persistentvolumes/syncer.go @@ -85,7 +85,7 @@ func (s *persistentVolumeSyncer) ModifyController(_ *synccontext.RegisterContext var _ syncertypes.Syncer = &persistentVolumeSyncer{} -func (s *persistentVolumeSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *persistentVolumeSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { vPv := vObj.(*corev1.PersistentVolume) if vPv.DeletionTimestamp != nil || (vPv.Annotations != nil && vPv.Annotations[HostClusterPersistentVolumeAnnotation] != "") { if len(vPv.Finalizers) > 0 { @@ -217,9 +217,9 @@ func (s *persistentVolumeSyncer) WithOptions() *syncertypes.Options { return &syncertypes.Options{DisableUIDDeletion: true} } -var _ syncertypes.UpSyncer = &persistentVolumeSyncer{} +var _ syncertypes.ToVirtualSyncer = &persistentVolumeSyncer{} -func (s *persistentVolumeSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *persistentVolumeSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { pPersistentVolume := pObj.(*corev1.PersistentVolume) sync, vPvc, err := s.shouldSync(ctx.Context, pPersistentVolume) if err != nil { @@ -283,11 +283,11 @@ func (s *persistentVolumeSyncer) IsManaged(ctx context.Context, pObj client.Obje return sync, nil } -func (s *persistentVolumeSyncer) VirtualToPhysical(_ context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +func (s *persistentVolumeSyncer) VirtualToHost(_ context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { return types.NamespacedName{Name: translatePersistentVolumeName(req.Name, vObj)} } -func (s *persistentVolumeSyncer) PhysicalToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { +func (s *persistentVolumeSyncer) HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { if pObj != nil { pAnnotations := pObj.GetAnnotations() if pAnnotations != nil && pAnnotations[translate.NameAnnotation] != "" { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/poddisruptionbudgets/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/poddisruptionbudgets/syncer.go index 552ad543..39e18852 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/poddisruptionbudgets/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/poddisruptionbudgets/syncer.go @@ -19,8 +19,8 @@ type pdbSyncer struct { translator.NamespacedTranslator } -func (pdb *pdbSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return pdb.SyncDownCreate(ctx, vObj, pdb.translate(ctx.Context, vObj.(*policyv1.PodDisruptionBudget))) +func (pdb *pdbSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return pdb.SyncToHostCreate(ctx, vObj, pdb.translate(ctx.Context, vObj.(*policyv1.PodDisruptionBudget))) } func (pdb *pdbSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -31,5 +31,5 @@ func (pdb *pdbSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vOb translator.PrintChanges(pObj, newPDB, ctx.Log) } - return pdb.SyncDownUpdate(ctx, vObj, newPDB) + return pdb.SyncToHostUpdate(ctx, vObj, newPDB) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/pods/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/pods/syncer.go index 5232248f..79ac2b88 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/pods/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/pods/syncer.go @@ -151,7 +151,7 @@ func (s *podSyncer) ModifyController(ctx *synccontext.RegisterContext, builder * var _ syncer.Syncer = &podSyncer{} -func (s *podSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *podSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { vPod := vObj.(*corev1.Pod) // in some scenarios it is possible that the pod was already started and the physical pod // was deleted without vcluster's knowledge. In this case we are deleting the virtual pod @@ -220,7 +220,7 @@ func (s *podSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) ( return ctrl.Result{}, nil } - return s.SyncDownCreate(ctx, vPod, pPod) + return s.SyncToHostCreate(ctx, vPod, pPod) } func (s *podSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -348,7 +348,7 @@ func (s *podSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj translator.PrintChanges(pPod, updatedPod, ctx.Log) } - return s.SyncDownUpdate(ctx, vPod, updatedPod) + return s.SyncToHostUpdate(ctx, vPod, updatedPod) } func syncEphemeralContainers(vPod *corev1.Pod, pPod *corev1.Pod) bool { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/priorityclasses/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/priorityclasses/syncer.go index fc9404c4..bcb73eca 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/priorityclasses/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/priorityclasses/syncer.go @@ -31,7 +31,7 @@ func (s *priorityClassSyncer) RegisterIndices(ctx *synccontext.RegisterContext) var _ syncer.Syncer = &priorityClassSyncer{} -func (s *priorityClassSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *priorityClassSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { newPriorityClass := s.translate(ctx.Context, vObj.(*schedulingv1.PriorityClass)) ctx.Log.Infof("create physical priority class %s", newPriorityClass.Name) err := ctx.PhysicalClient.Create(ctx.Context, newPriorityClass) diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/secrets/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/secrets/syncer.go index 54aaf9da..2c8bdf57 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/secrets/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/secrets/syncer.go @@ -100,7 +100,7 @@ func (s *secretSyncer) ModifyController(_ *synccontext.RegisterContext, builder return builder.Watches(&corev1.Pod{}, handler.EnqueueRequestsFromMapFunc(mapPods)), nil } -func (s *secretSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *secretSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { createNeeded, err := s.isSecretUsed(ctx, vObj) if err != nil { return ctrl.Result{}, err @@ -108,7 +108,7 @@ func (s *secretSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object return ctrl.Result{}, nil } - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.Secret))) + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.Secret))) } func (s *secretSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -132,7 +132,7 @@ func (s *secretSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vO translator.PrintChanges(pObj, newSecret, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newSecret) + return s.SyncToHostUpdate(ctx, vObj, newSecret) } func (s *secretSyncer) isSecretUsed(ctx *synccontext.SyncContext, vObj runtime.Object) (bool, error) { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/serviceaccounts/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/serviceaccounts/syncer.go index 5f3dcbc0..e34a0615 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/serviceaccounts/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/serviceaccounts/syncer.go @@ -20,8 +20,8 @@ type serviceAccountSyncer struct { translator.NamespacedTranslator } -func (s *serviceAccountSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.ServiceAccount))) +func (s *serviceAccountSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.ServiceAccount))) } func (s *serviceAccountSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -31,5 +31,5 @@ func (s *serviceAccountSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Ob translator.PrintChanges(pObj, newServiceAccount, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newServiceAccount) + return s.SyncToHostUpdate(ctx, vObj, newServiceAccount) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/services/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/services/syncer.go index 986f24c2..e0148196 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/services/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/services/syncer.go @@ -44,8 +44,8 @@ func (s *serviceSyncer) WithOptions() *syncertypes.Options { return &syncertypes.Options{DisableUIDDeletion: true} } -func (s *serviceSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { - return s.SyncDownCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.Service))) +func (s *serviceSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { + return s.SyncToHostCreate(ctx, vObj, s.translate(ctx.Context, vObj.(*corev1.Service))) } func (s *serviceSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -103,16 +103,16 @@ func (s *serviceSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, v translator.PrintChanges(pService, newService, ctx.Log) } - return s.SyncDownUpdate(ctx, vObj, newService) + return s.SyncToHostUpdate(ctx, vObj, newService) } func isSwitchingFromExternalName(pService *corev1.Service, vService *corev1.Service) bool { return vService.Spec.Type == corev1.ServiceTypeExternalName && pService.Spec.Type != vService.Spec.Type && pService.Spec.ClusterIP != "" } -var _ syncertypes.UpSyncer = &serviceSyncer{} +var _ syncertypes.ToVirtualSyncer = &serviceSyncer{} -func (s *serviceSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *serviceSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { if !translate.Default.IsManaged(pObj) { return ctrl.Result{}, nil } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/host_sc_syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/host_sc_syncer.go index 4e36edaa..1970488b 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/host_sc_syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/host_sc_syncer.go @@ -19,9 +19,9 @@ type hostStorageClassSyncer struct { translator.Translator } -var _ syncer.UpSyncer = &hostStorageClassSyncer{} +var _ syncer.ToVirtualSyncer = &hostStorageClassSyncer{} -func (s *hostStorageClassSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *hostStorageClassSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { vObj := s.translateBackwards(ctx.Context, pObj.(*storagev1.StorageClass)) ctx.Log.Infof("create storage class %s, because it does not exist in virtual cluster", vObj.Name) return ctrl.Result{}, ctx.VirtualClient.Create(ctx.Context, vObj) @@ -41,7 +41,7 @@ func (s *hostStorageClassSyncer) Sync(ctx *synccontext.SyncContext, pObj client. return ctrl.Result{}, nil } -func (s *hostStorageClassSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *hostStorageClassSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { ctx.Log.Infof("delete virtual storage class %s, because physical object is missing", vObj.GetName()) return ctrl.Result{}, ctx.VirtualClient.Delete(ctx.Context, vObj) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/syncer.go index 04b5b469..e06e9f3d 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/storageclasses/syncer.go @@ -50,7 +50,7 @@ func (s *storageClassSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Obje return ctrl.Result{}, nil } -func (s *storageClassSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *storageClassSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { newStorageClass := s.translate(ctx.Context, vObj.(*storagev1.StorageClass)) ctx.Log.Infof("create physical storage class %s", newStorageClass.Name) err := ctx.PhysicalClient.Create(ctx.Context, newStorageClass) diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotclasses/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotclasses/syncer.go index 41862907..69f04baf 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotclasses/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotclasses/syncer.go @@ -27,9 +27,9 @@ func (s *volumeSnapshotClassSyncer) Init(registerContext *synccontext.RegisterCo return util.EnsureCRD(registerContext.Context, registerContext.VirtualManager.GetConfig(), []byte(volumeSnapshotClassesCRD), volumesnapshotv1.SchemeGroupVersion.WithKind("VolumeSnapshotClass")) } -var _ syncer.UpSyncer = &volumeSnapshotClassSyncer{} +var _ syncer.ToVirtualSyncer = &volumeSnapshotClassSyncer{} -func (s *volumeSnapshotClassSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *volumeSnapshotClassSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { pVolumeSnapshotClass := pObj.(*volumesnapshotv1.VolumeSnapshotClass) vObj := s.translateBackwards(ctx.Context, pVolumeSnapshotClass) ctx.Log.Infof("create VolumeSnapshotClass %s, because it does not exist in the virtual cluster", vObj.Name) @@ -38,7 +38,7 @@ func (s *volumeSnapshotClassSyncer) SyncUp(ctx *synccontext.SyncContext, pObj cl var _ syncer.Syncer = &volumeSnapshotClassSyncer{} -func (s *volumeSnapshotClassSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *volumeSnapshotClassSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { // We are not doing any syncing Forward for the VolumeSnapshotClasses // if this method is called it means that VolumeSnapshotClass was deleted in host or // a new VolumeSnapshotClass was created in vcluster, and it should be deleted to avoid confusion diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotcontents/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotcontents/syncer.go index 732d9f8f..cccacbad 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotcontents/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshotcontents/syncer.go @@ -65,9 +65,9 @@ func newIndexByVSCPhysicalName() client.IndexerFunc { } } -var _ syncer.UpSyncer = &volumeSnapshotContentSyncer{} +var _ syncer.ToVirtualSyncer = &volumeSnapshotContentSyncer{} -func (s *volumeSnapshotContentSyncer) SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { +func (s *volumeSnapshotContentSyncer) SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) { pVSC := pObj.(*volumesnapshotv1.VolumeSnapshotContent) // check if the VolumeSnapshotContent should get synced sync, vVS, err := s.shouldSync(ctx.Context, pVSC) @@ -85,7 +85,7 @@ func (s *volumeSnapshotContentSyncer) SyncUp(ctx *synccontext.SyncContext, pObj var _ syncer.Syncer = &volumeSnapshotContentSyncer{} -func (s *volumeSnapshotContentSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *volumeSnapshotContentSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { vVSC := vObj.(*volumesnapshotv1.VolumeSnapshotContent) if vVSC.DeletionTimestamp != nil || (vVSC.Annotations != nil && vVSC.Annotations[HostClusterVSCAnnotation] != "") { if len(vVSC.Finalizers) > 0 { @@ -241,11 +241,11 @@ func (s *volumeSnapshotContentSyncer) IsManaged(ctx context.Context, pObj client return sync, nil } -func (s *volumeSnapshotContentSyncer) VirtualToPhysical(_ context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +func (s *volumeSnapshotContentSyncer) VirtualToHost(_ context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { return types.NamespacedName{Name: translateVolumeSnapshotContentName(req.Name, vObj)} } -func (s *volumeSnapshotContentSyncer) PhysicalToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { +func (s *volumeSnapshotContentSyncer) HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { if pObj != nil { pAnnotations := pObj.GetAnnotations() if pAnnotations != nil && pAnnotations[translate.NameAnnotation] != "" { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer.go index 8499c9c7..bacba9ba 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/resources/volumesnapshots/volumesnapshots/syncer.go @@ -43,7 +43,7 @@ func (s *volumeSnapshotSyncer) Init(registerContext *synccontext.RegisterContext var _ syncer.Syncer = &volumeSnapshotSyncer{} -func (s *volumeSnapshotSyncer) SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { +func (s *volumeSnapshotSyncer) SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) { vVS := vObj.(*volumesnapshotv1.VolumeSnapshot) if vVS.DeletionTimestamp != nil { // delete volume snapshot immediately @@ -60,7 +60,7 @@ func (s *volumeSnapshotSyncer) SyncDown(ctx *synccontext.SyncContext, vObj clien return ctrl.Result{}, err } - return s.SyncDownCreate(ctx, vObj, pObj) + return s.SyncToHostCreate(ctx, vObj, pObj) } func (s *volumeSnapshotSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) { @@ -153,5 +153,5 @@ func (s *volumeSnapshotSyncer) Sync(ctx *synccontext.SyncContext, pObj client.Ob translator.PrintChanges(pVS, updated, ctx.Log) } - return s.SyncDownUpdate(ctx, vVS, updated) + return s.SyncToHostUpdate(ctx, vVS, updated) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/fake_syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/fake_syncer.go index 2ebfafa2..6c10eb01 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/fake_syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/fake_syncer.go @@ -71,7 +71,7 @@ func (r *fakeSyncer) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu return ctrl.Result{}, err } - return r.syncer.FakeSyncUp(syncContext, req.NamespacedName) + return r.syncer.FakeSyncToVirtual(syncContext, req.NamespacedName) } // check if we should skip resource diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/syncer.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/syncer.go index 57ca4a41..fdb462e0 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/syncer.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/syncer.go @@ -117,7 +117,7 @@ func (r *syncerController) Reconcile(ctx context.Context, origReq ctrl.Request) // check what function we should call if vObj != nil && pObj == nil { - return r.syncer.SyncDown(syncContext, vObj) + return r.syncer.SyncToHost(syncContext, vObj) } else if vObj != nil && pObj != nil { // make sure the object uid matches pAnnotations := pObj.GetAnnotations() @@ -140,10 +140,10 @@ func (r *syncerController) Reconcile(ctx context.Context, origReq ctrl.Request) } } - // check if up syncer - upSyncer, ok := r.syncer.(syncertypes.UpSyncer) + // check if virtual syncer + toVirtual, ok := r.syncer.(syncertypes.ToVirtualSyncer) if ok { - return upSyncer.SyncUp(syncContext, pObj) + return toVirtual.SyncToVirtual(syncContext, pObj) } return DeleteObject(syncContext, pObj, "virtual object was deleted") @@ -172,7 +172,7 @@ func (r *syncerController) getObjectsFromPhysical(ctx *synccontext.SyncContext, } // get virtual object - exclude, vObj, err = r.getVirtualObject(ctx.Context, r.syncer.PhysicalToVirtual(ctx.Context, req.NamespacedName, pObj)) + exclude, vObj, err = r.getVirtualObject(ctx.Context, r.syncer.HostToVirtual(ctx.Context, req.NamespacedName, pObj)) if err != nil { return nil, nil, err } else if exclude { @@ -192,7 +192,7 @@ func (r *syncerController) getObjectsFromVirtual(ctx *synccontext.SyncContext, r } // get physical object - exclude, pObj, err = r.getPhysicalObject(ctx.Context, r.syncer.VirtualToPhysical(ctx.Context, req.NamespacedName, vObj), vObj) + exclude, pObj, err = r.getPhysicalObject(ctx.Context, r.syncer.VirtualToHost(ctx.Context, req.NamespacedName, vObj), vObj) if err != nil { return nil, nil, err } else if exclude { @@ -319,7 +319,7 @@ func (r *syncerController) extractRequest(ctx context.Context, req ctrl.Request) } // try to get virtual name from physical - req.NamespacedName = r.syncer.PhysicalToVirtual(ctx, pReq.NamespacedName, pObj) + req.NamespacedName = r.syncer.HostToVirtual(ctx, pReq.NamespacedName, pObj) } return req, pReq, nil @@ -332,7 +332,7 @@ func (r *syncerController) enqueueVirtual(ctx context.Context, obj client.Object // add a new request for the host object as otherwise this information might be lost after a delete event if isDelete { - name := r.syncer.VirtualToPhysical(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, obj) + name := r.syncer.VirtualToHost(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, obj) if name.Name != "" { q.Add(toHostRequest(reconcile.Request{ NamespacedName: name, @@ -365,7 +365,7 @@ func (r *syncerController) enqueuePhysical(ctx context.Context, obj client.Objec // add a new request for the virtual object as otherwise this information might be lost after a delete event if isDelete { - name := r.syncer.PhysicalToVirtual(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, obj) + name := r.syncer.HostToVirtual(ctx, types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, obj) if name.Name != "" { q.Add(reconcile.Request{ NamespacedName: name, diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/cluster_translator.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/cluster_translator.go index 6733ab2e..191e3049 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/cluster_translator.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/cluster_translator.go @@ -44,13 +44,13 @@ func (n *clusterTranslator) IsManaged(_ context2.Context, pObj client.Object) (b return translate.Default.IsManagedCluster(pObj), nil } -func (n *clusterTranslator) VirtualToPhysical(_ context2.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +func (n *clusterTranslator) VirtualToHost(_ context2.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { return types.NamespacedName{ Name: n.nameTranslator(req.Name, vObj), } } -func (n *clusterTranslator) PhysicalToVirtual(ctx context2.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { +func (n *clusterTranslator) HostToVirtual(ctx context2.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { if pObj != nil { pAnnotations := pObj.GetAnnotations() if pAnnotations != nil && pAnnotations[translate.NameAnnotation] != "" { diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/mirror_name_translator.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/mirror_name_translator.go index 087c79f4..207445cf 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/mirror_name_translator.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/mirror_name_translator.go @@ -47,10 +47,10 @@ func (n *mirrorPhysicalTranslator) IsManaged(context.Context, client.Object) (bo return true, nil } -func (n *mirrorPhysicalTranslator) VirtualToPhysical(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (n *mirrorPhysicalTranslator) VirtualToHost(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { return req } -func (n *mirrorPhysicalTranslator) PhysicalToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { +func (n *mirrorPhysicalTranslator) HostToVirtual(_ context.Context, req types.NamespacedName, _ client.Object) types.NamespacedName { return req } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/namespaced_translator.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/namespaced_translator.go index 24a1c4be..936ee777 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/namespaced_translator.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/namespaced_translator.go @@ -66,7 +66,7 @@ func (n *namespacedTranslator) RegisterIndices(ctx *context.RegisterContext) err }) } -func (n *namespacedTranslator) SyncDownCreate(ctx *context.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) { +func (n *namespacedTranslator) SyncToHostCreate(ctx *context.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) { ctx.Log.Infof("create physical %s %s/%s", n.name, pObj.GetNamespace(), pObj.GetName()) err := ctx.PhysicalClient.Create(ctx.Context, pObj) if err != nil { @@ -82,7 +82,7 @@ func (n *namespacedTranslator) SyncDownCreate(ctx *context.SyncContext, vObj, pO return ctrl.Result{}, nil } -func (n *namespacedTranslator) SyncDownUpdate(ctx *context.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) { +func (n *namespacedTranslator) SyncToHostUpdate(ctx *context.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) { // this is needed because of interface nil check if !(pObj == nil || (reflect.ValueOf(pObj).Kind() == reflect.Ptr && reflect.ValueOf(pObj).IsNil())) { ctx.Log.Infof("updating physical %s/%s, because virtual %s have changed", pObj.GetNamespace(), pObj.GetName(), n.name) @@ -103,7 +103,7 @@ func (n *namespacedTranslator) IsManaged(_ context2.Context, pObj client.Object) return translate.Default.IsManaged(pObj), nil } -func (n *namespacedTranslator) VirtualToPhysical(_ context2.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { +func (n *namespacedTranslator) VirtualToHost(_ context2.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName { name := translate.Default.PhysicalName(req.Name, req.Namespace) if n.nameTranslator != nil { name = n.nameTranslator(req, vObj) @@ -115,7 +115,7 @@ func (n *namespacedTranslator) VirtualToPhysical(_ context2.Context, req types.N } } -func (n *namespacedTranslator) PhysicalToVirtual(_ context2.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { +func (n *namespacedTranslator) HostToVirtual(_ context2.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName { if pObj != nil { pAnnotations := pObj.GetAnnotations() if pAnnotations != nil && pAnnotations[translate.NameAnnotation] != "" { @@ -147,7 +147,7 @@ func (n *namespacedTranslator) TranslateMetadata(ctx context2.Context, vObj clie // reset metadata & translate name and namespace translate.ResetObjectMetadata(m) - m.SetName(n.VirtualToPhysical(ctx, types.NamespacedName{Name: vObj.GetName(), Namespace: vObj.GetNamespace()}, vObj).Name) + m.SetName(n.VirtualToHost(ctx, types.NamespacedName{Name: vObj.GetName(), Namespace: vObj.GetNamespace()}, vObj).Name) if vObj.GetNamespace() != "" { m.SetNamespace(translate.Default.PhysicalNamespace(vObj.GetNamespace())) diff --git a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/translator.go b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/translator.go index aa3d796e..5173ada0 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/translator.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/controllers/syncer/translator/translator.go @@ -24,11 +24,11 @@ type NameTranslator interface { // IsManaged determines if a physical object is managed by the vcluster IsManaged(context.Context, client.Object) (bool, error) - // VirtualToPhysical translates a virtual name to a physical name - VirtualToPhysical(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName + // VirtualToHost translates a virtual name to a physical name + VirtualToHost(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName - // PhysicalToVirtual translates a physical name to a virtual name - PhysicalToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName + // HostToVirtual translates a physical name to a virtual name + HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName } // MetadataTranslator is used to convert metadata between virtual and physical objects and vice versa @@ -51,12 +51,12 @@ type NamespacedTranslator interface { // RegisterIndices registers the default indices for the syncer RegisterIndices(ctx *syncercontext.RegisterContext) error - // SyncDownCreate creates the given pObj in the target namespace - SyncDownCreate(ctx *syncercontext.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) + // SyncToHostCreate creates the given pObj in the target namespace + SyncToHostCreate(ctx *syncercontext.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) - // SyncDownUpdate updates the given pObj (if not nil) in the target namespace - SyncDownUpdate(ctx *syncercontext.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) + // SyncToHostUpdate updates the given pObj (if not nil) in the target namespace + SyncToHostUpdate(ctx *syncercontext.SyncContext, vObj, pObj client.Object) (ctrl.Result, error) - // Function to override default VirtualToPhysical name translation + // SetNameTranslator is a function to override default VirtualToHost name translation SetNameTranslator(nameTranslator translate.PhysicalNamespacedNameTranslator) } diff --git a/vendor/github.com/loft-sh/vcluster/pkg/types/types.go b/vendor/github.com/loft-sh/vcluster/pkg/types/types.go index 09dfe4a1..c38a5e5b 100644 --- a/vendor/github.com/loft-sh/vcluster/pkg/types/types.go +++ b/vendor/github.com/loft-sh/vcluster/pkg/types/types.go @@ -27,21 +27,21 @@ type Syncer interface { Object translator.NameTranslator - // SyncDown is called when a virtual object was created and needs to be synced down to the physical cluster - SyncDown(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) + // SyncToHost is called when a virtual object was created and needs to be synced down to the physical cluster + SyncToHost(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) // Sync is called to sync a virtual object with a physical object Sync(ctx *synccontext.SyncContext, pObj client.Object, vObj client.Object) (ctrl.Result, error) } -type UpSyncer interface { - // SyncUp is called when a physical object exists but the virtual object does not exist - SyncUp(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) +type ToVirtualSyncer interface { + // SyncToVirtual is called when a host object exists but the virtual object does not exist + SyncToVirtual(ctx *synccontext.SyncContext, pObj client.Object) (ctrl.Result, error) } type FakeSyncer interface { Object - FakeSyncUp(ctx *synccontext.SyncContext, req types.NamespacedName) (ctrl.Result, error) + FakeSyncToVirtual(ctx *synccontext.SyncContext, req types.NamespacedName) (ctrl.Result, error) FakeSync(ctx *synccontext.SyncContext, vObj client.Object) (ctrl.Result, error) } diff --git a/vendor/modules.txt b/vendor/modules.txt index aa0fdc07..d079fb1d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -407,7 +407,7 @@ github.com/loft-sh/utils/pkg/command github.com/loft-sh/utils/pkg/downloader github.com/loft-sh/utils/pkg/downloader/commands github.com/loft-sh/utils/pkg/extract -# github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201075718-1f1fb0a70d6e +# github.com/loft-sh/vcluster v0.19.0-alpha.4.0.20240201171603-e3abc343e685 ## explicit; go 1.21.5 github.com/loft-sh/vcluster/cmd/vclusterctl/cmd github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/app/create @@ -525,7 +525,7 @@ github.com/loft-sh/vcluster/pkg/util/toleration github.com/loft-sh/vcluster/pkg/util/translate github.com/loft-sh/vcluster/pkg/util/websocketproxy github.com/loft-sh/vcluster/test/framework -# github.com/loft-sh/vcluster-values v0.0.0-20240131102942-9de6e2694279 +# github.com/loft-sh/vcluster-values v0.0.0-20240131133548-d47237f9bcbe ## explicit; go 1.21.5 github.com/loft-sh/vcluster-values/values # github.com/mailru/easyjson v0.7.7