models

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package models contains the types (mostly structures) encapsulating the API requests and reponses used by the communication between epinio client and APIserver. Not all of them unfortunately, the simpler ones are coded directly. TODO: Give even the most simple requests and responses properly named types.

Index

Constants

View Source
const (
	EpinioStageIDPrevious   = "epinio.suse.org/previous-stage-id"
	EpinioStageIDLabel      = "epinio.suse.org/stage-id"
	EpinioStageBlobUIDLabel = "epinio.suse.org/blob-uid"

	ApplicationCreated = "created"
	ApplicationStaging = "staging"
	ApplicationRunning = "running"
	ApplicationError   = "error"
)
View Source
const (
	OriginNone = iota
	OriginPath
	OriginGit
	OriginContainer
)

manifest origin codes for `Kind`.

Variables

View Source
var ResponseOK = Response{"ok"}

Functions

This section is empty.

Types

type App

type App struct {
	Meta          AppRef                   `json:"meta"`
	Configuration ApplicationUpdateRequest `json:"configuration"`
	Origin        ApplicationOrigin        `json:"origin"`
	Workload      *AppDeployment           `json:"deployment,omitempty"`
	Status        ApplicationStatus        `json:"status"`
	StatusMessage string                   `json:"statusmessage"`
	StageID       string                   `json:"stage_id,omitempty"` // staging id, last run
}

App has all the application's properties, for at rest (Configuration), and active (Workload). The main structure has identifying information. It is used in the CLI and API responses. If an error is hit while constructing the app object, the Error attribute will be set to that.

func NewApp

func NewApp(name string, namespace string) *App

NewApp returns a new app for name and namespace

func (*App) AppRef

func (a *App) AppRef() AppRef

AppRef returns a reference to the app (name, namespace)

type AppDeployment added in v0.1.2

type AppDeployment struct {
	// TODO: Readiness and Liveness fields?
	Active          bool                `json:"active,omitempty"` // app is > 0 replicas
	CreatedAt       string              `json:"createdAt,omitempty"`
	DesiredReplicas int32               `json:"desiredreplicas"`
	ReadyReplicas   int32               `json:"readyreplicas"`
	Replicas        map[string]*PodInfo `json:"replicas"`
	Username        string              `json:"username,omitempty"` // app creator
	StageID         string              `json:"stage_id,omitempty"` // staging id, running app
	Status          string              `json:"status,omitempty"`   // app replica status
	Routes          []string            `json:"routes,omitempty"`   // app routes
}

AppDeployment contains all the information specific to an active application, i.e. one with a deployment in the cluster.

type AppList

type AppList []App

AppList is a collection of app references

func (AppList) Len

func (al AppList) Len() int

Len (Sort interface) returns the length of the AppList

func (AppList) Less

func (al AppList) Less(i, j int) bool

Less (Sort interface) compares the contents of the specified indices in the AppList and returns true if the condition holds, and else false.

func (AppList) Swap

func (al AppList) Swap(i, j int)

Swap (Sort interface) exchanges the contents of specified indices in the AppList

type AppRef

type AppRef struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

AppRef references an App by name and namespace

func NewAppRef

func NewAppRef(name string, namespace string) AppRef

NewAppRef returns a new reference to an app

func (*AppRef) App

func (ar *AppRef) App() *App

App returns a fresh app model for the reference

func (*AppRef) MakeEnvSecretName added in v0.1.2

func (ar *AppRef) MakeEnvSecretName() string

MakeEnvSecretName returns the name of the kube secret holding the environment variables of the referenced application

func (*AppRef) MakePVCName added in v0.1.2

func (ar *AppRef) MakePVCName() string

MakePVCName returns the name of the kube pvc to use with/for the referenced application.

func (*AppRef) MakeScaleSecretName added in v0.1.2

func (ar *AppRef) MakeScaleSecretName() string

MakeScaleSecretName returns the name of the kube secret holding the number of desired instances for referenced application

func (*AppRef) MakeServiceSecretName added in v0.1.2

