app

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 21 Imported by: 36

Documentation

Index

Constants

View Source
const (
	TeresaAnnotation = "teresa.io/app"
	TeresaTeamLabel  = "teresa.io/team"
	TeresaLastUser   = "teresa.io/last-user"
	TeresaAppSecrets = "teresa-secrets"
)
View Source
const (
	ProcessTypeWeb        = "web"
	ProcessTypeCronPrefix = "cron"
)
View Source
const SecretPath = "/teresa/secrets"

Variables

View Source
var (
	ErrAlreadyExists           = status.Errorf(codes.AlreadyExists, "App already exists")
	ErrNotFound                = status.Errorf(codes.NotFound, "App not found")
	ErrProtectedEnvVar         = status.Errorf(codes.InvalidArgument, "Can't change protected env vars")
	ErrInvalidName             = status.Errorf(codes.InvalidArgument, "Invalid App Name")
	ErrInvalidLimits           = status.Errorf(codes.InvalidArgument, "Invalid Limits")
	ErrInvalidAutoscale        = status.Errorf(codes.InvalidArgument, "Invalid Autoscale")
	ErrInvalidEnvVarName       = status.Errorf(codes.InvalidArgument, "Invalid Env Var Name")
	ErrInvalidSecretName       = status.Errorf(codes.InvalidArgument, "Invalid Secret Name")
	ErrInvalidActionForCronJob = status.Errorf(codes.InvalidArgument, "Invalid action for a cronjob app")
	ErrMissingVirtualHost      = status.Errorf(
		codes.InvalidArgument,
		"Missing --vhost or --reserve-static-ip argument with the application domain",
	)
	ErrInvalidBlankVHost = status.Errorf(
		codes.InvalidArgument,
		"Blank vhosts not allowed for cluster with ingress integration",
	)
)

Functions

func IsCronJob added in v0.17.0

func IsCronJob(processType string) bool

func IsWebApp added in v0.27.0

func IsWebApp(processType string) bool

Types

type Address

type Address struct {
	Hostname string
}

type App

type App struct {
	Name            string     `json:"name"`
	Team            string     `json:"-"`
	ProcessType     string     `json:"processType"`
	VirtualHost     string     `json:"virtualHost"`
	Limits          *Limits    `json:"-"`
	Autoscale       *Autoscale `json:"-"`
	EnvVars         []*EnvVar  `json:"envVars"`
	Internal        bool       `json:"internal"`
	ReserveStaticIp bool       `json:"reserveStaticIp"`
	Secrets         []string   `json:"secrets"`
	SecretFiles     []string   `json:"secret_files"`
	Protocol        string     `json:"protocol"`
}

type AppListItem

type AppListItem struct {
	Team      string
	Name      string
	Addresses []*Address
}

type AppOperations

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

func (*AppOperations) ChangeTeam added in v0.10.0

func (ops *AppOperations) ChangeTeam(appName, teamName string) error

ChangeTeam changes current team name of an App (be sure the new team exists)

func (*AppOperations) CheckPermAndGet added in v0.8.0

func (ops *AppOperations) CheckPermAndGet(user *database.User, appName string) (*App, error)

func (*AppOperations) CheckVirtualHostIsMissing added in v0.30.0

func (ops *AppOperations) CheckVirtualHostIsMissing(app *App) (Err error)

func (*AppOperations) Create

func (ops *AppOperations) Create(user *database.User, app *App) (Err error)

func (*AppOperations) Delete added in v0.8.0

func (ops *AppOperations) Delete(user *database.User, appName string) error

func (*AppOperations) DeletePods added in v0.13.0

func (ops *AppOperations) DeletePods(user *database.User, appName string, podsNames []string) error

func (*AppOperations) Get

func (ops *AppOperations) Get(appName string) (*App, error)

func (*AppOperations) HasPermission

func (ops *AppOperations) HasPermission(user *database.User, appName string) bool

func (*AppOperations) Info

func (ops *AppOperations) Info(user *database.User, appName string) (*Info, error)

func (*AppOperations) List

func (ops *AppOperations) List(user *database.User) ([]*AppListItem, error)

