service

package
v0.0.0-...-1b7c243 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: BSD-3-Clause Imports: 31 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 (
	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 (
	ErrServiceAlreadyExists = errors.New("Service already exists.")
)

Functions

func CreateServiceInstance

func CreateServiceInstance(instance ServiceInstance, service *Service, user *auth.User, requestID string) error

func DeleteInstance

func DeleteInstance(si *ServiceInstance, requestID string) error

DeleteInstance deletes the service instance from the database.

func GetServicesNames

func GetServicesNames(services []Service) []string

func InitializeSync

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

func Proxy

func Proxy(service *Service, path string, w http.ResponseWriter, r *http.Request) error

Proxy is a proxy between tsuru and the service. This method allow customized service methods.

func RenameServiceInstanceTeam

func RenameServiceInstanceTeam(oldName, newName string) error

func RenameServiceTeam

func RenameServiceTeam(oldName, newName string) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) BindApp

func (c *Client) BindApp(instance *ServiceInstance, app bind.App) (map[string]string, error)

func (*Client) BindUnit

func (c *Client) BindUnit(instance *ServiceInstance, app bind.App, unit bind.Unit) error

func (*Client) Create

func (c *Client) Create(instance *ServiceInstance, user, requestID string) error

func (*Client) Destroy

func (c *Client) Destroy(instance *ServiceInstance, requestID string) error

func (*Client) Info

func (c *Client) Info(instance *ServiceInstance, requestID string) ([]map[string]string, error)

Info returns the additional info about a service instance. The api should be prepared to receive the request, like below: GET /resources/<name>

func (*Client) Plans

func (c *Client) Plans(requestID string) ([]Plan, error)

Plans returns the service plans. The api should be prepared to receive the request, like below: GET /resources/plans

func (*Client) Proxy

func (c *Client) Proxy(path string, w http.ResponseWriter, r *http.Request) error

Proxy is a proxy between tsuru and the service. This method allow customized service methods.

func (*Client) Status

func (c *Client) Status(instance *ServiceInstance, requestID string) (string, error)

func (*Client) UnbindApp

func (c *Client) UnbindApp(instance *ServiceInstance, app bind.App) error

func (*Client) UnbindUnit

func (c *Client) UnbindUnit(instance *ServiceInstance, app bind.App, unit bind.Unit) error

func (*Client) Update

func (c *Client) Update(instance *ServiceInstance, requestID string) error

type Plan

type Plan struct {
	Name        string
	Description string
}

Plan represents a service plan

func GetPlanByServiceNameAndPlanName

func GetPlanByServiceNameAndPlanName(serviceName, planName, requestID string) (Plan, error)

func GetPlansByServiceName

func GetPlansByServiceName(serviceName, 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 GetServicesByFilter

func GetServicesByFilter(filter bson.M) ([]Service, error)

func GetServicesByOwnerTeamsAndServices

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

func GetServicesByTeamsAndServices

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

func (*Service) Create

func (s *Service) Create() error

func (*Service) Delete

func (s *Service) Delete() error

func (*Service) Get

func (s *Service) Get() error

func (*Service) GetUsername

func (s *Service) GetUsername() string

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

func (*Service) Update

func (s *Service) Update() error

type ServiceInstance

type ServiceInstance struct {
	Name        string
	Id          int
	ServiceName string `bson:"service_name"`
	PlanName    string `bson:"plan_name"`
	Apps        []string
	BoundUnits  []Unit `bson:"bound_units"`
	Teams       []string
	TeamOwner   string
	Description string
	Tags        []string
}

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, shouldRestart bool, writer io.Writer) 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) MarshalJSON

func (si *ServiceInstance) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ServiceName in json format.

func (*ServiceInstance) Revoke

func (si *ServiceInstance) Revoke(teamName string) error

func (*ServiceInstance) Service

func (si *ServiceInstance) Service() *Service

func (*ServiceInstance) Status

func (si *ServiceInstance) Status(requestID string) (string, error)

Status returns the service instance status.

func (*ServiceInstance) UnbindApp

func (si *ServiceInstance) UnbindApp(app bind.App, shouldRestart bool, writer io.Writer) 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, requestID string) error

Update changes informations of the service instance.

type ServiceInstanceModel

type ServiceInstanceModel struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

type ServiceModel

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

type Unit

type Unit struct {
	AppName, ID, IP string
}

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