core

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginTypeAPIKey = "APIKey"
)

Variables

View Source
var ErrNotFound = errors.New("the object could not be found")

Functions

func NewValidationError

func NewValidationError(message string, validationError error) error

NewValidationError creates a ValidationError conditional on the type of error passed in. It is expected that validationError is typically of type ozzo-validation.Errors object, containing a key/value pair of string/errors, but it can be of any type of error that is consumable by a client.

Types

type ApiKey

type ApiKey struct {
	Id      int    `json:"id"`
	UserId  int    `json:"userId"`
	KeyHash []byte `json:"keyHash"`
}

type ApiKeyRepository

type ApiKeyRepository interface {
	GetByUserId(userId int) ([]ApiKey, error)
	Create(userId int, keyHash []byte) (int, error)
}

type App

type App struct {
	Name string
	// TODO: Consider a name that better describes the intent (e.g. "guardid" or something)
	Hashid AppId
}

type AppId

type AppId []byte

func DecodeAppId

func DecodeAppId(src string) (AppId, error)

func (AppId) String

func (appId AppId) String() string

type AppRepository

type AppRepository interface {
	Get(name string) (*App, error)
	Create(app *App) error
	ListApps() ([]App, error)
}

type AppStatus

type AppStatus struct {
	StageStatuses []StageStatus
	// Deployments returns the whole deployment. We should probably use a different type here with less data, but we can't just pass
	// Deployment.Doc.Status as we also need the DeploymentName and the Stage.
	Deployments []Deployment
}

type Deployment

type Deployment struct {
	Name      string
	StageName string
	AppName   string
	// RiserRevision is for tracking deployment changes and has no relation to a k8s deployment revision
	RiserRevision int64
	DeletedAt     *time.Time
	Doc           DeploymentDoc
}

type DeploymentConfig

type DeploymentConfig struct {
	Name      string
	Namespace string
	Stage     string
	Docker    DeploymentDocker
	// TODO: Move to core and remove api/v1/model dependency
	App           *model.AppConfig
	Traffic       TrafficConfig
	ManualRollout bool
}

type DeploymentContext

type DeploymentContext struct {
	Deployment    *DeploymentConfig
	Stage         *StageConfig
	RiserRevision int64
	SecretNames   []string
	ManualRollout bool
}

type DeploymentDoc

type DeploymentDoc struct {
	Status  *DeploymentStatus   `json:"status,omitempty"`
	Traffic []TrafficConfigRule `json:"traffic"`
}

func (*DeploymentDoc) Scan

func (a *DeploymentDoc) Scan(value interface{}) error

Needed for sql.Scanner interface

func (*DeploymentDoc) Value

func (a *DeploymentDoc) Value() (driver.Value, error)

Needed for sql.Scanner interface

type DeploymentDocker

type DeploymentDocker struct {
	Tag string `json:"tag"`
}

type DeploymentRepository

type DeploymentRepository interface {
	Create(newDeployment *Deployment) error
	Delete(name, stageName string) error
	Get(name, stageName string) (*Deployment, error)
	FindByApp(appName string) ([]Deployment, error)
	UpdateStatus(name, stageName string, status *DeploymentStatus) error
	UpdateTraffic(name, stageName string, riserRevision int64, traffic TrafficConfig) error
	IncrementRevision(name, stageName string) (int64, error)
	RollbackRevision(name, stageName string, failedRevision int64) (int64, error)
}

type DeploymentRevisionStatus added in v0.0.6

type DeploymentRevisionStatus struct {
	Name                 string `json:"name"`
	AvailableReplicas    int32  `json:"availableReplicas"`
	DockerImage          string `json:"dockerImage"`
	RiserRevision        int64  `json:"riserRevision"`
	RevisionStatus       string `json:"revisionStatus"`
	RevisionStatusReason string `json:"revisionStatusReason"`
}

type DeploymentStatus

type DeploymentStatus struct {
	ObservedRiserRevision     int64                      `json:"observedRiserRevision"`
	LastUpdated               time.Time                  `json:"lastUpdated"`
	Revisions                 []DeploymentRevisionStatus `json:"revisions"`
	LatestReadyRevisionName   string                     `json:"latestReadyRevisionName"`
	LatestCreatedRevisionName string                     `json:"latestCreatedRevisionName"`
	Traffic                   []DeploymentTrafficStatus  `json:"traffic"`
}

func (*DeploymentStatus) Value

func (a *DeploymentStatus) Value() (driver.Value, error)

Needed for sql.Scanner interface. Normally this is only needed on the "Doc" object but we need this here since we do status only updates.

type DeploymentTrafficStatus added in v0.0.6

type DeploymentTrafficStatus struct {
	Percent      *int64 `json:"percent,omitempty"`
	RevisionName string `json:"revisionName"`
	Tag          string `json:"tag,omitempty"`
}

type FakeApiKeyRepository

