sources

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Reusable testing libraries for testing backends

Index

Constants

View Source
const PVCType = "persistentVolumeClaim"

PVCType is the name of the PVC type. I'm saving this as a const since it's a bit nasty and I might want to change it later

Variables

View Source
var ClusterName string

ClusterName stores the name of the cluster, this is also used as the context for non-namespaced items. This designed to be user by namespaced items to create linked item requests on non-namespaced items

View Source
var ClusterNamespaceRegex = regexp.MustCompile(`(?P<clusterName>.+:.+?)(\.(?P<namespace>[a-z0-9]([-a-z0-9]*[a-z0-9])?))?$`)

ClusterNamespaceRegex matches the cluster name and namespace from a string that is in the format {clusterName}.{namespace}

This is possible due to the fact namespaces have a limited set of characters so we can use a regex to find the last instance of a namespace-compliant string after a trailing

SourceFunctions is the list of functions to load

Functions

func APITimeoutContext

func APITimeoutContext() (context.Context, context.CancelFunc)

APITimeoutContext Returns a context representing the configured timeout for API calls. This is configured in the "apitimeout" setting and is represented in seconds

func BasicGetFindSearchTests

func BasicGetFindSearchTests(t *testing.T, query string, source ResourceSource)

BasicGetFindSearchTests Executes a series of basic tests against a kubernetes source. These tests include:

  • Searching with a given query for items
  • Grabbing the name of one of the found items and making sure that we can Get() it
  • Running a Find() and ensuring that there is > 0 results

func GetAllNamespaceNames

func GetAllNamespaceNames(cs *kubernetes.Clientset) ([]string, error)

GetAllNamespaceNames gets the names of all namespaces that can be found for a given connection

func GetK8sMeta

func GetK8sMeta(s metaV1.Object) map[string]interface{}

GetK8sMeta will assign attributes to an existing attributes hash that are taken from Kubernetes ObjectMetadata

func LabelSelectorToQuery

func LabelSelectorToQuery(labelSelector *metaV1.LabelSelector) string

TODO: Rename to LabelSelectorToQuery

func ListOptionsToQuery

func ListOptionsToQuery(lo *metaV1.ListOptions) string

func MapClusterRoleBindingGet

func MapClusterRoleBindingGet(i interface{}) (*sdp.Item, error)

MapClusterRoleBindingGet maps an interface that is underneath a *rbacV1Beta1.ClusterRoleBinding to an item. If the interface isn't actually a *rbacV1Beta1.ClusterRoleBinding this will fail

func MapClusterRoleBindingList

func MapClusterRoleBindingList(i interface{}) ([]*sdp.Item, error)

MapClusterRoleBindingList maps an interface that is underneath a *rbacV1Beta1.ClusterRoleBindingList to a list of Items

func MapClusterRoleGet

func MapClusterRoleGet(i interface{}) (*sdp.Item, error)

MapClusterRoleGet maps an interface that is underneath a *rbacV1Beta1.ClusterRole to an item. If the interface isn't actually a *rbacV1Beta1.ClusterRole this will fail

func MapClusterRoleList

func MapClusterRoleList(i interface{}) ([]*sdp.Item, error)

MapClusterRoleList maps an interface that is underneath a *rbacV1Beta1.ClusterRoleList to a list of Items

func MapConfigMapGet

func MapConfigMapGet(i interface{}) (*sdp.Item, error)

MapConfigMapGet maps an interface that is underneath a *coreV1.ConfigMap to an item. If the interface isn't actually a *coreV1.ConfigMap this will fail

func MapConfigMapList

func MapConfigMapList(i interface{}) ([]*sdp.Item, error)

MapConfigMapList maps an interface that is underneath a *coreV1.ConfigMapList to a list of Items

func MapCronJobGet

func MapCronJobGet(i interface{}) (*sdp.Item, error)

MapCronJobGet maps an interface that is underneath a *batchV1beta1.CronJob to an item. If the interface isn't actually a *batchV1beta1.CronJob this will fail