func (ar *AppRef) MakeServiceSecretName() string

MakeServiceSecretName returns the name of the kube secret holding the bound services of the referenced application

type ApplicationCreateRequest

type ApplicationCreateRequest struct {
	Name          string                   `json:"name"          yaml:"name"`
	Configuration ApplicationUpdateRequest `json:"configuration" yaml:"configuration,omitempty"`
}

ApplicationCreateRequest represents and contains the data needed to create an application (at rest), possibly with presets (services)

type ApplicationDeleteResponse

type ApplicationDeleteResponse struct {
	UnboundServices []string `json:"unboundservices"`
}

ApplicationDeleteResponse represents the server's response to a successful app deletion

type ApplicationManifest added in v0.1.2

type ApplicationManifest struct {
	ApplicationCreateRequest `yaml:",inline"`
	Self                     string            `yaml:"-"` // Hidden from yaml. The file's location.
	Origin                   ApplicationOrigin `yaml:"origin,omitempty"`
	Staging                  ApplicationStage  `yaml:"staging,omitempty"`
}

ApplicationManifest represents and contains the data of an application's manifest file, plus some auxiliary data never (un)marshaled. Namely, the file's location, and origin type tag.

type ApplicationOrigin added in v0.1.3

type ApplicationOrigin struct {
	// Hidden from yaml. Type tag to simplify struct usage.
	// Note: we cannot hide this property from the JSON since it's used to unmarshal correctly the result of the Apps endpoint
	// @see failling test here: https://github.com/epinio/epinio/runs/4935898437?check_suite_focus=true
	// We should probably expose a more meaningful value instead of this "Kind" int
	Kind      int     `yaml:"-"`
	Container string  `yaml:"container,omitempty" json:"container,omitempty"`
	Git       *GitRef `yaml:"git,omitempty"       json:"git,omitempty"`
	Path      string  `yaml:"path,omitempty"      json:"path,omitempty"`
}

ApplicationOrigin is the part of the manifest describing the origin of the application (sources). At most one of the fields may be specified / not empty.

func (*ApplicationOrigin) String added in v0.1.3

func (o *ApplicationOrigin) String() string

type ApplicationStage added in v0.1.3

type ApplicationStage struct {
	Builder string `yaml:"builder,omitempty"`
}

ApplicationStaging is the part of the manifest holding information relevant to staging the application's sources. This is, currently, only the reference to the Paketo builder image to use.

type ApplicationStatus added in v0.1.2

type ApplicationStatus string

type ApplicationUpdateRequest added in v0.1.2

type ApplicationUpdateRequest struct {
	Instances   *int32         `json:"instances"   yaml:"instances,omitempty"`
	Services    []string       `json:"services"    yaml:"services,omitempty"`
	Environment EnvVariableMap `json:"environment" yaml:"environment,omitempty"`
	Routes      []string       `json:"routes" yaml:"routes,omitempty"`
}

ApplicationUpdateRequest represents and contains the data needed to update an application. Specifically to modify the number of replicas to run, and the services bound to it. Note: Instances is a pointer to give us a nil value separate from actual integers, as means of communicating `default`/`no change`.

type AuthTokenResponse added in v0.3.6

type AuthTokenResponse struct {
	Token string `json:"token,omitempty"`
}

AuthTokenResponse contains an auth token

type BindRequest

type BindRequest struct {
	Names []string `json:"names"`
}

BindRequest represents and contains the data needed to bind services to an application.

type BindResponse

type BindResponse struct {
	WasBound []string `json:"wasbound"`
}

BindResponse represents the server's response to the successful binding of services to an application.

type DeployRequest

type DeployRequest struct {
	App      AppRef            `json:"app,omitempty"`
	Stage    StageRef          `json:"stage,omitempty"`
	ImageURL string            `json:"image,omitempty"`
	Origin   ApplicationOrigin `json:"origin,omitempty"`
}

DeployRequest represents and contains the data needed to deploy an application Note that the overall application configuration (instances, services, EVs) is already known server side, through AppCreate/AppUpdate requests. This request not only comes with the image to deploy, but also the information where the sources of that image came from.

