service

package
v0.0.0-...-9451de5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var (
	ErrServiceAlreadyExists = errors.New("Service already exists.")
	ErrServiceNotFound      = errors.New("Service not found.")
)
View Source
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")
	ErrAppNotBound               = errors.New("app 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")
)
View Source
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.

View Source
var ErrInvalidBrokerData = errors.New("Invalid broker data")

Functions

func BrokerService

func BrokerService() (serviceTypes.ServiceBrokerService, error)

func Create

func Create(s Service) error

func CreateServiceInstance

func CreateServiceInstance(instance ServiceInstance, service *Service, evt *event.Event, requestID string) error

func Delete

func Delete(s Service) error

func DeleteInstance

func DeleteInstance(si *ServiceInstance, evt *event.Event, requestID string) error

DeleteInstance deletes the service instance from the database.

func InitializeSync

func InitializeSync(appLister func() ([]bind.App, error)) error

func Proxy

func Proxy(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(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.

func RenameServiceInstanceTeam

func RenameServiceInstanceTeam(oldName, newName string) error

func RenameServiceTeam

func RenameServiceTeam(oldName, newName string) error

func Update

func Update(s Service) error

Types

type BindAppParameters

type BindAppParameters map[string]interface{}

type BrokerInstanceBind

type BrokerInstanceBind struct {
	// UUID is a v4 UUID generated when binding
	UUID         string
	OperationKey string
	Parameters   map[string]interface{}
}

type BrokerInstanceData

type BrokerInstanceData struct {
	// UUID is a v4 UUID generated for this Instance on creation
	UUID             string
	ServiceID        string
	PlanID           string
	OrgID            string
	SpaceID          string
	LastOperationKey string

	Binds map[string]BrokerInstanceBind
}

type Plan

type Plan struct {
	Name        string
	Description string
	Schemas     *osb.Schemas `json:",omitempty"`
}

Plan represents a service plan

func GetPlanByServiceAndPlanName

func GetPlanByServiceAndPlanName(svc Service, planName, requestID string) (Plan, error)

func GetPlansByService

func GetPlansByService(svc Service, requestID string) ([]Plan, error)

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"`
}

func Get

func Get(service string) (Service, error)

func GetServices

func GetServices() ([]Service, error)

func GetServicesByOwnerTeamsAndServices

func GetServicesByOwnerTeamsAndServices(teams []string, services []string) ([]Service, error)

func GetServicesByTeamsAndServices

func GetServicesByTeamsAndServices(teams []string, services []string) ([]Service, error)

func (*Service) GrantAccess

func (s *Service) GrantAccess(team *authTypes.Team) error

func (*Service) HasTeam

func (s *Service) HasTeam(team *authTypes.Team) bool

func (*Service) RevokeAccess

func (s *Service) RevokeAccess(team *authTypes.Team) error

type ServiceClient

type ServiceClient interface {
	Create(instance *ServiceInstance, evt *event.Event, requestID string) error
	Update(instance *ServiceInstance, evt *event.Event, requestID string) error
	Destroy(instance *ServiceInstance, evt *event.Event, requestID string) error
	BindApp(instance *ServiceInstance, app bind.App, params BindAppParameters, evt *event.Event, requestID string) (map[string]string, error)
	BindUnit(instance *ServiceInstance, app bind.App, unit bind.Unit) error
	UnbindApp(instance *ServiceInstance, app bind.App, evt *event.Event, requestID string) error
	UnbindUnit(instance *ServiceInstance, app bind.App, unit bind.Unit) error
	Status(instance *ServiceInstance, requestID string) (string, error)
	Info(instance *ServiceInstance, requestID string) ([]map[string]string, error)
	Plans(requestID string) ([]Plan, error)
	Proxy(path string, evt *event.Event, requestID string, w http.ResponseWriter, r *http.Request) error
}

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"`
	BoundUnits  []Unit                 `bson:"bound_units" json:"bound_units"`
	Teams       []string               `json:"teams"`
	TeamOwner   string                 `json:"team_owner"`
	Description string                 `json:"description"`
	Tags        []string               `json:"tags"`
	Parameters  map[string]interface{} `json:"parameters,omitempty"`

	// BrokerData stores data used by Instances provisioned by Brokers
	BrokerData *BrokerInstanceData `json:"broker_data,omitempty" bson:"broker_data"`
}

func GetServiceInstance

func GetServiceInstance(serviceName string, instanceName string) (*ServiceInstance, error)

func GetServiceInstancesBoundToApp

func GetServiceInstancesBoundToApp(appName 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) BindUnit

func (si *ServiceInstance) BindUnit(app bind.App, unit bind.Unit) error

BindUnit makes the bind between the binder and an unit.

func (*ServiceInstance) FindApp

func (si *ServiceInstance) FindApp(appName 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

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) UnbindUnit

func (si *ServiceInstance) UnbindUnit(app bind.App, unit bind.Unit) error

UnbindUnit makes the unbind between the service instance and an unit.

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 ServiceInstanceWithInfo struct {
	Id          int
	Name        string
	Teams       []string
	PlanName    string
	Apps        []string
	ServiceName string
	Info        map[string]string
	TeamOwner   string
}

type ServiceModel

type ServiceModel struct {
	Service          string            `json:"service"`
	Instances        []string          `json:"instances"`
	Plans            []string          `json:"plans"`
	ServiceInstances []ServiceInstance `json:"service_instances"`
}

type UnbindAppArgs

type UnbindAppArgs struct {
	App         bind.App
	Restart     bool
	ForceRemove bool
	Event       *event.Event
	RequestID   string
}

type Unit

type Unit struct {
	AppName string `json:"app_name"`
	ID      string `json:"id"`
	IP      string `json:"ip"`
}

func (Unit) GetID

func (bu Unit) GetID() string

func (Unit) GetIp

func (bu Unit) GetIp() string

Jump to

Keyboard shortcuts

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