func (*AppOperations) ListByTeam added in v0.10.0

func (ops *AppOperations) ListByTeam(teamName string) ([]string, error)

func (*AppOperations) Logs

func (ops *AppOperations) Logs(user *database.User, appName string, opts *LogOptions) (io.ReadCloser, error)

func (*AppOperations) SaveApp added in v0.8.0

func (ops *AppOperations) SaveApp(app *App, lastUser string) error

func (*AppOperations) SetAutoscale added in v0.7.0

func (ops *AppOperations) SetAutoscale(user *database.User, appName string, as *Autoscale) error

func (*AppOperations) SetEnv

func (ops *AppOperations) SetEnv(user *database.User, appName string, evs []*EnvVar) error

func (*AppOperations) SetReplicas added in v0.13.0

func (ops *AppOperations) SetReplicas(user *database.User, appName string, replicas int32) error

func (*AppOperations) SetSecret added in v0.17.0

func (ops *AppOperations) SetSecret(user *database.User, appName string, secrets []*EnvVar) error

func (*AppOperations) SetSecretFile added in v0.25.0

func (ops *AppOperations) SetSecretFile(user *database.User, appName, name string, content []byte) error

func (*AppOperations) SetVHosts added in v0.26.0

func (ops *AppOperations) SetVHosts(user *database.User, appName string, vHosts []string) error

func (*AppOperations) TeamName

func (ops *AppOperations) TeamName(appName string) (string, error)

func (*AppOperations) UnsetEnv

func (ops *AppOperations) UnsetEnv(user *database.User, appName string, evNames []string) error

func (*AppOperations) UnsetSecret added in v0.17.0

func (ops *AppOperations) UnsetSecret(user *database.User, appName string, secrets []string) error

type Autoscale added in v0.7.0

type Autoscale struct {
	CPUTargetUtilization int32
	Max                  int32
	Min                  int32
}

type EnvVar

type EnvVar struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type FakeOperations

type FakeOperations struct {
	Storage map[string]*App
	// contains filtered or unexported fields
}

func NewFakeOperations

func NewFakeOperations() *FakeOperations

func (*FakeOperations) ChangeTeam added in v0.10.0

func (f *FakeOperations) ChangeTeam(appName, teamName string) error

func (*FakeOperations) CheckPermAndGet added in v0.8.0

func (f *FakeOperations) CheckPermAndGet(user *database.User, appName string) (*App, error)

func (*FakeOperations) CheckVirtualHostIsMissing added in v0.30.0

func (f *FakeOperations) CheckVirtualHostIsMissing(app *App) error

func (*FakeOperations) Create

func (f *FakeOperations) Create(user *database.User, app *App) error

func (*FakeOperations) Delete added in v0.8.0

func (f *FakeOperations) Delete(user *database.User, appName string) error

func (*FakeOperations) DeletePods added in v0.13.0

func (f *FakeOperations) DeletePods(user *database.User, appName string, podsNames []string) error

func (*FakeOperations) Get

func (f *FakeOperations) Get(appName string) (*App, error)

func (*FakeOperations) HasPermission

func (f *FakeOperations) HasPermission(user *database.User, appName string) bool

func (*FakeOperations) Info

func (f *FakeOperations) Info(user *database.User, appName string) (*Info, error)

func (*FakeOperations) List

func (f *FakeOperations) List(user *database.User) ([]*AppListItem, error)

func (*FakeOperations) ListByTeam added in v0.10.0

func (f *FakeOperations) ListByTeam(teamName string) ([]string, error)

func (*FakeOperations) Logs

func (f *FakeOperations) Logs(user *database.User, appName string, opts *LogOptions) (io.ReadCloser, error)

func (*FakeOperations) SaveApp added in v0.8.0

func (f *FakeOperations) SaveApp(app *App, lastUser string) error

func (*FakeOperations) SetAutoscale added in v0.7.0

func (f *FakeOperations) SetAutoscale(user *database.User, appName string, as *Autoscale) error

func (*FakeOperations) SetEnv

func (f *FakeOperations) SetEnv(user *database.User, appName string, envVars []*EnvVar) error