func MapCronJobList

func MapCronJobList(i interface{}) ([]*sdp.Item, error)

MapCronJobList maps an interface that is underneath a *batchV1beta1.CronJobList to a list of Items

func MapDaemonSetGet

func MapDaemonSetGet(i interface{}) (*sdp.Item, error)

MapDaemonSetGet maps an interface that is underneath a *appsV1.DaemonSet to an item. If the interface isn't actually a *appsV1.DaemonSet this will fail

func MapDaemonSetList

func MapDaemonSetList(i interface{}) ([]*sdp.Item, error)

MapDaemonSetList maps an interface that is underneath a *appsV1.DaemonSetList to a list of Items

func MapDeploymentGet

func MapDeploymentGet(i interface{}) (*sdp.Item, error)

MapDeploymentGet maps an interface that is underneath a *appsV1.Deployment to an item. If the interface isn't actually a *appsV1.Deployment this will fail

func MapDeploymentList

func MapDeploymentList(i interface{}) ([]*sdp.Item, error)

MapDeploymentList maps an interface that is underneath a *appsV1.DeploymentList to a list of Items

func MapEndpointGet

func MapEndpointGet(i interface{}) (*sdp.Item, error)

MapEndpointGet maps an interface that is underneath a *coreV1.Endpoints to an item. If the interface isn't actually a *coreV1.Endpoints this will fail

func MapEndpointList

func MapEndpointList(i interface{}) ([]*sdp.Item, error)

MapEndpointList maps an interface that is underneath a *coreV1.EndpointsList to a list of Items

func MapEndpointSliceGet

func MapEndpointSliceGet(i interface{}) (*sdp.Item, error)

MapEndpointSliceGet maps an interface that is underneath a *discoveryV1beta1.EndpointSlice to an item. If the interface isn't actually a *discoveryV1beta1.EndpointSlice this will fail

func MapEndpointSliceList

func MapEndpointSliceList(i interface{}) ([]*sdp.Item, error)

MapEndpointSliceList maps an interface that is underneath a *discoveryV1beta1.EndpointSliceList to a list of Items

func MapHorizontalPodAutoscalerGet

func MapHorizontalPodAutoscalerGet(i interface{}) (*sdp.Item, error)

MapHorizontalPodAutoscalerGet maps an interface that is underneath a *autoscalingV1.HorizontalPodAutoscaler to an item. If the interface isn't actually a *autoscalingV1.HorizontalPodAutoscaler this will fail

func MapHorizontalPodAutoscalerList

func MapHorizontalPodAutoscalerList(i interface{}) ([]*sdp.Item, error)

MapHorizontalPodAutoscalerList maps an interface that is underneath a *autoscalingV1.HorizontalPodAutoscalerList to a list of Items

func MapIngressGet

func MapIngressGet(i interface{}) (*sdp.Item, error)

MapIngressGet maps an interface that is underneath a *networkingV1.Ingress to an item. If the interface isn't actually a *networkingV1.Ingress this will fail

func MapIngressList

func MapIngressList(i interface{}) ([]*sdp.Item, error)

MapIngressList maps an interface that is underneath a *networkingV1.IngressList to a list of Items

func MapJobGet

func MapJobGet(i interface{}) (*sdp.Item, error)

MapJobGet maps an interface that is underneath a *batchV1.Job to an item. If the interface isn't actually a *batchV1.Job this will fail

func MapJobList

func MapJobList(i interface{}) ([]*sdp.Item, error)

MapJobList maps an interface that is underneath a *batchV1.JobList to a list of Items

func MapLimitRangeGet

func MapLimitRangeGet(i interface{}) (*sdp.Item, error)

MapLimitRangeGet maps an interface that is underneath a *coreV1.LimitRange to an item. If the interface isn't actually a *coreV1.LimitRange this will fail

func MapLimitRangeList

func MapLimitRangeList(i interface{}) ([]*sdp.Item, error)

