operator-sdk: github.com/operator-framework/operator-sdk/pkg/k8sutil Index | Files

package k8sutil

import "github.com/operator-framework/operator-sdk/pkg/k8sutil"

Index

Package Files

constants.go k8sutil.go

Constants

const (
    // KubeConfigEnvVar defines the env variable KUBECONFIG which
    // contains the kubeconfig file path.
    KubeConfigEnvVar = "KUBECONFIG"

    // WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
    // which is the namespace where the watch activity happens.
    // this value is empty if the operator is running with clusterScope.
    WatchNamespaceEnvVar = "WATCH_NAMESPACE"

    // OperatorNameEnvVar is the constant for env variable OPERATOR_NAME
    // which is the name of the current operator
    OperatorNameEnvVar = "OPERATOR_NAME"

    // PodNameEnvVar is the constant for env variable POD_NAME
    // which is the name of the current pod.
    PodNameEnvVar = "POD_NAME"
)

Variables

var ErrNoNamespace = fmt.Errorf("namespace not found for current environment")

ErrNoNamespace indicates that a namespace could not be found for the current environment

var ErrRunLocal = fmt.Errorf("operator run mode forced to local")

ErrRunLocal indicates that the operator is set to run in local mode (this error is returned by functions that only work on operators running in cluster mode)

var ForceRunModeEnv = "OSDK_FORCE_RUN_MODE"

ForceRunModeEnv indicates if the operator should be forced to run in either local or cluster mode (currently only used for local mode)

func GetGVKsFromAddToScheme Uses

func GetGVKsFromAddToScheme(addToSchemeFunc func(*runtime.Scheme) error) ([]schema.GroupVersionKind, error)

GetGVKsFromAddToScheme takes in the runtime scheme and filters out all generic apimachinery meta types. It returns just the GVK specific to this scheme.

func GetOperatorName Uses

func GetOperatorName() (string, error)

GetOperatorName return the operator name

func GetOperatorNamespace Uses

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace the operator should be running in.

func GetPod Uses

func GetPod(ctx context.Context, client crclient.Client, ns string) (*corev1.Pod, error)

GetPod returns a Pod object that corresponds to the pod in which the code is currently running. It expects the environment variable POD_NAME to be set by the downwards API.

func GetWatchNamespace Uses

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func ResourceExists Uses

func ResourceExists(dc discovery.DiscoveryInterface, apiGroupVersion, kind string) (bool, error)

ResourceExists returns true if the given resource kind exists in the given api groupversion

func SupportsOwnerReference Uses

func SupportsOwnerReference(restMapper meta.RESTMapper, owner, dependent runtime.Object) (bool, error)

SupportsOwnerReference checks whether a given dependent supports owner references, based on the owner. This function performs following checks:

-- True: Owner is cluster-scoped.
-- True: Both Owner and dependent are Namespaced with in same namespace.
-- False: Owner is Namespaced and dependent is Cluster-scoped.
-- False: Both Owner and dependent are Namespaced with different namespaces.

type RunModeType Uses

type RunModeType string
const (
    LocalRunMode   RunModeType = "local"
    ClusterRunMode RunModeType = "cluster"
)

Package k8sutil imports 12 packages (graph) and is imported by 63 packages. Updated 2020-05-22. Refresh now. Tools for package owners.