Skip to content

Commit ea5068f

Browse files
committed
add docs
On-behalf-of: @SAP christoph.mewes@sap.com
1 parent 9cb2b5a commit ea5068f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • pkg/konnector/controllers/cluster/serviceexport/isolation

pkg/konnector/controllers/cluster/serviceexport/isolation/strategy.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,36 @@ import (
2323
"k8s.io/apimachinery/pkg/types"
2424
)
2525

26+
// Strategy implements the namespace/name translation for Kubernetes objects when
27+
// they are copied from one cluster to another. Not every strategy is necessarily
28+
// applicable to all circumstances (strategies can be for cluster-scoped or
29+
// namespaced objects only, check their documentation).
2630
type Strategy interface {
31+
// ToProviderKey translates the namespace/name (collectively called "key") from
32+
// the consumer side to the provider side. This function can return a nil key
33+
// for invalid/foreign objects, so callers need to be aware.
2734
ToProviderKey(consumerKey types.NamespacedName) (*types.NamespacedName, error)
35+
36+
// ToConsumerKey translates the namespace/name (collectively called "key") from
37+
// the provider side to the consumer side. This function can return a nil key
38+
// for invalid/foreign objects, so callers need to be aware.
2839
ToConsumerKey(providerKey types.NamespacedName) (*types.NamespacedName, error)
2940

41+
// EnsureProviderKey is very similar to ToProviderKey, but may make changes
42+
// on the provider side and return a nil key in case the target key is simply
43+
// not ready yet. This is most often the case when waiting for the backend
44+
// to assign a namespace for an APIServiceNamespace.
3045
EnsureProviderKey(ctx context.Context, consumerKey types.NamespacedName) (*types.NamespacedName, error)
3146

47+
// MutateMetadataAndSpec mutates the object's content (its main resource) when
48+
// syncing from the consumer side to the provide side. This function is also
49+
// responsible for applying the translated keys (from ToProviderKey).
3250
MutateMetadataAndSpec(consumerObj *unstructured.Unstructured, providerKey types.NamespacedName) error
51+
52+
// MutateStatus is the opposite of MutateMetadataAndSpec and might mutate the
53+
// object status (status subresource) when syncing it back from the provider
54+
// cluster to the consumer cluster. This function is also responsible for
55+
// applying the consumer key to "rename" the object back to its original name
56+
// on the consumer cluster.
3357
MutateStatus(providerObj *unstructured.Unstructured, consumerKey types.NamespacedName) error
3458
}

0 commit comments

Comments
 (0)