MapLimitRangeList maps an interface that is underneath a *coreV1.LimitRangeList to a list of Items

func MapNamespaceGet

func MapNamespaceGet(i interface{}) (*sdp.Item, error)

MapNamespaceGet maps an interface that is underneath a *coreV1.Namespace to an item. If the interface isn't actually a *coreV1.Namespace this will fail

func MapNamespaceList

func MapNamespaceList(i interface{}) ([]*sdp.Item, error)

MapNamespaceList maps an interface that is underneath a *coreV1.NamespaceList to a list of Items

func MapNetworkPolicyGet

func MapNetworkPolicyGet(i interface{}) (*sdp.Item, error)

MapNetworkPolicyGet maps an interface that is underneath a *networkingV1.NetworkPolicy to an item. If the interface isn't actually a *networkingV1.NetworkPolicy this will fail

func MapNetworkPolicyList

func MapNetworkPolicyList(i interface{}) ([]*sdp.Item, error)

MapNetworkPolicyList maps an interface that is underneath a *networkingV1.NetworkPolicyList to a list of Items

func MapPVCGet

func MapPVCGet(i interface{}) (*sdp.Item, error)

MapPVCGet maps an interface that is underneath a *coreV1.PersistentVolumeClaim to an item. If the interface isn't actually a *coreV1.PersistentVolumeClaim this will fail

func MapPVCList

func MapPVCList(i interface{}) ([]*sdp.Item, error)

MapPVCList maps an interface that is underneath a *coreV1.PersistentVolumeClaimList to a list of Items

func MapPersistentVolumeGet

func MapPersistentVolumeGet(i interface{}) (*sdp.Item, error)

MapPersistentVolumeGet maps an interface that is underneath a *coreV1.PersistentVolume to an item. If the interface isn't actually a *coreV1.PersistentVolume this will fail

func MapPersistentVolumeList

func MapPersistentVolumeList(i interface{}) ([]*sdp.Item, error)

MapPersistentVolumeList maps an interface that is underneath a *coreV1.PersistentVolumeList to a list of Items

func MapPodDisruptionBudgetGet

func MapPodDisruptionBudgetGet(i interface{}) (*sdp.Item, error)

MapPodDisruptionBudgetGet maps an interface that is underneath a *policyV1beta1.PodDisruptionBudget to an item. If the interface isn't actually a *policyV1beta1.PodDisruptionBudget this will fail

func MapPodDisruptionBudgetList

func MapPodDisruptionBudgetList(i interface{}) ([]*sdp.Item, error)

MapPodDisruptionBudgetList maps an interface that is underneath a *policyV1beta1.PodDisruptionBudgetList to a list of Items

func MapPodGet

func MapPodGet(i interface{}) (*sdp.Item, error)

MapPodGet maps an interface that is underneath a *coreV1.Pod to an item. If the interface isn't actually a *coreV1.Pod this will fail

func MapPodList

func MapPodList(i interface{}) ([]*sdp.Item, error)

MapPodList maps an interface that is underneath a *coreV1.PodList to a list of Items

func MapPriorityClassGet

func MapPriorityClassGet(i interface{}) (*sdp.Item, error)

MapPriorityClassGet maps an interface that is underneath a *coreV1.PriorityClass to an item. If the interface isn't actually a *coreV1.PriorityClass this will fail

func MapPriorityClassList

func MapPriorityClassList(i interface{}) ([]*sdp.Item, error)

MapPriorityClassList maps an interface that is underneath a *coreV1.PriorityClassList to a list of Items

func MapReplicaSetGet

func MapReplicaSetGet(i interface{}) (*sdp.Item, error)

MapReplicaSetGet maps an interface that is underneath a *appsV1.ReplicaSet to an item. If the interface isn't actually a *appsV1.ReplicaSet this will fail

func MapReplicaSetList

func MapReplicaSetList(i interface{}) ([]*sdp.Item, error)

MapReplicaSetList maps an interface that is underneath a *appsV1.ReplicaSetList to a list of Items