func (*FakeOperations) SetReplicas added in v0.13.0

func (f *FakeOperations) SetReplicas(user *database.User, appName string, replicas int32) error

func (*FakeOperations) SetSecret added in v0.17.0

func (f *FakeOperations) SetSecret(user *database.User, appName string, secrets []*EnvVar) error

func (*FakeOperations) SetSecretFile added in v0.25.0

func (f *FakeOperations) SetSecretFile(user *database.User, appName, name string, content []byte) error

func (*FakeOperations) SetVHosts added in v0.26.0

func (f *FakeOperations) SetVHosts(user *database.User, appName string, vHosts []string) error

func (*FakeOperations) TeamName

func (f *FakeOperations) TeamName(appName string) (string, error)

func (*FakeOperations) UnsetEnv

func (f *FakeOperations) UnsetEnv(user *database.User, appName string, envVars []string) error

func (*FakeOperations) UnsetSecret added in v0.17.0

func (f *FakeOperations) UnsetSecret(user *database.User, appName string, secrets []string) error

type Info

type Info struct {
	Team      string
	Addresses []*Address
	EnvVars   []*EnvVar
	Status    *Status
	Autoscale *Autoscale
	Limits    *Limits
	Protocol  string
	Volumes   []string
}

type K8sOperations

type K8sOperations interface {
	NamespaceAnnotation(namespace, annotation string) (string, error)
	NamespaceLabel(namespace, label string) (string, error)
	PodList(namespace string, opts *PodListOptions) ([]*Pod, error)
	PodLogs(namespace, podName string, opts *LogOptions) (io.ReadCloser, error)
	CreateNamespace(app *App, userEmail string) error
	CreateQuota(app *App) error
	GetSecret(namespace, secretName string) (map[string][]byte, error)
	CreateOrUpdateSecret(appName, secretName string, data map[string][]byte) error
	CreateOrUpdateAutoscale(app *App) error
	AddressList(namespace string) ([]*Address, error)
	Status(namespace string) (*Status, error)
	Autoscale(namespace string) (*Autoscale, error)
	Limits(namespace, name string) (*Limits, error)
	IsNotFound(err error) bool
	IsAlreadyExists(err error) bool
	IsInvalid(err error) bool
	IsUnknown(err error) bool
	SetNamespaceAnnotations(namespace string, annotations map[string]string) error
	SetNamespaceLabels(namespace string, labels map[string]string) error
	DeleteDeployEnvVars(namespace, name string, evNames []string) error
	DeleteCronJobEnvVars(namespace, name string, evNames []string) error
	CreateOrUpdateDeployEnvVars(namespace, name string, evs []*EnvVar) error
	CreateOrUpdateCronJobEnvVars(namespace, name string, evs []*EnvVar) error
	CreateOrUpdateDeploySecretEnvVars(namespace, name, secretName string, secrets []string) error
	CreateOrUpdateCronJobSecretEnvVars(namespace, name, secretName string, secrets []string) error
	DeleteNamespace(namespace string) error
	NamespaceListByLabel(label, value string) ([]string, error)
	DeploySetReplicas(namespace, name string, replicas int32) error
	DeletePod(namespace, podName string) error
	HasIngress(namespace, name string) (bool, error)
	IngressEnabled() bool
	UpdateIngress(namespace, name string, vHosts []string) error
	CreateOrUpdateDeploySecretFile(namespace, deploy, fileName string) error
	CreateOrUpdateCronJobSecretFile(namespace, cronjob, filename string) error
	DeleteDeploySecrets(namespace, deploy string, envVars, volKeys []string) error
	DeleteCronJobSecrets(namespace, cronjob string, envVars, volKeys []string) error
	SuspendCronJob(namespace, name string) error
	ResumeCronJob(namespace, name string) error
}

type LimitRangeQuantity

type LimitRangeQuantity struct {
	Quantity string
	Resource string
}

type Limits

type Limits struct {
	Default        []*LimitRangeQuantity
	DefaultRequest []*LimitRangeQuantity
}

type LogOptions added in v0.16.0

type LogOptions struct {
	Lines     int64
	Follow    bool
	PodName   string
	Previous  bool
	Container string
}

