Documentation
¶
Index ¶
- func BindService(app *v1alpha1.App, binding *v1alpha1.AppSpecServiceBinding)
- func UnbindService(app *v1alpha1.App, bindingName string)
- type Client
- func (c *Client) Create(serviceInstanceName, appName string, opts ...CreateOption) (*v1alpha1.AppSpecServiceBinding, error)
- func (c *Client) Delete(serviceInstanceName, appName string, opts ...DeleteOption) error
- func (c *Client) List(opts ...ListOption) ([]servicecatalogv1beta1.ServiceBinding, error)
- func (c *Client) WaitForBindings(ctx context.Context, namespace, appName string) error
- type ClientInterface
- type CreateOption
- type CreateOptions
- type DeleteOption
- type DeleteOptions
- type ListOption
- type ListOptions
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindService ¶
func BindService(app *v1alpha1.App, binding *v1alpha1.AppSpecServiceBinding)
BindService binds a service to an App.
Example ¶
package main
import (
"fmt"
kfv1alpha1 "github.com/google/kf/pkg/apis/kf/v1alpha1"
servicebindings "github.com/google/kf/pkg/kf/service-bindings"
)
func main() {
myApp := &kfv1alpha1.App{}
servicebindings.BindService(myApp, &kfv1alpha1.AppSpecServiceBinding{
Instance: "some-service",
BindingName: "some-binding-name",
})
servicebindings.BindService(myApp, &kfv1alpha1.AppSpecServiceBinding{
Instance: "another-service",
BindingName: "some-binding-name",
})
servicebindings.BindService(myApp, &kfv1alpha1.AppSpecServiceBinding{
Instance: "third-service",
BindingName: "third",
})
servicebindings.BindService(myApp, &kfv1alpha1.AppSpecServiceBinding{
Instance: "forth-service",
BindingName: "forth",
})
servicebindings.UnbindService(myApp, "third")
for _, b := range myApp.Spec.ServiceBindings {
fmt.Println("Instance", b.Instance, "BindingName", b.BindingName)
}
}
Output: Instance another-service BindingName some-binding-name Instance forth-service BindingName forth
func UnbindService ¶
UnbindService unbinds a service from an App.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Create ¶
func (c *Client) Create(serviceInstanceName, appName string, opts ...CreateOption) (*v1alpha1.AppSpecServiceBinding, error)
Create binds a service instance to an app.
func (*Client) Delete ¶
func (c *Client) Delete(serviceInstanceName, appName string, opts ...DeleteOption) error
Delete unbinds a service instance from an app.
func (*Client) List ¶
func (c *Client) List(opts ...ListOption) ([]servicecatalogv1beta1.ServiceBinding, error)
List queries Kubernetes for service bindings.
type ClientInterface ¶
type ClientInterface interface {
// Create binds a service instance to an app.
Create(serviceInstanceName, appName string, opts ...CreateOption) (*v1alpha1.AppSpecServiceBinding, error)
// Delete removes a service binding from an app.
Delete(serviceInstanceName, appName string, opts ...DeleteOption) error
// List queries Kubernetes for service bindings.
List(opts ...ListOption) ([]servicecatalogv1beta1.ServiceBinding, error)
WaitForBindings(ctx context.Context, namespace, appName string) error
}
ClientInterface is a client capable of interacting with service catalog services and mapping the CF to Kubernetes concepts.
func NewClient ¶
func NewClient(appsClient apps.Client, svcatClient servicecatalogclient.Interface) ClientInterface
NewClient creates a new client capable of interacting with service catalog services.
type CreateOption ¶
type CreateOption func(*createConfig)
CreateOption is a single option for configuring a createConfig
func WithCreateBindingName ¶
func WithCreateBindingName(val string) CreateOption
WithCreateBindingName creates an Option that sets name to expose service instance to app process with.
func WithCreateNamespace ¶
func WithCreateNamespace(val string) CreateOption
WithCreateNamespace creates an Option that sets the Kubernetes namespace to use.
func WithCreateParams ¶
func WithCreateParams(val map[string]interface{}) CreateOption
WithCreateParams creates an Option that sets service-specific configuration parameters.
type CreateOptions ¶
type CreateOptions []CreateOption
CreateOptions is a configuration set defining a createConfig
func CreateOptionDefaults ¶
func CreateOptionDefaults() CreateOptions
CreateOptionDefaults gets the default values for Create.
func (CreateOptions) BindingName ¶
func (opts CreateOptions) BindingName() string
BindingName returns the last set value for BindingName or the empty value if not set.
func (CreateOptions) Extend ¶
func (opts CreateOptions) Extend(other CreateOptions) CreateOptions
Extend creates a new CreateOptions with the contents of other overriding the values set in this CreateOptions.
func (CreateOptions) Namespace ¶
func (opts CreateOptions) Namespace() string
Namespace returns the last set value for Namespace or the empty value if not set.
func (CreateOptions) Params ¶
func (opts CreateOptions) Params() map[string]interface{}
Params returns the last set value for Params or the empty value if not set.
type DeleteOption ¶
type DeleteOption func(*deleteConfig)
DeleteOption is a single option for configuring a deleteConfig
func WithDeleteNamespace ¶
func WithDeleteNamespace(val string) DeleteOption
WithDeleteNamespace creates an Option that sets the Kubernetes namespace to use.
type DeleteOptions ¶
type DeleteOptions []DeleteOption
DeleteOptions is a configuration set defining a deleteConfig
func DeleteOptionDefaults ¶
func DeleteOptionDefaults() DeleteOptions
DeleteOptionDefaults gets the default values for Delete.
func (DeleteOptions) Extend ¶
func (opts DeleteOptions) Extend(other DeleteOptions) DeleteOptions
Extend creates a new DeleteOptions with the contents of other overriding the values set in this DeleteOptions.
func (DeleteOptions) Namespace ¶
func (opts DeleteOptions) Namespace() string
Namespace returns the last set value for Namespace or the empty value if not set.
type ListOption ¶
type ListOption func(*listConfig)
ListOption is a single option for configuring a listConfig
func WithListAppName ¶
func WithListAppName(val string) ListOption
WithListAppName creates an Option that sets filter the results to bindings for the given app.
func WithListNamespace ¶
func WithListNamespace(val string) ListOption
WithListNamespace creates an Option that sets the Kubernetes namespace to use.
func WithListServiceInstance ¶
func WithListServiceInstance(val string) ListOption
WithListServiceInstance creates an Option that sets filter the results to bindings for the given service instance.
type ListOptions ¶
type ListOptions []ListOption
ListOptions is a configuration set defining a listConfig
func ListOptionDefaults ¶
func ListOptionDefaults() ListOptions
ListOptionDefaults gets the default values for List.
func (ListOptions) AppName ¶
func (opts ListOptions) AppName() string
AppName returns the last set value for AppName or the empty value if not set.
func (ListOptions) Extend ¶
func (opts ListOptions) Extend(other ListOptions) ListOptions
Extend creates a new ListOptions with the contents of other overriding the values set in this ListOptions.
func (ListOptions) Namespace ¶
func (opts ListOptions) Namespace() string
Namespace returns the last set value for Namespace or the empty value if not set.
func (ListOptions) ServiceInstance ¶
func (opts ListOptions) ServiceInstance() string
ServiceInstance returns the last set value for ServiceInstance or the empty value if not set.