func MapReplicationControllerGet

func MapReplicationControllerGet(i interface{}) (*sdp.Item, error)

MapReplicationControllerGet maps an interface that is underneath a *coreV1.ReplicationController to an item. If the interface isn't actually a *coreV1.ReplicationController this will fail

func MapReplicationControllerList

func MapReplicationControllerList(i interface{}) ([]*sdp.Item, error)

MapReplicationControllerList maps an interface that is underneath a *coreV1.ReplicationControllerList to a list of Items

func MapResourceQuotaGet

func MapResourceQuotaGet(i interface{}) (*sdp.Item, error)

MapResourceQuotaGet maps an interface that is underneath a *coreV1.ResourceQuota to an item. If the interface isn't actually a *coreV1.ResourceQuota this will fail

func MapResourceQuotaList

func MapResourceQuotaList(i interface{}) ([]*sdp.Item, error)

MapResourceQuotaList maps an interface that is underneath a *coreV1.ResourceQuotaList to a list of Items

func MapRoleBindingGet

func MapRoleBindingGet(i interface{}) (*sdp.Item, error)

MapRoleBindingGet maps an interface that is underneath a *rbacV1.RoleBinding to an item. If the interface isn't actually a *rbacV1.RoleBinding this will fail

func MapRoleBindingList

func MapRoleBindingList(i interface{}) ([]*sdp.Item, error)

MapRoleBindingList maps an interface that is underneath a *rbacV1.RoleBindingList to a list of Items

func MapRoleGet

func MapRoleGet(i interface{}) (*sdp.Item, error)

MapRoleGet maps an interface that is underneath a *rbacV1.Role to an item. If the interface isn't actually a *rbacV1.Role this will fail

func MapRoleList

func MapRoleList(i interface{}) ([]*sdp.Item, error)

MapRoleList maps an interface that is underneath a *rbacV1.RoleList to a list of Items

func MapSecretGet

func MapSecretGet(i interface{}) (*sdp.Item, error)

MapSecretGet maps an interface that is underneath a *coreV1.Secret to an item. If the interface isn't actually a *coreV1.Secret this will fail

func MapSecretList

func MapSecretList(i interface{}) ([]*sdp.Item, error)

MapSecretList maps an interface that is underneath a *coreV1.SecretList to a list of Items

func MapServiceAccountGet

func MapServiceAccountGet(i interface{}) (*sdp.Item, error)

MapServiceAccountGet maps an interface that is underneath a *coreV1.ServiceAccount to an item. If the interface isn't actually a *coreV1.ServiceAccount this will fail

func MapServiceAccountList

func MapServiceAccountList(i interface{}) ([]*sdp.Item, error)

MapServiceAccountList maps an interface that is underneath a *coreV1.ServiceAccountList to a list of Items

func MapServiceGet

func MapServiceGet(i interface{}) (*sdp.Item, error)

MapServiceGet Maps an interface (which is the result of out Get function) to a service item

func MapServiceList

func MapServiceList(i interface{}) ([]*sdp.Item, error)

MapServiceList Maps the interface output of our list function to a list of items

func MapStatefulSetGet

func MapStatefulSetGet(i interface{}) (*sdp.Item, error)

MapStatefulSetGet maps an interface that is underneath a *appsV1.StatefulSet to an item. If the interface isn't actually a *appsV1.StatefulSet this will fail

func MapStatefulSetList

func MapStatefulSetList(i interface{}) ([]*sdp.Item, error)

MapStatefulSetList maps an interface that is underneath a *appsV1.StatefulSetList to a list of Items

func MapStorageClassGet

func MapStorageClassGet(i interface{}) (*sdp.Item, error)

MapStorageClassGet maps an interface that is underneath a *storageV1.StorageClass to an item. If the interface isn't actually a *storageV1.StorageClass this will fail

func MapStorageClassList

func MapStorageClassList(i interface{}) ([]*sdp.Item, error)

MapStorageClassList maps an interface that is underneath a *storageV1.StorageClassList to a list of Items

func ObjectReferenceToLIR

func ObjectReferenceToLIR(ref *coreV1.ObjectReference, parentContext string) *sdp.ItemRequest

ObjectReferenceToLIR Converts a K8s ObjectReference to a linked item request. Note that you must provide the parent context (the name of the cluster) since the reference could be an object in a different namespace and therefore context. If the parent context is empty, the context will be assumed to be the same as the current object

func QueryToListOptions

func QueryToListOptions(query string) (metaV1.ListOptions, error)

QueryToListOptions converts a Search() query string to a ListOptions object that can be used to query the API

func TestValidateItem

func TestValidateItem(t *testing.T, i *sdp.Item)

TestValidateItem Checks an item to ensure it is a valid SDP item. This includes checking that all required attributes are populated

func TestValidateItems

func TestValidateItems(t *testing.T, is []*sdp.Item)

TestValidateItems Runs TestValidateItem on many items

func ThroughJSON

func ThroughJSON(i interface{}) (interface{}, error)

ThroughJSON Converts the object though JSON and back returning an interface with all other type data stripped

Types

type ContextDetails

type ContextDetails struct {
	ClusterName string
	Namespace   string
}

func ParseContext

func ParseContext(itemContext string) (ContextDetails, error)

ParseContext Parses the custer and context name out of a given SDP context given that the naming convention is {clusterName}.{namespace}

type NamespaceStorage

type NamespaceStorage struct {
	CS            *kubernetes.Clientset
	CacheDuration time.Duration
	// contains filtered or unexported fields
}

NamespaceStorage is an object that is used for storing the list of namespaces. Many of the non-namespaced resources will need to know what thee list of namespaces is in order for them to create LinkedItemRequests. This object stores them to ensure that we don't unnecessarily spam the API

func (*NamespaceStorage) Namespaces

func (ns *NamespaceStorage) Namespaces() ([]string, error)

Namespaces returns the list of namespaces, updating if required

type NamespacedSourceFunction

type NamespacedSourceFunction func(cs *kubernetes.Clientset) ResourceSource

NamespacedSourceFunction is a function that accepts a kubernetes client and namespace, and returns a ResourceSource for a given type. This also satisfies the Backend interface

type NonNamespacedSourceFunction

type NonNamespacedSourceFunction func(cs *kubernetes.Clientset) ResourceSource

NonNamespacedSourceFunction is a function that accepts a kubernetes client and returns a ResourceSource for a given type. This also satisfies the Backend interface

type ResourceSource

type ResourceSource struct {
	// The type of items that will be returned from this source
	ItemType string
	// A function that will accept an interface and return a list of items. The
	// interface that is passed will be the first item returned from
	// "listFunction", as an interface. The function should covert this to
	// whatever format it is expecting, the proceed to map to Items
	MapList func(interface{}) ([]*sdp.Item, error)
	// A function that will accept an interface and return an item. The
	// interface that is passed will be the first item returned from
	// "getFunction", as an interface. The function should covert this to
	// whatever format it is expecting, the proceed to map to an item
	MapGet func(interface{}) (*sdp.Item, error)

	// Whether or not this source is for namespaced resources
	Namespaced bool

	// NSS Namespace storage for when backends need to lookup the list of
	// namespaces
	NSS *NamespaceStorage
	// contains filtered or unexported fields
}

ResourceSource represents a source of Kubernetes resources. one of these sources needs to be created, and then have its get and list functions registered by calling the LoadFunctions method. Note that in order for this to be able to discover any time of Kubernetes resource it uses as significant amount of reflection. The LoadFunctions method should do enough error checking to ensure that the methods on this struct don't cause any panics, but there is still a very real chance that there will be panics so be careful doing anything non-standard with this struct

func ClusterRoleBindingSource

func ClusterRoleBindingSource(cs *kubernetes.Clientset) (ResourceSource, error)

