Skip to content

Commit

Permalink
chore: bump example sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Feb 1, 2024
1 parent ea54922 commit 3ca4eec
Show file tree
Hide file tree
Showing 47 changed files with 279 additions and 254 deletions.
8 changes: 5 additions & 3 deletions e2e/test_plugin/syncers/car.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions e2e/test_plugin/syncers/import_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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{}
}
Expand All @@ -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{}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/crd-sync/syncers/car.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions examples/import-secrets/syncers/import_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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{}
}
Expand All @@ -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{}
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3ca4eec

Please sign in to comment.