keys

package
v1.9.0-preview4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterWideKey

type ClusterWideKey struct {
	// Group is the API Group of resource being referenced.
	Group string

	// Version is the API Version of the resource being referenced.
	Version string

	// Kind is the type of resource being referenced.
	Kind string

	// Namespace is the name of a namespace.
	Namespace string

	// Name is the name of resource being referenced.
	Name string
}

ClusterWideKey is the object key which is a unique identifier under a cluster, across all resources.

func ClusterWideKeyFunc

func ClusterWideKeyFunc(obj interface{}) (ClusterWideKey, error)

ClusterWideKeyFunc generates a ClusterWideKey for object.

func (*ClusterWideKey) GroupVersion

func (k *ClusterWideKey) GroupVersion() schema.GroupVersion

GroupVersion returns the group and version of resource being referenced.

func (*ClusterWideKey) GroupVersionKind

func (k *ClusterWideKey) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the group, version, and kind of resource being referenced.

func (*ClusterWideKey) NamespaceKey

func (k *ClusterWideKey) NamespaceKey() string

NamespaceKey returns the traditional key of an object.

func (ClusterWideKey) String

func (k ClusterWideKey) String() string

String returns the key's printable info with format: "<GroupVersion>, kind=<Kind>, <NamespaceKey>"

Example
key := ClusterWideKey{
	Group:     "apps",
	Version:   "v1",
	Kind:      "Namespace",
	Namespace: "default",
	Name:      "foo",
}
pKey := &key
fmt.Printf("%s\n", key)
fmt.Printf("%v\n", key)
fmt.Printf("%s\n", key.String())
fmt.Printf("%s\n", pKey)
fmt.Printf("%v\n", pKey)
fmt.Printf("%s\n", pKey.String())
Output:

apps/v1, kind=Namespace, default/foo
apps/v1, kind=Namespace, default/foo
apps/v1, kind=Namespace, default/foo
apps/v1, kind=Namespace, default/foo
apps/v1, kind=Namespace, default/foo
apps/v1, kind=Namespace, default/foo

type ClusterWideKeyWithConfig added in v1.9.0

type ClusterWideKeyWithConfig struct {
	// ClusterWideKey is the object key which is a unique identifier under a cluster, across all resources.
	ClusterWideKey ClusterWideKey

	// ResourceChangeByKarmada defines whether resource is changed by Karmada
	ResourceChangeByKarmada bool
}

ClusterWideKeyWithConfig is the object key which is a unique identifier under a cluster, combined with certain config.

func (ClusterWideKeyWithConfig) String added in v1.9.0

func (k ClusterWideKeyWithConfig) String() string

String returns the key's printable info with format: "<GroupVersion>, kind=<Kind>, <NamespaceKey>, ResourceChangeByKarmada=<ResourceChangeByKarmada>"

type FederatedKey

type FederatedKey struct {
	// Cluster is the cluster name of the referencing object.
	Cluster string
	ClusterWideKey
}

FederatedKey is the object key which is a unique identifier across all clusters in federation.

func FederatedKeyFunc

func FederatedKeyFunc(cluster string, obj interface{}) (FederatedKey, error)

FederatedKeyFunc generates a FederatedKey for object.

func (FederatedKey) String

func (f FederatedKey) String() string

String returns the key's printable info with format: "cluster=<Cluster>, <GroupVersion>, kind=<Kind>, <NamespaceKey>"

Example
key := FederatedKey{
	Cluster: "karmada",
	ClusterWideKey: ClusterWideKey{
		Group:     "apps",
		Version:   "v1",
		Kind:      "Namespace",
		Namespace: "default",
		Name:      "foo"},
}
pKey := &key
fmt.Printf("%s\n", key)
fmt.Printf("%v\n", key)
fmt.Printf("%s\n", key.String())
fmt.Printf("%s\n", pKey)
fmt.Printf("%v\n", pKey)
fmt.Printf("%s\n", pKey.String())
Output:

cluster=karmada, apps/v1, kind=Namespace, default/foo
cluster=karmada, apps/v1, kind=Namespace, default/foo
cluster=karmada, apps/v1, kind=Namespace, default/foo
cluster=karmada, apps/v1, kind=Namespace, default/foo
cluster=karmada, apps/v1, kind=Namespace, default/foo
cluster=karmada, apps/v1, kind=Namespace, default/foo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL