servicecatalog

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FieldExternalClassName is the jsonpath to a class's external name.
	FieldExternalClassName = "spec.externalName"
	// MultipleClassesFoundError is the error returned when we find a clusterserviceclass
	// and a serviceclass with the same name
	MultipleClassesFoundError = "More than one class found"
)
View Source
const (
	// FieldExternalPlanName is the jsonpath to a plan's external name.
	FieldExternalPlanName = "spec.externalName"

	// FieldClusterServiceClassRef is the jsonpath to a plan's associated class name.
	FieldClusterServiceClassRef = "spec.clusterServiceClassRef.name"

	// FieldServiceClassRef is the jsonpath to a plan's associated class name.
	FieldServiceClassRef = "spec.serviceClassRef.name"
)
View Source
const (
	// ClusterScope filters resources to those defined at the cluster-scope.
	ClusterScope = "cluster"

	// NamespaceScope filters resources to those defined within a namespace.
	NamespaceScope = "namespace"

	// AllScope combines all resources at both the cluster and namespace scopes.
	AllScope = "all"
)
View Source
const (
	// FieldServicePlanRef is the jsonpath to an instance's plan name (Kubernetes name).
	FieldServicePlanRef = "spec.clusterServicePlanRef.name"
)
View Source
const MultipleBrokersFoundError = "More than one broker found"

MultipleBrokersFoundError is the error returned when we find a clusterservicebroker and a servicebroker with the same name

Variables

This section is empty.

Functions

func BuildParameters

func BuildParameters(params interface{}) *runtime.RawExtension

BuildParameters converts a map of variable assignments to a byte encoded json document, which is what the ServiceCatalog API consumes.

func BuildParametersFrom

func BuildParametersFrom(secrets map[string]string) []v1beta1.ParametersFromSource

BuildParametersFrom converts a map of secrets names to secret keys to the type consumed by the ServiceCatalog API.

func GetBindingStatusCondition

func GetBindingStatusCondition(status v1beta1.ServiceBindingStatus) v1beta1.ServiceBindingCondition

GetBindingStatusCondition returns the last condition on a binding status. When no conditions exist, an empty condition is returned.

Types

type Broker

type Broker interface {

	// GetName returns the broker's name.
	GetName() string

	// GetNamespace returns the broker's namespace, or "" if it's cluster-scoped.
	GetNamespace() string

	// GetURL returns the broker's URL.
	GetURL() string

	// GetSpec returns the broker's spec.
	GetSpec() v1beta1.CommonServiceBrokerSpec

	// GetStatus returns the broker's status.
	GetStatus() v1beta1.CommonServiceBrokerStatus
}

Broker provides a unifying layer of cluster and namespace scoped broker resources.

type Class

type Class interface {

	// GetName returns the class's name.
	GetName() string

	// GetNamespace returns the class's namespace, or "" if it's cluster-scoped.
	GetNamespace() string

	// GetExternalName returns the class's external name.
	GetExternalName() string

	// GetDescription returns the class description.
	GetDescription() string

	// GetSpec returns the spec.
	GetSpec() v1beta1.CommonServiceClassSpec

	// GetServiceBrokerName returns the name of the service
	// broker for the class.
	GetServiceBrokerName() string

	// GetStatusText returns the status of the class.
	GetStatusText() string

	// IsClusterServiceCLass returns true if the class is a ClusterServiceClass
	IsClusterServiceClass() bool
}

Class provides a unifying layer of cluster and namespace scoped class resources.

type CreateClassFromOptions added in v0.1.33

type CreateClassFromOptions struct {
	Name      string
	Scope     Scope
	Namespace string
	From      string
}

CreateClassFromOptions allows to specify how a new class will be created

type FilterOptions

type FilterOptions struct {
	ClassID string
}

FilterOptions allows for optional filtering fields to be passed to `Retrieve` methods.

type Plan

type Plan interface {

	// GetName returns the plan's name.
	GetName() string

	// GetShortStatus returns the plan's status.
	GetShortStatus() string

	// GetNamespace returns the plan's namespace, or "" if it's cluster-scoped.
	GetNamespace() string

	// GetExternalName returns the plan's external name.
	GetExternalName() string

	// GetDescription returns the plan description.
	GetDescription() string

	// GetFree returns if the plan is free.
	GetFree() bool

	// GetClassID returns the plan's class name.
	GetClassID() string

	// GetInstanceCreateSchema returns the instance create schema from plan.
	GetInstanceCreateSchema() *runtime.RawExtension

	// GetInstanceUpdateSchema returns the instance update schema from plan.
	GetInstanceUpdateSchema() *runtime.RawExtension

	// GetBindingCreateSchema returns the instance create schema from plan.
	GetBindingCreateSchema() *runtime.RawExtension

	// GetDefaultProvisionParameters returns the default provision parameters from plan.
	GetDefaultProvisionParameters() *runtime.RawExtension
}

Plan provides a unifying layer of cluster and namespace scoped plan resources.

type ProvisionOptions added in v0.1.39

type ProvisionOptions struct {
	ExternalID string
	Namespace  string
	Params     interface{}
	Secrets    map[string]string
}

ProvisionOptions allows for the passing of optional fields to the instance Provision method.

type RegisterOptions

type RegisterOptions struct {
	BasicSecret       string
	BearerSecret      string
	CAFile            string
	ClassRestrictions []string
	Namespace         string
	PlanRestrictions  []string
	RelistBehavior    v1beta1.ServiceBrokerRelistBehavior
	RelistDuration    *metav1.Duration
	SkipTLS           bool
}

RegisterOptions allows for passing of optional fields to the broker Register method.

type SDK

type SDK struct {
	K8sClient            kubernetes.Interface
	ServiceCatalogClient clientset.Interface
}

SDK wrapper around the generated Go client for the Kubernetes Service Catalog

func (*SDK) Bind

func (sdk *SDK) Bind(namespace, bindingName, externalID, instanceName, secretName string,
	params interface{}, secrets map[string]string) (*v1beta1.ServiceBinding, error)

Bind an instance to a secret.

func (*SDK) BindingParentHierarchy

BindingParentHierarchy retrieves all ancestor resources of a binding.

func (*SDK) BrokerHasStatus added in v0.1.32

func (sdk *SDK) BrokerHasStatus(broker Broker, status v1beta1.ServiceBrokerConditionType) bool

BrokerHasStatus returns if the broker is in the specified status.

func (*SDK) Core

func (sdk *SDK) Core() corev1.CoreV1Interface

Core is the underlying generated Core API versioned interface It should be used instead of accessing the client directly.

func (*SDK) CreateClassFrom added in v0.1.33

func (sdk *SDK) CreateClassFrom(opts CreateClassFromOptions) (Class, error)

CreateClassFrom returns new created class

func (*SDK) DeleteBinding

func (sdk *SDK) DeleteBinding(ns, bindingName string) error

DeleteBinding by name.

func (*SDK) DeleteBindings

func (sdk *SDK) DeleteBindings(bindings []types.NamespacedName) ([]types.NamespacedName, error)

DeleteBindings deletes bindings by name.

func (*SDK) Deprovision

func (sdk *SDK) Deprovision(namespace, instanceName string) error

Deprovision deletes an instance.

func (*SDK) Deregister

func (sdk *SDK) Deregister(brokerName string, scopeOpts *ScopeOptions) error

Deregister deletes a broker

func (*SDK) InstanceHasStatus

func (sdk *SDK) InstanceHasStatus(instance *v1beta1.ServiceInstance, status v1beta1.ServiceInstanceConditionType) bool

InstanceHasStatus returns if the instance is in the specified status.

func (*SDK) InstanceParentHierarchy

InstanceParentHierarchy retrieves all ancestor resources of an instance.

func (*SDK) InstanceToServiceClassAndPlan

func (sdk *SDK) InstanceToServiceClassAndPlan(instance *v1beta1.ServiceInstance,
) (*v1beta1.ClusterServiceClass, *v1beta1.ClusterServicePlan, error)

InstanceToServiceClassAndPlan retrieves the parent class and plan for an instance.

func (*SDK) IsBindingFailed

func (sdk *SDK) IsBindingFailed(binding *v1beta1.ServiceBinding) bool

IsBindingFailed returns true if the instance is in the Failed status.

func (*SDK) IsBindingReady

func (sdk *SDK) IsBindingReady(binding *v1beta1.ServiceBinding) bool

IsBindingReady returns true if the instance is in the Ready status.

func (*SDK) IsBrokerFailed added in v0.1.32

func (sdk *SDK) IsBrokerFailed(broker Broker) bool

IsBrokerFailed returns if the broker is in the Failed status.

func (*SDK) IsBrokerReady added in v0.1.32

func (sdk *SDK) IsBrokerReady(broker Broker) bool

IsBrokerReady returns if the broker is in the Ready status.

func (*SDK) IsInstanceFailed

func (sdk *SDK) IsInstanceFailed(instance *v1beta1.ServiceInstance) bool

IsInstanceFailed returns if the instance is in the Failed status.

func (*SDK) IsInstanceReady

func (sdk *SDK) IsInstanceReady(instance *v1beta1.ServiceInstance) bool

IsInstanceReady returns if the instance is in the Ready status.

func (*SDK) Provision

func (sdk *SDK) Provision(instanceName, classKubeName, planKubeName string, provisionClusterInstance bool, opts *ProvisionOptions) (*v1beta1.ServiceInstance, error)

Provision creates an instance of a specific service class and plan specified by their k8s names. Depending on provisionClusterInstance, it will create either an instance of a cluster class/plan or a namespaced class/plan

func (*SDK) Register

func (sdk *SDK) Register(brokerName string, url string, opts *RegisterOptions, scopeOpts *ScopeOptions) (Broker, error)

Register creates a broker

func (*SDK) RemoveBindingFinalizerByInstance added in v0.1.43

func (sdk *SDK) RemoveBindingFinalizerByInstance(ns, name string) ([]types.NamespacedName, error)

RemoveBindingFinalizerByInstance removes v1beta1.FinalizerServiceCatalog from all bindings for the specified instance.

func (*SDK) RemoveFinalizerForBinding added in v0.1.43

func (sdk *SDK) RemoveFinalizerForBinding(namespacedName types.NamespacedName) error

RemoveFinalizerForBinding removes the finalizer for a single binding

func (*SDK) RemoveFinalizerForBindings added in v0.1.43

func (sdk *SDK) RemoveFinalizerForBindings(bindings []types.NamespacedName) ([]types.NamespacedName, error)

RemoveFinalizerForBindings removes the finalizer for the provided list of bindings

func (*SDK) RemoveFinalizerForInstance added in v0.2.0

func (sdk *SDK) RemoveFinalizerForInstance(ns, name string) error

RemoveFinalizerForInstance removes v1beta1.FinalizerServiceCatalog from the specified instance.

func (*SDK) RetrieveBinding

func (sdk *SDK) RetrieveBinding(ns, name string) (*v1beta1.ServiceBinding, error)

RetrieveBinding gets a binding by its name.

func (*SDK) RetrieveBindings

func (sdk *SDK) RetrieveBindings(ns string) (*v1beta1.ServiceBindingList, error)

RetrieveBindings lists all bindings in a namespace.

func (*SDK) RetrieveBindingsByInstance

func (sdk *SDK) RetrieveBindingsByInstance(instance *v1beta1.ServiceInstance,
) ([]v1beta1.ServiceBinding, error)

RetrieveBindingsByInstance gets all child bindings for an instance.

func (*SDK) RetrieveBrokerByClass

func (sdk *SDK) RetrieveBrokerByClass(class *v1beta1.ClusterServiceClass,
) (*v1beta1.ClusterServiceBroker, error)

RetrieveBrokerByClass gets the parent broker of a class.

func (*SDK) RetrieveBrokerByID added in v0.1.43

func (sdk *SDK) RetrieveBrokerByID(kubeName string, opts ScopeOptions) (Broker, error)

RetrieveBrokerByID gets a broker by its k8s name

func (*SDK) RetrieveBrokers

func (sdk *SDK) RetrieveBrokers(opts ScopeOptions) ([]Broker, error)

RetrieveBrokers lists all brokers defined in the cluster.

func (*SDK) RetrieveClassByID

func (sdk *SDK) RetrieveClassByID(kubeName string, opts ScopeOptions) (Class, error)

RetrieveClassByID gets a class by its Kubernetes name.

func (*SDK) RetrieveClassByName

func (sdk *SDK) RetrieveClassByName(name string, opts ScopeOptions) (Class, error)

RetrieveClassByName gets a class by its external name.

func (*SDK) RetrieveClassByPlan

func (sdk *SDK) RetrieveClassByPlan(plan Plan) (Class, error)

RetrieveClassByPlan gets the class associated to a plan.

func (*SDK) RetrieveClasses

func (sdk *SDK) RetrieveClasses(opts ScopeOptions) ([]Class, error)

RetrieveClasses lists all classes defined in the cluster.

func (*SDK) RetrieveInstance

func (sdk *SDK) RetrieveInstance(ns, name string) (*v1beta1.ServiceInstance, error)

RetrieveInstance gets an instance by its name.

func (*SDK) RetrieveInstanceByBinding

func (sdk *SDK) RetrieveInstanceByBinding(b *v1beta1.ServiceBinding,
) (*v1beta1.ServiceInstance, error)

RetrieveInstanceByBinding retrieves the parent instance for a binding.

func (*SDK) RetrieveInstances

func (sdk *SDK) RetrieveInstances(ns, classFilter, planFilter string) (*v1beta1.ServiceInstanceList, error)

RetrieveInstances lists all instances in a namespace.

func (*SDK) RetrieveInstancesByPlan

func (sdk *SDK) RetrieveInstancesByPlan(plan Plan) ([]v1beta1.ServiceInstance, error)

RetrieveInstancesByPlan retrieves all instances of a plan.

func (*SDK) RetrievePlanByClassAndName added in v0.1.36

func (sdk *SDK) RetrievePlanByClassAndName(className, planName string, opts ScopeOptions) (Plan, error)

RetrievePlanByClassAndName gets a plan by its external name and class name combination.

func (*SDK) RetrievePlanByClassIDAndName added in v0.1.39

func (sdk *SDK) RetrievePlanByClassIDAndName(classKubeName, planName string, scopeOpts ScopeOptions) (Plan, error)

RetrievePlanByClassIDAndName gets a plan by its external name and class kube name combination.

func (*SDK) RetrievePlanByID

func (sdk *SDK) RetrievePlanByID(kubeName string, opts ScopeOptions) (Plan, error)

RetrievePlanByID gets a plan by its Kubernetes name.

func (*SDK) RetrievePlanByName

func (sdk *SDK) RetrievePlanByName(name string, opts ScopeOptions) (Plan, error)

RetrievePlanByName gets a plan by its external name.

func (*SDK) RetrievePlans

func (sdk *SDK) RetrievePlans(classID string, opts ScopeOptions) ([]Plan, error)

RetrievePlans lists all plans defined in the cluster.

func (*SDK) RetrieveSecretByBinding

func (sdk *SDK) RetrieveSecretByBinding(binding *v1beta1.ServiceBinding) (*corev1.Secret, error)

RetrieveSecretByBinding gets the secret associated with a binding A nil secret is returned without error when the secret has not been created by Service Catalog yet. An error is returned when the binding is Ready but the secret could not be retrieved.

func (*SDK) ServerVersion

func (sdk *SDK) ServerVersion() (*version.Info, error)

ServerVersion asks the Service Catalog API Server for the version.Info object and returns it.

func (*SDK) ServiceCatalog

func (sdk *SDK) ServiceCatalog() v1beta1.ServicecatalogV1beta1Interface

ServiceCatalog is the underlying generated Service Catalog versioned interface It should be used instead of accessing the client directly.

func (*SDK) Sync

func (sdk *SDK) Sync(name string, scopeOpts ScopeOptions, retries int) error

Sync or relist a broker to refresh its broker metadata.

func (*SDK) TouchInstance

func (sdk *SDK) TouchInstance(ns, name string, retries int) error

TouchInstance increments the updateRequests field on an instance to make service process it again (might be an update, delete, or noop)

func (*SDK) Unbind

func (sdk *SDK) Unbind(ns, instanceName string) ([]types.NamespacedName, error)

Unbind deletes all bindings associated to an instance.

func (*SDK) WaitForBinding

func (sdk *SDK) WaitForBinding(ns, name string, interval time.Duration, timeout *time.Duration) (binding *v1beta1.ServiceBinding, err error)

WaitForBinding waits for the instance to complete the current operation (or fail).

func (*SDK) WaitForBroker added in v0.1.32

func (sdk *SDK) WaitForBroker(name string, opts *ScopeOptions, interval time.Duration, timeout *time.Duration) (broker Broker, err error)

WaitForBroker waits for the specified broker to be Ready or Failed

func (*SDK) WaitForInstance

func (sdk *SDK) WaitForInstance(ns, name string, interval time.Duration, timeout *time.Duration) (instance *v1beta1.ServiceInstance, err error)

WaitForInstance waits for the instance to complete the current operation (or fail).

func (*SDK) WaitForInstanceToNotExist

func (sdk *SDK) WaitForInstanceToNotExist(ns, name string, interval time.Duration, timeout *time.Duration) (instance *v1beta1.ServiceInstance, err error)

WaitForInstanceToNotExist waits for the specified instance to no longer exist.

type Scope

type Scope string

Scope is an enum that represents filtering resources by their scope (cluster vs. namespace).

func (Scope) Matches

func (s Scope) Matches(value Scope) bool

Matches determines if a particular value is included in the scope.

type ScopeOptions

type ScopeOptions struct {
	Namespace string
	Scope     Scope
}

ScopeOptions allows for filtering results based on it's namespace and scope (cluster vs. namespaced).

type SvcatClient

type SvcatClient interface {
	Bind(string, string, string, string, string, interface{}, map[string]string) (*apiv1beta1.ServiceBinding, error)
	BindingParentHierarchy(*apiv1beta1.ServiceBinding) (*apiv1beta1.ServiceInstance, *apiv1beta1.ClusterServiceClass, *apiv1beta1.ClusterServicePlan, *apiv1beta1.ClusterServiceBroker, error)
	DeleteBinding(string, string) error
	DeleteBindings([]types.NamespacedName) ([]types.NamespacedName, error)
	IsBindingFailed(*apiv1beta1.ServiceBinding) bool
	IsBindingReady(*apiv1beta1.ServiceBinding) bool
	RetrieveBinding(string, string) (*apiv1beta1.ServiceBinding, error)
	RetrieveBindings(string) (*apiv1beta1.ServiceBindingList, error)
	RetrieveBindingsByInstance(*apiv1beta1.ServiceInstance) ([]apiv1beta1.ServiceBinding, error)
	Unbind(string, string) ([]types.NamespacedName, error)
	WaitForBinding(string, string, time.Duration, *time.Duration) (*apiv1beta1.ServiceBinding, error)
	RemoveBindingFinalizerByInstance(string, string) ([]types.NamespacedName, error)
	RemoveFinalizerForBindings([]types.NamespacedName) ([]types.NamespacedName, error)
	RemoveFinalizerForBinding(types.NamespacedName) error
	RemoveFinalizerForInstance(string, string) error

	Deregister(string, *ScopeOptions) error
	RetrieveBrokers(opts ScopeOptions) ([]Broker, error)
	RetrieveBrokerByID(string, ScopeOptions) (Broker, error)
	RetrieveBrokerByClass(*apiv1beta1.ClusterServiceClass) (*apiv1beta1.ClusterServiceBroker, error)
	Register(string, string, *RegisterOptions, *ScopeOptions) (Broker, error)
	Sync(string, ScopeOptions, int) error
	WaitForBroker(string, *ScopeOptions, time.Duration, *time.Duration) (Broker, error)

	RetrieveClasses(ScopeOptions) ([]Class, error)
	RetrieveClassByName(string, ScopeOptions) (Class, error)
	RetrieveClassByID(string, ScopeOptions) (Class, error)
	RetrieveClassByPlan(Plan) (Class, error)
	CreateClassFrom(CreateClassFromOptions) (Class, error)

	Deprovision(string, string) error
	InstanceParentHierarchy(*apiv1beta1.ServiceInstance) (*apiv1beta1.ClusterServiceClass, *apiv1beta1.ClusterServicePlan, *apiv1beta1.ClusterServiceBroker, error)
	InstanceToServiceClassAndPlan(*apiv1beta1.ServiceInstance) (*apiv1beta1.ClusterServiceClass, *apiv1beta1.ClusterServicePlan, error)
	IsInstanceFailed(*apiv1beta1.ServiceInstance) bool
	IsInstanceReady(*apiv1beta1.ServiceInstance) bool
	Provision(string, string, string, bool, *ProvisionOptions) (*apiv1beta1.ServiceInstance, error)
	RetrieveInstance(string, string) (*apiv1beta1.ServiceInstance, error)
	RetrieveInstanceByBinding(*apiv1beta1.ServiceBinding) (*apiv1beta1.ServiceInstance, error)
	RetrieveInstances(string, string, string) (*apiv1beta1.ServiceInstanceList, error)
	RetrieveInstancesByPlan(Plan) ([]apiv1beta1.ServiceInstance, error)
	TouchInstance(string, string, int) error
	WaitForInstance(string, string, time.Duration, *time.Duration) (*apiv1beta1.ServiceInstance, error)
	WaitForInstanceToNotExist(string, string, time.Duration, *time.Duration) (*apiv1beta1.ServiceInstance, error)

	RetrievePlans(string, ScopeOptions) ([]Plan, error)
	RetrievePlanByName(string, ScopeOptions) (Plan, error)
	RetrievePlanByClassAndName(string, string, ScopeOptions) (Plan, error)
	RetrievePlanByClassIDAndName(string, string, ScopeOptions) (Plan, error)
	RetrievePlanByID(string, ScopeOptions) (Plan, error)

	RetrieveSecretByBinding(*apiv1beta1.ServiceBinding) (*apicorev1.Secret, error)

	ServerVersion() (*version.Info, error)
}

SvcatClient is an interface containing the various actions in the svcat pkg lib This interface is then faked with Counterfeiter for the cmd/svcat unit tests

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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