Documentation ¶
Index ¶
- Variables
- func BrokerService() (serviceTypes.ServiceBrokerService, error)
- func CatalogCacheService() (service.ServiceBrokerCatalogCacheService, error)
- func Create(s Service) error
- func CreateServiceInstance(ctx context.Context, instance ServiceInstance, service *Service, ...) error
- func Delete(s Service) error
- func DeleteInstance(ctx context.Context, si *ServiceInstance, evt *event.Event, requestID string) error
- func Proxy(ctx context.Context, service *Service, path string, evt *event.Event, ...) error
- func ProxyInstance(ctx context.Context, instance *ServiceInstance, path string, evt *event.Event, ...) error
- func RenameServiceInstanceTeam(ctx context.Context, oldName, newName string) error
- func RenameServiceTeam(ctx context.Context, oldName, newName string) error
- func Update(s Service) error
- type BindAppParameters
- type BrokerInstanceBind
- type BrokerInstanceData
- type Plan
- type ProxyOpts
- type Service
- func Get(ctx context.Context, service string) (Service, error)
- func GetServices(ctx context.Context) ([]Service, error)
- func GetServicesByOwnerTeamsAndServices(ctx context.Context, teams []string, services []string) ([]Service, error)
- func GetServicesByTeamsAndServices(ctx context.Context, teams []string, services []string) ([]Service, error)
- type ServiceClient
- type ServiceInstance
- func GetServiceInstance(ctx context.Context, serviceName string, instanceName string) (*ServiceInstance, error)
- func GetServiceInstancesBoundToApp(appName string) ([]ServiceInstance, error)
- func GetServiceInstancesBoundToJob(jobName string) ([]ServiceInstance, error)
- func GetServiceInstancesByServices(services []Service) ([]ServiceInstance, error)
- func GetServicesInstancesByTeamsAndNames(teams []string, names []string, appName, serviceName string) ([]ServiceInstance, error)
- func (si *ServiceInstance) BindApp(app bind.App, params BindAppParameters, shouldRestart bool, writer io.Writer, ...) error
- func (si *ServiceInstance) BindJob(job *jobTypes.Job, writer io.Writer, evt *event.Event, requestID string) error
- func (si *ServiceInstance) FindApp(appName string) int
- func (si *ServiceInstance) FindJob(jobName string) int
- func (si *ServiceInstance) GetIdentifier() string
- func (si *ServiceInstance) Grant(teamName string) error
- func (si *ServiceInstance) Info(requestID string) (map[string]string, error)
- func (si *ServiceInstance) Revoke(teamName string) error
- func (si *ServiceInstance) Status(requestID string) (string, error)
- func (si *ServiceInstance) ToInfo() (ServiceInstanceWithInfo, error)
- func (si *ServiceInstance) UnbindApp(unbindArgs UnbindAppArgs) error
- func (si *ServiceInstance) UnbindJob(unbindArgs UnbindJobArgs) error
- func (si *ServiceInstance) Update(service Service, updateData ServiceInstance, evt *event.Event, ...) error
- type ServiceInstanceWithInfo
- type ServiceModel
- type UnbindAppArgs
- type UnbindJobArgs
Constants ¶
This section is empty.
Variables ¶
var ( ErrInstanceAlreadyExistsInAPI = errors.New("instance already exists in the service API") ErrInstanceNotFoundInAPI = errors.New("instance does not exist in the service API") ErrInstanceNotReady = errors.New("instance is not ready yet") )
var ( ErrServiceAlreadyExists = errors.New("Service already exists.") ErrServiceNotFound = errors.New("Service not found.") ErrMissingPool = errors.New("Missing pool") )
var ( ErrServiceInstanceNotFound = errors.New("service instance not found") ErrInvalidInstanceName = errors.New("invalid service instance name") ErrInstanceNameAlreadyExists = errors.New("instance name already exists.") ErrAccessNotAllowed = errors.New("user does not have access to this service instance") ErrTeamMandatory = errors.New("please specify the team that owns the service instance") ErrAppAlreadyBound = errors.New("app is already bound to this service instance") ErrJobAlreadyBound = errors.New("job is already bound to this service instance") ErrAppNotBound = errors.New("app is not bound to this service instance") ErrJobNotBound = errors.New("job is not bound to this service instance") ErrUnitNotBound = errors.New("unit is not bound to this service instance") ErrServiceInstanceBound = errors.New("This service instance is bound to at least one app. Unbind them before removing it") ErrMultiClusterServiceRequiresPool = errors.New("multi-cluster service instance requires a pool") ErrMultiClusterViolatingConstraint = errors.New("multi-cluster service instance is not allowed in this pool") ErrMultiClusterPoolDoesNotMatch = errors.New("pools between app and multi-cluster service instance does not match") ErrRegularServiceInstanceCannotBelongToPool = errors.New("regular (non-multi-cluster) service instance cannot belong to a pool") ErrRevokeInstanceTeamOwnerAccess = errors.New("cannot revoke the instance's team owner access") )
var ClientFactory = func(config *osb.ClientConfiguration) (osb.Client, error) { return osb.NewClient(config) }
ClientFactory provides a way to customize the Open Service Broker API client. Should be used in tests to create a fake client.
var ErrInvalidBrokerData = errors.New("Invalid broker data")
Functions ¶
func BrokerService ¶
func BrokerService() (serviceTypes.ServiceBrokerService, error)
func CatalogCacheService ¶
func CatalogCacheService() (service.ServiceBrokerCatalogCacheService, error)
func CreateServiceInstance ¶
func DeleteInstance ¶
func DeleteInstance(ctx context.Context, si *ServiceInstance, evt *event.Event, requestID string) error
DeleteInstance deletes the service instance from the database.
func Proxy ¶
func Proxy(ctx context.Context, service *Service, path string, evt *event.Event, requestID string, w http.ResponseWriter, r *http.Request) error
Proxy is a proxy between tsuru and the service. This method allow customized service methods.
func ProxyInstance ¶
func ProxyInstance(ctx context.Context, instance *ServiceInstance, path string, evt *event.Event, requestID string, w http.ResponseWriter, r *http.Request) error
ProxyInstance is a proxy between tsuru and the service instance. This method allow customized service instance methods.
Types ¶
type BindAppParameters ¶
type BindAppParameters map[string]interface{}
type BrokerInstanceBind ¶
type BrokerInstanceData ¶
type ProxyOpts ¶
type ProxyOpts struct { Instance *ServiceInstance Path string Event *event.Event RequestID string Writer http.ResponseWriter Request *http.Request }
type Service ¶
type Service struct { Name string `bson:"_id"` Username string Password string Endpoint map[string]string OwnerTeams []string `bson:"owner_teams"` Teams []string Doc string IsRestricted bool `bson:"is_restricted"` // IsMultiCluster indicates whether Service Instances (children of this Service) // run within the user's Cluster (same pool of Tsuru Apps). When enabled, creating // a Service Instance must require a valid Pool. // // This field is immutable (after creating Service). IsMultiCluster bool `bson:"is_multi_cluster"` // contains filtered or unexported fields }
type ServiceClient ¶
type ServiceClient interface { Create(ctx context.Context, instance *ServiceInstance, evt *event.Event, requestID string) error Update(ctx context.Context, instance *ServiceInstance, evt *event.Event, requestID string) error Destroy(ctx context.Context, instance *ServiceInstance, evt *event.Event, requestID string) error BindApp(ctx context.Context, instance *ServiceInstance, app bind.App, params BindAppParameters, evt *event.Event, requestID string) (map[string]string, error) BindJob(ctx context.Context, instance *ServiceInstance, job *jobTypes.Job, evt *event.Event, requestID string) (map[string]string, error) UnbindApp(ctx context.Context, instance *ServiceInstance, app bind.App, evt *event.Event, requestID string) error UnbindJob(ctx context.Context, instance *ServiceInstance, job *jobTypes.Job, evt *event.Event, requestID string) error Status(ctx context.Context, instance *ServiceInstance, requestID string) (string, error) Info(ctx context.Context, instance *ServiceInstance, requestID string) ([]map[string]string, error) Plans(ctx context.Context, pool, requestID string) ([]Plan, error) Proxy(ctx context.Context, opts *ProxyOpts) error }
TODO: use requestID inside the context
type ServiceInstance ¶
type ServiceInstance struct { Name string `json:"name"` Id int `json:"id"` ServiceName string `bson:"service_name" json:"service_name"` PlanName string `bson:"plan_name" json:"plan_name"` Apps []string `json:"apps"` Jobs []string `json:"jobs"` Teams []string `json:"teams"` TeamOwner string `json:"team_owner"` Description string `json:"description"` Tags []string `json:"tags"` Parameters map[string]interface{} `json:"parameters,omitempty"` // Pool is the pool name which the Service Instance should run into. // This field is mandatory iff the parent Service is running in // multi-cluster mode (see Service.IsMultiCluster field) // // NOTE: after the service instance is created, this field turns immutable. Pool string `json:"pool,omitempty"` // BrokerData stores data used by Instances provisioned by Brokers BrokerData *BrokerInstanceData `json:"broker_data,omitempty" bson:"broker_data"` // ForceRemove indicates whether service instance should be removed even the // related call to service API fails. ForceRemove bool `bson:"-" json:"-"` // contains filtered or unexported fields }
func GetServiceInstance ¶
func GetServiceInstancesBoundToApp ¶
func GetServiceInstancesBoundToApp(appName string) ([]ServiceInstance, error)
func GetServiceInstancesBoundToJob ¶
func GetServiceInstancesBoundToJob(jobName string) ([]ServiceInstance, error)
func GetServiceInstancesByServices ¶
func GetServiceInstancesByServices(services []Service) ([]ServiceInstance, error)
func GetServicesInstancesByTeamsAndNames ¶
func GetServicesInstancesByTeamsAndNames(teams []string, names []string, appName, serviceName string) ([]ServiceInstance, error)
func (*ServiceInstance) BindApp ¶
func (si *ServiceInstance) BindApp(app bind.App, params BindAppParameters, shouldRestart bool, writer io.Writer, evt *event.Event, requestID string) error
BindApp makes the bind between the service instance and an app.
func (*ServiceInstance) BindJob ¶
func (si *ServiceInstance) BindJob(job *jobTypes.Job, writer io.Writer, evt *event.Event, requestID string) error
BindJob makes the bind between the service instance and a job.
func (*ServiceInstance) FindApp ¶
func (si *ServiceInstance) FindApp(appName string) int
func (*ServiceInstance) FindJob ¶
func (si *ServiceInstance) FindJob(jobName string) int
func (*ServiceInstance) GetIdentifier ¶
func (si *ServiceInstance) GetIdentifier() string
func (*ServiceInstance) Grant ¶
func (si *ServiceInstance) Grant(teamName string) error
func (*ServiceInstance) Info ¶
func (si *ServiceInstance) Info(requestID string) (map[string]string, error)
func (*ServiceInstance) Revoke ¶
func (si *ServiceInstance) Revoke(teamName string) error
func (*ServiceInstance) Status ¶
func (si *ServiceInstance) Status(requestID string) (string, error)
Status returns the service instance status.
func (*ServiceInstance) ToInfo ¶
func (si *ServiceInstance) ToInfo() (ServiceInstanceWithInfo, error)
ToInfo returns the service instance as a struct compatible with the return of the service info api call.
func (*ServiceInstance) UnbindApp ¶
func (si *ServiceInstance) UnbindApp(unbindArgs UnbindAppArgs) error
UnbindApp makes the unbind between the service instance and an app.
func (*ServiceInstance) UnbindJob ¶
func (si *ServiceInstance) UnbindJob(unbindArgs UnbindJobArgs) error
UnbindJob makes the unbind between the service instance and a job.
func (*ServiceInstance) Update ¶
func (si *ServiceInstance) Update(service Service, updateData ServiceInstance, evt *event.Event, requestID string) error
Update changes informations of the service instance.
type ServiceInstanceWithInfo ¶
type ServiceModel ¶
type ServiceModel struct { Service string `json:"service"` Instances []string `json:"instances"` Plans []string `json:"plans"` ServiceInstances []ServiceInstance `json:"service_instances"` }