type DeployResponse

type DeployResponse struct {
	Routes []string `json:"routes,omitempty"`
}

DeployResponse represents the server's response to a successful app deployment

type EnvMatchResponse

type EnvMatchResponse struct {
	Names []string `json:"names,omitempty"`
}

EnvMatchResponse contains the list of names for matching envs

type EnvVariable

type EnvVariable struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvVariable represents the Show Response for a single environment variable

type EnvVariableList

type EnvVariableList []EnvVariable

EnvVariableList is a collection of EVs.

func (EnvVariableList) Len

func (evl EnvVariableList) Len() int

Len (Sort interface) returns the length of the EnvVariableList

func (EnvVariableList) Less

func (evl EnvVariableList) Less(i, j int) bool

Less (Sort interface) compares the contents of the specified indices in the EnvVariableList and returns true if the condition holds, and else false.

func (EnvVariableList) StagingEnvArray

func (evl EnvVariableList) StagingEnvArray() []v1.EnvVar

StagingEnvArray returns the collection of environment variables and their values in a form suitable for injection into the Job-based staging of an application.

func (EnvVariableList) Swap

func (evl EnvVariableList) Swap(i, j int)

Swap (Sort interface) exchanges the contents of specified indices in the EnvVariableList

func (EnvVariableList) ToEnvVarArray

func (evl EnvVariableList) ToEnvVarArray(appRef AppRef) []v1.EnvVar

ToEnvVarArray converts the collection of environment variables for the referenced application, as a combination of standard variables and the user-specified variables. The result is used to make the application's environment available to the initial deployment

type EnvVariableMap added in v0.1.3

type EnvVariableMap map[string]string

EnvVariableMap is a collection of EVs as a map. It is used for Set Requests, and as List Responses

func (EnvVariableMap) List added in v0.1.3

func (evm EnvVariableMap) List() EnvVariableList

type EnvVarnameList

type EnvVarnameList []string

EnvVarnameList is a collection of EV names, it is used for Unset Requests, and as Match Responses

type GitRef

type GitRef struct {
	Revision string `json:"revision,omitempty" yaml:"revision,omitempty"`
	URL      string `json:"repository"         yaml:"url"`
}

type ImageRef

type ImageRef struct {
	ID string `json:"id,omitempty"`
}

ImageRef references an upload

func NewImage

func NewImage(id string) ImageRef

NewImage returns a new image ref for the given ID

type ImportGitResponse

type ImportGitResponse struct {
	BlobUID string `json:"blobuid,omitempty"`
}

type InfoResponse

type InfoResponse struct {
	Version     string `json:"version,omitempty"`
	KubeVersion string `json:"kube_version,omitempty"`
	Platform    string `json:"platform,omitempty"`
}

InfoResponse contains information about Epinio and its components

type Namespace

type Namespace struct {
	Name     string   `json:"name,omitempty"`
	Apps     []string `json:"apps,omitempty"`
	Services []string `json:"services,omitempty"`
}

Namespace has all the namespace properties, i.e. name, app names, and service names It is used in the CLI and API responses.

type NamespaceCreateRequest

type NamespaceCreateRequest struct {
	Name string `json:"name,omitempty"`
}

NamespaceCreateRequest contains the name of the namespace that should be created

type NamespaceList

type NamespaceList []Namespace

NamespaceList is a collection of namespaces

func (NamespaceList) Len

func (al NamespaceList) Len() int

Len (Sort interface) returns the length of the NamespaceList

func (NamespaceList) Less

func (al NamespaceList) Less(i, j int) bool

Less (Sort interface) compares the contents of the specified indices in the NamespaceList and returns true if the condition holds, and else false.

func (NamespaceList) Swap

func (al NamespaceList) Swap(i, j int)

Swap (Sort interface) exchanges the contents of specified indices in the NamespaceList

type NamespacesMatchResponse

type NamespacesMatchResponse struct {
	Names []string `json:"names,omitempty"`
}

