Documentation
¶
Index ¶
- Constants
- func DeploymentType(templateType service.TemplateType, provider service.ProviderModel) string
- func ErrorToServiceError(err error) service.CacaoError
- func MergeServiceErrorAndError(session service.Session, err error) service.CacaoErrorBase
- func ValidateDeployment(deployment Deployment) error
- func ValidateDeploymentStatus(status service.DeploymentStatus, pendingStatus service.DeploymentPendingStatus) error
- func ValidateDeploymentUpdate(update DeploymentUpdate) error
- type Actor
- type Config
- type Deployment
- type DeploymentFilter
- type DeploymentRun
- type DeploymentRunFilter
- type DeploymentRunUpdate
- type DeploymentSort
- type DeploymentSortField
- type DeploymentStatusUpdater
- func (u DeploymentStatusUpdater) PendingStatusCreating() (DeploymentUpdate, DeploymentFilter)
- func (u DeploymentStatusUpdater) PendingStatusDeleting() (DeploymentUpdate, DeploymentFilter)
- func (u DeploymentStatusUpdater) StatusActive() (DeploymentUpdate, DeploymentFilter)
- func (u DeploymentStatusUpdater) StatusCreationFailed() (DeploymentUpdate, DeploymentFilter)
- func (u DeploymentStatusUpdater) StatusDeleted() (DeploymentUpdate, DeploymentFilter)
- func (u DeploymentStatusUpdater) StatusDeletionErrored() (DeploymentUpdate, DeploymentFilter)
- type DeploymentUpdate
- type EnvConfig
- type Query
- type SortDirection
Constants ¶
const ( // DeploymentIDPrefix is prefix for ID for deployment objects DeploymentIDPrefix = "deployment" // RunIDPrefix is prefix for ID for deployment run objects RunIDPrefix = "run" )
ID prefix
const ( // DeploymentStreamThreshold is a threshold for streaming deployments in multiple // replies. If num of deployments in the list exceeds this threshold, start // streaming result in multiple replies. When deployment have large state in this // last run and the deployment list includes the full run, the threshold could // easily be overrun. DeploymentStreamThreshold = 10 // DeploymentRunStreamThreshold is a threshold for streaming runs in multiple replies. // If num of runs in the list exceeds this threshold, start streaming result in multiple replies. DeploymentRunStreamThreshold = 1000 )
const DeploymentWildcardSubject common.QueryOp = "cyverse.deployment.*"
DeploymentWildcardSubject is the wildcard subject this microservice subcribe to for all incoming queries
Variables ¶
This section is empty.
Functions ¶
func DeploymentType ¶
func DeploymentType(templateType service.TemplateType, provider service.ProviderModel) string
DeploymentType computes deployment type from template type and provider type. DeploymentType is used for determine which execution service handles operation on the deployment and run. FIXME move to deploymentcommon
func ErrorToServiceError ¶
func ErrorToServiceError(err error) service.CacaoError
ErrorToServiceError converts built-in error object into service error that can be transported in events.
func MergeServiceErrorAndError ¶
func MergeServiceErrorAndError(session service.Session, err error) service.CacaoErrorBase
MergeServiceErrorAndError merge a new error into a service error
func ValidateDeployment ¶
func ValidateDeployment(deployment Deployment) error
ValidateDeployment checks if a deployment is valid (ready for storage). Changes to this function should also apply to ValidateDeploymentUpdate.
func ValidateDeploymentStatus ¶
func ValidateDeploymentStatus(status service.DeploymentStatus, pendingStatus service.DeploymentPendingStatus) error
ValidateDeploymentStatus checks if status pair(current & pending) are valid
func ValidateDeploymentUpdate ¶
func ValidateDeploymentUpdate(update DeploymentUpdate) error
ValidateDeploymentUpdate checks if an update is valid (ready to be applied in storage). Changes to this function should also apply to ValidateDeployment.
Types ¶
type Actor ¶
Actor is the user that performs certain action. FIXME remove this alias, once migration is done
type Config ¶
type Config struct { MessagingConfig messaging2.NatsStanMsgConfig MongoConfig db.MongoDBConfig }
Config is configuration via config file
type Deployment ¶
type Deployment struct { ID common.ID `bson:"_id"` Name string `bson:"name"` Description string `bson:"description"` CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` Workspace common.ID `bson:"workspace"` // user who created the deployment CreatedBy deploymentcommon.Creator `bson:",inline"` Template common.ID `bson:"template"` TemplateType service.TemplateTypeName `bson:"template_type"` PrimaryCloudProvider common.ID `bson:"primary_provider"` CurrentStatus service.DeploymentStatus `bson:"current_status"` PendingStatus service.DeploymentPendingStatus `bson:"pending_status"` StatusMsg string `bson:"status_msg"` CloudCredentials deploymentcommon.ProviderCredentialMappings `bson:"cloud_credentials"` GitCredential deploymentcommon.CredentialID `bson:"git_credential"` // most recent run sorted by creation timestamp LastRun *common.ID `bson:"last_run"` }
Deployment is the storage format of deployment
func (Deployment) ConvertToExternal ¶
func (d Deployment) ConvertToExternal() service.Deployment
ConvertToExternal converts to external representation. Note: this is the responsibility of the caller to ensure they pass in the correct lastRun.
func (Deployment) FindCloudCredential ¶
func (d Deployment) FindCloudCredential(provider common.ID) (deploymentcommon.CredentialID, bool)
FindCloudCredential find cloud credential for a provider if any.
func (Deployment) HasLastRun ¶
func (d Deployment) HasLastRun() bool
HasLastRun returns true if the deployment has a last run
func (Deployment) Owner ¶
func (d Deployment) Owner() string
Owner returns the owner of the deployment. Currently, owner is the creator.
type DeploymentFilter ¶
type DeploymentFilter struct { ID common.ID // Only return deployments that is created by a user Creator string // Only return deployments that has the specified source template Template common.ID // Only return deployments that have one of the specified source templates TemplateSet []common.ID // Only return deployments that is in the specified workspace Workspace common.ID // Only return deployments that has the specified primary cloud provider PrimaryCloudProvider common.ID // Only return deployments that has the specified credential (git or cloud) Credential deploymentcommon.CredentialID // Only return deployments that is marked as deleting Deleting *bool // Only return deployments with matching deletion workflow name DeletionWorkflow string CurrentStatus []service.DeploymentStatus PendingStatus []service.DeploymentPendingStatus }
DeploymentFilter is filter for searching deployment. All values here must have a "nil" or "zero" value that indicates the field is not set.
func (DeploymentFilter) ToMongoFilters ¶
func (df DeploymentFilter) ToMongoFilters() bson.M
ToMongoFilters converts a deployment filter object to filter in mongo-format
type DeploymentRun ¶
type DeploymentRun struct { // ID of the deployment run ID common.ID `bson:"_id"` Deployment common.ID `bson:"deployment"` CreatedBy deploymentcommon.Creator `bson:",inline"` CreatedAt time.Time `bson:"created_at"` EndsAt time.Time `bson:"ended_at"` TemplateSnapshot deploymentcommon.TemplateSnapshot `bson:"template"` // parameters in the run creation request RequestParameters service.DeploymentParameterValues `bson:"request_parameters"` Parameters deploymentcommon.DeploymentParameters `bson:"parameters"` Status deploymentcommon.DeploymentRunStatus `bson:"status"` StatusMsg string `bson:"status_msg"` // most recent state LastState service.DeploymentStateView `bson:"last_state"` StateUpdatedAt time.Time `bson:"state_updated_at"` }
DeploymentRun is the storage format of deployment run in metadata service. This should only store info that is template-engine/cloud-provider agnostic. Info that is specific to template-engine/cloud-provider should be stored by specific deployment service. This stores enough info about the run to be able to make reproducible call to specific deployment ms without access to external ms.
func (DeploymentRun) ConvertToExternal ¶
func (r DeploymentRun) ConvertToExternal() service.DeploymentRun
ConvertToExternal converts to external representation
func (DeploymentRun) HasLogs ¶
func (r DeploymentRun) HasLogs() bool
HasLogs ... Deprecated: logs should not be stored in metadata svc
func (DeploymentRun) HasRawState ¶
func (r DeploymentRun) HasRawState() bool
HasRawState ... Deprecated: raw state should not be stored in metadata svc
type DeploymentRunFilter ¶
DeploymentRunFilter is filter for searching deployment run
func (DeploymentRunFilter) ToMongoFilters ¶
func (drf DeploymentRunFilter) ToMongoFilters() bson.M
ToMongoFilters converts a deployment run filter object to filter in mongo-format
type DeploymentRunUpdate ¶
type DeploymentRunUpdate struct { Deployment *common.ID `bson:"deployment"` EndsAt *time.Time `bson:"ended_at"` TemplateSnapshot *deploymentcommon.TemplateSnapshot `bson:"template"` Parameters *deploymentcommon.DeploymentParameters `bson:"parameters"` Status *deploymentcommon.DeploymentRunStatus `bson:"status"` StatusMsg *string `bson:"status_msg"` LastState *service.DeploymentStateView `bson:"last_state"` StateUpdatedAt *time.Time `bson:"state_updated_at"` }
DeploymentRunUpdate is used for updating deployment run, it contains fields that can potentially be updated. All fields should be nullable(ptr or slice), so that fields that has nil value is not updated in storage.
func (DeploymentRunUpdate) ToBSONValues ¶
func (dru DeploymentRunUpdate) ToBSONValues() bson.M
ToBSONValues ...
type DeploymentSort ¶
type DeploymentSort struct { SortBy DeploymentSortField SortDir SortDirection }
DeploymentSort is sort option for deployment
func DefaultDeploymentSort ¶
func DefaultDeploymentSort() DeploymentSort
DefaultDeploymentSort returns the default sort option
func FromExternalDeploymentSort ¶
func FromExternalDeploymentSort(field service.SortByField, direction service.SortDirection) (DeploymentSort, error)
FromExternalDeploymentSort converts from external representation of sorting option for deployment
type DeploymentSortField ¶
type DeploymentSortField string
DeploymentSortField are fields that can be sort by for deployment
const ( SortByID DeploymentSortField = "_id" // default SortByWorkspace DeploymentSortField = "workspace" SortByTemplate DeploymentSortField = "template" SortByPrimaryCloud DeploymentSortField = "primary_cloud" )
Fields to sort by for deployment
type DeploymentStatusUpdater ¶
type DeploymentStatusUpdater struct {
// contains filtered or unexported fields
}
DeploymentStatusUpdater include logic that generate update parameter for updating current/pending status of deployment
func NewDeploymentStatusUpdater ¶
func NewDeploymentStatusUpdater(updateTimestamp time.Time) DeploymentStatusUpdater
NewDeploymentStatusUpdater ...
func (DeploymentStatusUpdater) PendingStatusCreating ¶
func (u DeploymentStatusUpdater) PendingStatusCreating() (DeploymentUpdate, DeploymentFilter)
PendingStatusCreating returns update parameter for changing pending PendingStatus to Creating
func (DeploymentStatusUpdater) PendingStatusDeleting ¶
func (u DeploymentStatusUpdater) PendingStatusDeleting() (DeploymentUpdate, DeploymentFilter)
PendingStatusDeleting returns update parameter for changing pending PendingStatus to Deleting
func (DeploymentStatusUpdater) StatusActive ¶
func (u DeploymentStatusUpdater) StatusActive() (DeploymentUpdate, DeploymentFilter)
StatusActive returns the update parameter for changing CurrentStatus to Active
func (DeploymentStatusUpdater) StatusCreationFailed ¶
func (u DeploymentStatusUpdater) StatusCreationFailed() (DeploymentUpdate, DeploymentFilter)
StatusCreationFailed returns the update parameter for changing CurrentStatus to CreationErrored
func (DeploymentStatusUpdater) StatusDeleted ¶
func (u DeploymentStatusUpdater) StatusDeleted() (DeploymentUpdate, DeploymentFilter)
StatusDeleted returns the update parameter for changing CurrentStatus to Deleted
func (DeploymentStatusUpdater) StatusDeletionErrored ¶
func (u DeploymentStatusUpdater) StatusDeletionErrored() (DeploymentUpdate, DeploymentFilter)
StatusDeletionErrored returns the update parameter for changing CurrentStatus to DeletionErrored
type DeploymentUpdate ¶
type DeploymentUpdate struct { Name *string Description *string UpdatedAt *time.Time Template *common.ID TemplateType *service.TemplateTypeName PrimaryCloudProvider *common.ID CurrentStatus *service.DeploymentStatus PendingStatus *service.DeploymentPendingStatus StatusMsg *string CloudCredentials deploymentcommon.ProviderCredentialMappings // ProviderCredentialMappings is slice, so no * GitCredential *deploymentcommon.CredentialID LastRun **common.ID // LastRun is a ptr field, so ** }
DeploymentUpdate is used for updating deployment, it contains fields that can potentially be updated. All fields should be nullable(ptr or slice), so that fields that has nil value is not updated in storage.
func (DeploymentUpdate) ToBSONValues ¶
func (du DeploymentUpdate) ToBSONValues() bson.M
ToBSONValues ...
type EnvConfig ¶
type EnvConfig struct { PodName string `envconfig:"POD_NAME"` LogLevel string `envconfig:"LOG_LEVEL" default:"debug"` }
EnvConfig is configuration via environment variable
type Query ¶
type Query interface { QueryType() common.QueryOp CloudEvent() cloudevents.Event ReplySubject() string }
Query is the the query type that is passed in between domain and storage via ports
type SortDirection ¶
type SortDirection int
SortDirection is the direction to sort the result
const AscendingSort SortDirection = 1 // default
AscendingSort sorts result in ascending order
const DescendingSort SortDirection = -1
DescendingSort sorts result in descending order