type FakeApiKeyRepository struct {
	GetByUserIdFn   func(int) ([]ApiKey, error)
	CreateFn        func(int, []byte) (int, error)
	CreateCallCount int
}

func (*FakeApiKeyRepository) Create

func (r *FakeApiKeyRepository) Create(userId int, keyHash []byte) (int, error)

func (*FakeApiKeyRepository) GetByUserId

func (r *FakeApiKeyRepository) GetByUserId(userId int) ([]ApiKey, error)

type FakeAppRepository

type FakeAppRepository struct {
	GetFn        func(string) (*App, error)
	GetCallCount int
	CreateFn     func(app *App) error
	ListAppsFn   func() ([]App, error)
}

func (*FakeAppRepository) Create

func (fake *FakeAppRepository) Create(app *App) error

func (*FakeAppRepository) Get

func (fake *FakeAppRepository) Get(name string) (*App, error)

func (*FakeAppRepository) ListApps

func (fake *FakeAppRepository) ListApps() ([]App, error)

type FakeDeploymentRepository

type FakeDeploymentRepository struct {
	CreateFn                   func(newDeployment *Deployment) error
	CreateCallCount            int
	DeleteFn                   func(name, stageName string) error
	DeleteCallCount            int
	GetFn                      func(name, stageName string) (*Deployment, error)
	GetCallCount               int
	FindByAppFn                func(string) ([]Deployment, error)
	IncrementRevisionFn        func(name, stageName string) (int64, error)
	IncrementRevisionCallCount int
	RollbackRevisionFn         func(name, stageName string, failedRevision int64) (int64, error)
	UpdateStatusFn             func(name, stageName string, status *DeploymentStatus) error
	UpdateStatusCallCount      int
	UpdateTrafficFn            func(name, stageName string, riserRevision int64, traffic TrafficConfig) error
	UpdateTrafficCallCount     int
}

func (*FakeDeploymentRepository) Create

func (f *FakeDeploymentRepository) Create(newDeployment *Deployment) error

func (*FakeDeploymentRepository) Delete added in v0.0.7

func (f *FakeDeploymentRepository) Delete(name, stageName string) error

func (*FakeDeploymentRepository) FindByApp

func (fake *FakeDeploymentRepository) FindByApp(appName string) ([]Deployment, error)

func (*FakeDeploymentRepository) Get

func (f *FakeDeploymentRepository) Get(name, stageName string) (*Deployment, error)

func (*FakeDeploymentRepository) IncrementRevision added in v0.0.7

func (fake *FakeDeploymentRepository) IncrementRevision(deploymentName, stageName string) (int64, error)

func (*FakeDeploymentRepository) RollbackRevision added in v0.0.7

func (fake *FakeDeploymentRepository) RollbackRevision(name, stageName string, failedRevision int64) (int64, error)

func (*FakeDeploymentRepository) UpdateStatus

func (fake *FakeDeploymentRepository) UpdateStatus(deploymentName, stageName string, status *DeploymentStatus) error

func (*FakeDeploymentRepository) UpdateTraffic added in v0.0.6

func (fake *FakeDeploymentRepository) UpdateTraffic(name, stageName string, riserRevision int64, traffic TrafficConfig) error

type FakeSecretMetaRepository

type FakeSecretMetaRepository struct {
	SaveFn        func(*SecretMeta) error
	SaveCallCount int
	FindByStageFn func(string, string) ([]SecretMeta, error)
}

func (*FakeSecretMetaRepository) FindByStage

func (fake *FakeSecretMetaRepository) FindByStage(appName string, stageName string) ([]SecretMeta, error)

func (*FakeSecretMetaRepository) Save

func (fake *FakeSecretMetaRepository) Save(secretMeta *SecretMeta) error

type FakeStageRepository

type FakeStageRepository struct {
	GetFn         func(string) (*Stage, error)
	GetCallCount  int
	ListFn        func() ([]Stage, error)
	ListCallCount int
	SaveFn        func(*Stage) error
	SaveCallCount int
}

func (*FakeStageRepository) Get

func (fake *FakeStageRepository) Get(name string) (*Stage, error)

func (*FakeStageRepository) List

func (fake *FakeStageRepository) List() ([]Stage, error)

func (*FakeStageRepository) Save

func (fake *FakeStageRepository) Save(stage *Stage) error

type FakeUserRepository

type FakeUserRepository struct {
	GetByApiKeyFn    func(keyHash []byte) (*User, error)
	GetByUsernameFn  func(username string) (*User, error)
	CreateFn         func(newUser *NewUser) (int, error)
	CreateCallCount  int
	GetActiveCountFn func() (int, error)
}

func (*FakeUserRepository) Create

func (r *FakeUserRepository) Create(newUser *NewUser) (int, error)

func (*FakeUserRepository) GetActiveCount

func (r *FakeUserRepository) GetActiveCount() (int, error)