NamespacesMatchResponse contains the list of names for matching namespaces

type PodInfo added in v0.3.6

type PodInfo struct {
	Name        string `json:"name"`
	MemoryBytes int64  `json:"memoryBytes"`
	MilliCPUs   int64  `json:"millicpus"`
	CreatedAt   string `json:"createdAt,omitempty"`
	Restarts    int32  `json:"restarts"`
	Ready       bool   `json:"ready"`
}

type Request

type Request struct {
}

type Response

type Response struct {
	Status string `json:"status"`
}

type ServiceAppsResponse

type ServiceAppsResponse struct {
	AppsOf map[string]AppList `json:"apps_of,omitempty"`
}

ServiceAppsResponse returns a list of apps per service

type ServiceCreateRequest added in v0.1.2

type ServiceCreateRequest struct {
	Name string            `json:"name"`
	Data map[string]string `json:"data"`
}

ServiceCreateRequest represents and contains the data needed to create a service instance

type ServiceDeleteRequest added in v0.1.2

type ServiceDeleteRequest struct {
	Unbind bool `json:"unbind"`
}

ServiceDeleteRequest represents and contains the data needed to delete a service

type ServiceDeleteResponse added in v0.1.2

type ServiceDeleteResponse struct {
	BoundApps []string `json:"boundapps"`
}

ServiceDeleteResponse represents the server's response to a successful service deletion

type ServiceRef added in v0.1.5

type ServiceRef struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

ServiceRef references a Service by name and namespace

type ServiceReplaceRequest added in v0.3.2

type ServiceReplaceRequest map[string]string

ServiceReplaceRequest represents and contains the data needed to replace a service instance

type ServiceResponse

type ServiceResponse struct {
	Meta          ServiceRef          `json:"meta"`
	Configuration ServiceShowResponse `json:"configuration"`
}

ServiceResponse represents the data of a single service instance

type ServiceResponseList

type ServiceResponseList []ServiceResponse

ServiceResponseList represents a collection of service instance

func (ServiceResponseList) Len

func (srl ServiceResponseList) Len() int

Len (Sort interface) returns the length of the ServiceResponseList

func (ServiceResponseList) Less

func (srl ServiceResponseList) Less(i, j int) bool

Less (Sort interface) compares the contents of the specified indices in the ServiceResponseList and returns true if the condition holds, and else false.

func (ServiceResponseList) Swap

func (srl ServiceResponseList) Swap(i, j int)

Swap (Sort interface) exchanges the contents of specified indices in the ServiceResponseList

type ServiceShowResponse

type ServiceShowResponse struct {
	Username  string            `json:"user"`
	Details   map[string]string `json:"details,omitempty"`
	BoundApps []string          `json:"boundapps"`
}

ServiceShowResponse contains details about a service

type ServiceUpdateRequest added in v0.3.0

type ServiceUpdateRequest struct {
	Remove []string          `json:"remove,omitempty"`
	Set    map[string]string `json:"edit,omitempty"`
}

ServiceUpdateRequest represents and contains the data needed to update a service instance (add/change, and remove keys)

type StageRef

type StageRef struct {
	ID string `json:"id,omitempty"`
}

StageRef references a staging run by ID, currently randomly generated for each POST to the staging endpoint

func NewStage

func NewStage(id string) StageRef

NewStage returns a new reference to a staging run

type StageRequest

type StageRequest struct {
	App          AppRef `json:"app,omitempty"`
	BlobUID      string `json:"blobuid,omitempty"`
	BuilderImage string `json:"builderimage,omitempty"`
}

StageRequest represents and contains the data needed to stage an application

type StageResponse

type StageResponse struct {
	Stage    StageRef `json:"stage,omitempty"`
	ImageURL string   `json:"image,omitempty"`
}

StageResponse represents the server's response to a successful app staging

type UploadResponse

type UploadResponse struct {
	BlobUID string `json:"blobuid,omitempty"`
}

UploadResponse represents the server's response to a successful app sources upload

Jump to

Keyboard shortcuts

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