ClusterRoleBindingSource returns a ResourceSource for ClusterRoleBindingClaims for a given client

func ClusterRoleSource

func ClusterRoleSource(cs *kubernetes.Clientset) (ResourceSource, error)

ClusterRoleSource returns a ResourceSource for ClusterRoleClaims for a given client

func ConfigMapSource

func ConfigMapSource(cs *kubernetes.Clientset) (ResourceSource, error)

ConfigMapSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func CronJobSource

func CronJobSource(cs *kubernetes.Clientset) (ResourceSource, error)

CronJobSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func DaemonSetSource

func DaemonSetSource(cs *kubernetes.Clientset) (ResourceSource, error)

DaemonSetSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func DeploymentSource

func DeploymentSource(cs *kubernetes.Clientset) (ResourceSource, error)

DeploymentSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func EndpointSliceSource

func EndpointSliceSource(cs *kubernetes.Clientset) (ResourceSource, error)

EndpointSliceSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func EndpointSource

func EndpointSource(cs *kubernetes.Clientset) (ResourceSource, error)

EndpointSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func HorizontalPodAutoscalerSource

func HorizontalPodAutoscalerSource(cs *kubernetes.Clientset) (ResourceSource, error)

HorizontalPodAutoscalerSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func IngressSource

func IngressSource(cs *kubernetes.Clientset) (ResourceSource, error)

IngressSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func JobSource

func JobSource(cs *kubernetes.Clientset) (ResourceSource, error)

JobSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func LimitRangeSource

func LimitRangeSource(cs *kubernetes.Clientset) (ResourceSource, error)

LimitRangeSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func NamespaceSource

func NamespaceSource(cs *kubernetes.Clientset) (ResourceSource, error)

NamespaceSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func NetworkPolicySource

func NetworkPolicySource(cs *kubernetes.Clientset) (ResourceSource, error)

NetworkPolicySource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func NodeSource

func NodeSource(cs *kubernetes.Clientset) (ResourceSource, error)

NodeSource returns a ResourceSource for PersistentVolumeClaims for a given client

func PVCSource

func PVCSource(cs *kubernetes.Clientset) (ResourceSource, error)

PVCSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func PersistentVolumeSource

func PersistentVolumeSource(cs *kubernetes.Clientset) (ResourceSource, error)

PersistentVolumeSource returns a ResourceSource for PersistentVolumeClaims for a given client

func PodDisruptionBudgetSource

func PodDisruptionBudgetSource(cs *kubernetes.Clientset) (ResourceSource, error)

PodDisruptionBudgetSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func PodSource

func PodSource(cs *kubernetes.Clientset) (ResourceSource, error)

PodSource returns a ResourceSource for Pods for a given client and namespace

func PriorityClassSource

func PriorityClassSource(cs *kubernetes.Clientset) (ResourceSource, error)

PriorityClassSource returns a ResourceSource for PriorityClassClaims for a given client

func ReplicaSetSource

func ReplicaSetSource(cs *kubernetes.Clientset) (ResourceSource, error)

ReplicaSetSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func ReplicationControllerSource

func ReplicationControllerSource(cs *kubernetes.Clientset) (ResourceSource, error)

ReplicationControllerSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func ResourceQuotaSource

func ResourceQuotaSource(cs *kubernetes.Clientset) (ResourceSource, error)

ResourceQuotaSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func RoleBindingSource

func RoleBindingSource(cs *kubernetes.Clientset) (ResourceSource, error)

RoleBindingSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func RoleSource

func RoleSource(cs *kubernetes.Clientset) (ResourceSource, error)

RoleSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func SecretSource

func SecretSource(cs *kubernetes.Clientset) (ResourceSource, error)

SecretSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

Secret Sauce

* 1/4 cup salad dressing (like Miracle Whip) * 1/4 cup mayonnaise * 3 tablespoons French salad dressing (Wishbone brand) * 1/2 tablespoon sweet pickle relish (Heinz brand) * 1 1/2 tablespoons dill pickle relish (Vlasic or Heinz brand) * 1 teaspoon sugar * 1 teaspoon dried minced onion * 1 teaspoon white vinegar * 1 teaspoon ketchup * 1/8 teaspoon salt