func (*FakeUserRepository) GetByApiKey

func (r *FakeUserRepository) GetByApiKey(keyHash []byte) (*User, error)

func (*FakeUserRepository) GetByUsername

func (r *FakeUserRepository) GetByUsername(username string) (*User, error)

type Namespace

type Namespace struct {
	Name  string
	Stage string
}

type NewUser

type NewUser struct {
	Username string
}

type ResourceFile

type ResourceFile struct {
	Name     string `json:"name"`
	Contents []byte `json:"contents"`
	Delete   bool   `json:"delete,omitempty"`
}

type RuntimeConfig

type RuntimeConfig struct {
	BootstrapApikey          string `split_words:"true"`
	BindAddress              string `split_words:"true" default:":8000"`
	DeveloperMode            bool   `split_words:"true"`
	GitUrl                   string `split_words:"true" required:"true"`
	GitDir                   string `split_words:"true" default:"/tmp/riser/git/"`
	GitBranch                string `split_words:"true" default:"master"`
	GitUsername              string `split_words:"true"`
	GitPassword              string `split_words:"true"`
	PostgresUrl              string `split_words:"true" default:"postgres://postgres.riser-system.svc.cluster.local/riserdb?sslmode=disable&connect_timeout=3"`
	PostgresUsername         string `split_words:"true" required:"true"`
	PostgresPassword         string `split_words:"true" required:"true"`
	PostgresMigrateOnStartup bool   `split_words:"true" default:"true"`
}

RuntimeConfig provides config for the srver.

type SecretMeta

type SecretMeta struct {
	AppName    string
	StageName  string
	SecretName string
	Doc        SecretMetaDoc
}

type SecretMetaDoc

type SecretMetaDoc struct {
	LastUpdated time.Time `json:"lastUpdated"`
}

func (*SecretMetaDoc) Scan

func (a *SecretMetaDoc) Scan(value interface{}) error

Needed for sql.Scanner interface

func (*SecretMetaDoc) Value

func (a *SecretMetaDoc) Value() (driver.Value, error)

Needed for sql.Scanner interface

type SecretMetaRepository

type SecretMetaRepository interface {
	Save(secretMeta *SecretMeta) error
	FindByStage(appName string, stageName string) ([]SecretMeta, error)
}

type Stage

type Stage struct {
	Name string
	Doc  StageDoc
}

type StageConfig

type StageConfig struct {
	SealedSecretCert  []byte `json:"sealedSecretCert"`
	PublicGatewayHost string `json:"publicGatewayHost"`
}

type StageDoc

type StageDoc struct {
	LastPing time.Time   `json:"lastPing"`
	Config   StageConfig `json:"config"`
}

func (*StageDoc) Scan

func (a *StageDoc) Scan(value interface{}) error

Needed for sql.Scanner interface

func (*StageDoc) Value

func (a *StageDoc) Value() (driver.Value, error)

Needed for sql.Scanner interface

type StageRepository

type StageRepository interface {
	Get(name string) (*Stage, error)
	List() ([]Stage, error)
	Save(stage *Stage) error
}

type StageStatus

type StageStatus struct {
	StageName string
	Healthy   bool
	Reason    string
}

type StatusProblem added in v0.0.6

type StatusProblem struct {
	Count   int    `json:"count"`
	Message string `json:"message"`
}

type TrafficConfig added in v0.0.6

type TrafficConfig []TrafficConfigRule

Needed for serialization to postgres since we do partial updates on traffic

func (TrafficConfig) Value added in v0.0.6

func (a TrafficConfig) Value() (driver.Value, error)

Needed for sql.Scanner interface. Normally this is only needed on the "Doc" object but we need this here since we do traffic only updates.

type TrafficConfigRule added in v0.0.6

type TrafficConfigRule struct {
	RiserRevision int64  `json:"riserRevision"`
	RevisionName  string `json:"revisionName"`
	Percent       int    `json:"percent"`
}

type User

type User struct {
	Id       int
	Username string
	Doc      UserDoc
}

type UserDoc

type UserDoc struct {
	Created time.Time `json:"created"`
}

func (*UserDoc) Scan

func (a *UserDoc) Scan(value interface{}) error

Needed for sql.Scanner interface

func (*UserDoc) Value

func (a *UserDoc) Value() (driver.Value, error)

Needed for sql.Scanner interface

type UserRepository

type UserRepository interface {
	GetByApiKey(keyHash []byte) (*User, error)
	GetByUsername(username string) (*User, error)
	Create(newUser *NewUser) (int, error)
	GetActiveCount() (int, error)
}

type ValidationError

type ValidationError struct {
	Message string
	// ValidationError represents the validation error that ocurred. See the API errorHandler for how this is returned to the client.
	ValidationError error
	// contains filtered or unexported fields
}

ValidationError provides an error consumable by a client. This is safe to return to the API as the errorHandler is aware of this error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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