type Operations

type Operations interface {
	Create(user *database.User, app *App) error
	Logs(user *database.User, appName string, opts *LogOptions) (io.ReadCloser, error)
	Info(user *database.User, appName string) (*Info, error)
	TeamName(appName string) (string, error)
	Get(appName string) (*App, error)
	HasPermission(user *database.User, appName string) bool
	SetEnv(user *database.User, appName string, evs []*EnvVar) error
	UnsetEnv(user *database.User, appName string, evs []string) error
	SetSecret(user *database.User, appName string, secrets []*EnvVar) error
	UnsetSecret(user *database.User, appName string, secrets []string) error
	SetSecretFile(user *database.User, appName, name string, content []byte) error
	List(user *database.User) ([]*AppListItem, error)
	ListByTeam(teamName string) ([]string, error)
	SetAutoscale(user *database.User, appName string, as *Autoscale) error
	CheckPermAndGet(user *database.User, appName string) (*App, error)
	SaveApp(app *App, lastUser string) error
	Delete(user *database.User, appName string) error
	ChangeTeam(appName, teamName string) error
	SetReplicas(user *database.User, appName string, replicas int32) error
	DeletePods(user *database.User, appName string, podsNames []string) error
	SetVHosts(user *database.User, appName string, vHosts []string) error
	CheckVirtualHostIsMissing(app *App) error
}

func NewOperations

func NewOperations(tops team.Operations, kops K8sOperations, st st.Storage) Operations

type Pod

type Pod struct {
	Name     string
	State    string
	Age      int64
	Restarts int32
	Ready    bool
}

type PodListOptions added in v0.16.0

type PodListOptions struct {
	PodName string
}

type Service

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

func NewService

func NewService(ops Operations) *Service

func (*Service) ChangeTeam added in v0.20.0

func (s *Service) ChangeTeam(ctx context.Context, req *appb.ChangeTeamRequest) (*appb.Empty, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, req *appb.CreateRequest) (*appb.Empty, error)

func (*Service) Delete added in v0.8.0

func (s *Service) Delete(ctx context.Context, req *appb.DeleteRequest) (*appb.Empty, error)

func (*Service) DeletePods added in v0.13.0

func (s *Service) DeletePods(ctx context.Context, req *appb.DeletePodsRequest) (*appb.Empty, error)

func (*Service) Info

func (s *Service) Info(ctx context.Context, req *appb.InfoRequest) (*appb.InfoResponse, error)

func (*Service) List

func (s *Service) List(ctx context.Context, _ *appb.Empty) (*appb.ListResponse, error)

func (*Service) Logs

func (s *Service) Logs(req *appb.LogsRequest, stream appb.App_LogsServer) error

func (*Service) RegisterService

func (s *Service) RegisterService(grpcServer *grpc.Server)

func (*Service) SetAutoscale added in v0.7.0

func (s *Service) SetAutoscale(ctx context.Context, req *appb.SetAutoscaleRequest) (*appb.Empty, error)

func (*Service) SetEnv

func (s *Service) SetEnv(ctx context.Context, req *appb.SetEnvRequest) (*appb.Empty, error)

func (*Service) SetReplicas added in v0.13.0

func (s *Service) SetReplicas(ctx context.Context, req *appb.SetReplicasRequest) (*appb.Empty, error)

func (*Service) SetSecret added in v0.17.0

func (s *Service) SetSecret(ctx context.Context, req *appb.SetSecretRequest) (*appb.Empty, error)

func (*Service) SetVHosts added in v0.26.0

func (s *Service) SetVHosts(ctx context.Context, req *appb.SetVHostsRequest) (*appb.Empty, error)

func (*Service) UnsetEnv

func (s *Service) UnsetEnv(ctx context.Context, req *appb.UnsetEnvRequest) (*appb.Empty, error)

func (*Service) UnsetSecret added in v0.17.0

func (s *Service) UnsetSecret(ctx context.Context, req *appb.UnsetEnvRequest) (*appb.Empty, error)

type Status

type Status struct {
	CPU  int32
	Pods []*Pod
}

Jump to

Keyboard shortcuts

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