func ServiceAccountSource

func ServiceAccountSource(cs *kubernetes.Clientset) (ResourceSource, error)

ServiceAccountSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func ServiceSource

func ServiceSource(cs *kubernetes.Clientset) (ResourceSource, error)

ServiceSource returns a ResourceSource for Pods for a given client and namespace

func StatefulSetSource

func StatefulSetSource(cs *kubernetes.Clientset) (ResourceSource, error)

StatefulSetSource returns a ResourceSource for PersistentVolumeClaims for a given client and namespace

func StorageClassSource

func StorageClassSource(cs *kubernetes.Clientset) (ResourceSource, error)

StorageClassSource returns a ResourceSource for StorageClassClaims for a given client

func (*ResourceSource) Contexts

func (rs *ResourceSource) Contexts() []string

Context Returns the list of contexts that this source is capable of findinf items for. This is usually the name of the cluster, plus any namespaces in the format {clusterName}.{namespace}

func (*ResourceSource) Find

func (rs *ResourceSource) Find(itemContext string) ([]*sdp.Item, error)

Find finds all items that the backend possibly can. It maybe be possible that this might not be an exhaustive list though in the case of kubernetes it is unlikely

func (*ResourceSource) Get

func (rs *ResourceSource) Get(itemContext string, name string) (*sdp.Item, error)

Get takes the UniqueAttribute value as a parameter (also referred to as the "name" of the item) and returns a full item will all details. This function must return an item whose UniqueAttribute value exactly matches the supplied parameter. If the item cannot be found it should return an ItemNotFoundError (Required)

func (*ResourceSource) LoadFunction

func (rs *ResourceSource) LoadFunction(interfaceFunction interface{}) error

LoadFunctions performs validation on the supplied interface function. This function should retrun an interface which has Get() and List() methods

A Get should be:

func(ctx context.Context, name string, opts metaV1.GetOptions)

A List should be:

List(ctx context.Context, opts metaV1.ListOptions)

func (*ResourceSource) MapNodeGet

func (rs *ResourceSource) MapNodeGet(i interface{}) (*sdp.Item, error)

MapNodeGet maps an interface that is underneath a *coreV1.Node to an item. If the interface isn't actually a *coreV1.Node this will fail

func (*ResourceSource) MapNodeList

func (rs *ResourceSource) MapNodeList(i interface{}) ([]*sdp.Item, error)

MapNodeList maps an interface that is underneath a *coreV1.NodeList to a list of Items

func (*ResourceSource) Name

func (rs *ResourceSource) Name() string

Name returns a descriptive name for the source, used in logging and metadata

func (*ResourceSource) Search

func (rs *ResourceSource) Search(itemContext string, query string) ([]*sdp.Item, error)

Search This search for items that match a given ListOptions. The query must be provided as a JSON object that can be cast to a [ListOptions](https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#ListOptions) object.

*Note:* Additional changes will be made to the ListOptions object after deserialization such as limiting the scope to items of the same type as the current ResourceSource, and drooping any options such as "Watch"

func (*ResourceSource) Type

func (rs *ResourceSource) Type() string

Type is the type of items that this returns (Required)

func (*ResourceSource) Weight

func (rs *ResourceSource) Weight() int

Weight The weight of this source, used for conflict resolution. Currently returns a static value of 100

type Selector

type Selector map[string]string

Selector represents a set of key value pairs that we are going to use as a selector

func (Selector) String

func (l Selector) String() string

String converts a set of key value pairs to the string format that a selector is expecting

type SourceFunction

type SourceFunction func(cs *kubernetes.Clientset) (ResourceSource, error)

SourceFunction is a function that accepts a kubernetes client and returns a ResourceSource for a given type. This also satisfies the discovery.Source interface

Jump to

Keyboard shortcuts

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