core

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 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
	// RiserGeneration is for tracking deployment changes and has no relation to a k8s Deployment generation
	RiserGeneration int64
	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
}

type DeploymentContext

type DeploymentContext struct {
	Deployment      *DeploymentConfig
	Stage           *StageConfig
	RiserGeneration int64
	SecretNames     []string
}

type DeploymentDoc

type DeploymentDoc struct {
	Status *DeploymentStatus `json:"status,omitempty"`
}

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
	FindByApp(appName string) ([]Deployment, error)
	Get(name, stageName string) (*Deployment, error)
	UpdateStatus(name, stageName string, status *DeploymentStatus) error
	IncrementGeneration(name, stageName string) (int64, error)
	RollbackGeneration(name, stageName string, failedGeneration int64) (int64, error)
}

type DeploymentStatus

type DeploymentStatus struct {
	ObservedRiserGeneration int64                     `json:"observedRiserGeneration"`
	RolloutStatus           string                    `json:"rolloutStatus"`
	RolloutStatusReason     string                    `json:"rolloutStatusReason"`
	RolloutRevision         int64                     `json:"revision"`
	DockerImage             string                    `json:"dockerImage"`
	Problems                []DeploymentStatusProblem `json:"problems"`
	LastUpdated             time.Time                 `json:"lastUpdated"`
}

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 DeploymentStatusProblem

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

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
	GetFn                        func(name, stageName string) (*Deployment, error)
	GetCallCount                 int
	FindByAppFn                  func(string) ([]Deployment, error)
	IncrementGenerationFn        func(name, stageName string) (int64, error)
	IncrementGenerationCallCount int
	RollbackGenerationFn         func(name, stageName string, failedGeneration int64) (int64, error)
	UpdateStatusFn               func(name, stageName string, status *DeploymentStatus) error
	UpdateStatusCallCount        int
}

func (*FakeDeploymentRepository) Create

func (f *FakeDeploymentRepository) Create(newDeployment *Deployment) 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) IncrementGeneration

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

func (*FakeDeploymentRepository) RollbackGeneration

func (fake *FakeDeploymentRepository) RollbackGeneration(name, stageName string, failedGeneration int64) (int64, error)

func (*FakeDeploymentRepository) UpdateStatus

func (fake *FakeDeploymentRepository) UpdateStatus(deploymentName, stageName string, status *DeploymentStatus) 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"`
}

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