Documentation
¶
Overview ¶
Package cloudstore provides the in-memory store used by the fake Terramate Cloud server.
Index ¶
- Constants
- type Data
- func (d *Data) AppendPreviewLogs(org Org, stackPreviewID string, logs cloud.CommandLogs) error
- func (d *Data) DeleteOutput(orgUUID cloud.UUID, id cloud.UUID) error
- func (d *Data) FindDeploymentForCommit(orgID cloud.UUID, commitSHA string) (*Deployment, bool)
- func (d *Data) GetDeployment(org *Org, id cloud.UUID) (*Deployment, bool)
- func (d *Data) GetDeploymentEvents(orgID, deploymentID cloud.UUID) (map[string][]deployment.Status, error)
- func (d *Data) GetDeploymentLogs(orgID cloud.UUID, stackMetaID string, stackTarget string, ...) (cloud.CommandLogs, error)
- func (d *Data) GetGithubCommitResponse() json.RawMessage
- func (d *Data) GetGithubPullRequestResponse() json.RawMessage
- func (d *Data) GetMemberships(user cloud.User) []Member
- func (d *Data) GetMembershipsForKey(key string) []Member
- func (d *Data) GetOrg(uuid cloud.UUID) (Org, bool)
- func (d *Data) GetOutput(orgUUID cloud.UUID, id cloud.UUID) (cloud.StoreOutput, error)
- func (d *Data) GetOutputByKey(orgUUID cloud.UUID, key cloud.StoreOutputKey) (cloud.StoreOutput, error)
- func (d *Data) GetPreviewByID(org Org, previewID string) (Preview, bool)
- func (d *Data) GetStack(org Org, id int64) (Stack, bool)
- func (d *Data) GetStackByMetaID(org Org, id string, target string) (Stack, int64, bool)
- func (d *Data) GetStackDrifts(orguuid cloud.UUID, stackID int64) ([]Drift, error)
- func (d *Data) GetUser(email string) (cloud.User, bool)
- func (d *Data) GetWellKnown() *cloud.WellKnown
- func (d *Data) InsertDeployment(orgID cloud.UUID, deploy Deployment) error
- func (d *Data) InsertDeploymentLogs(orgID cloud.UUID, stackMetaID string, stackTarget string, ...) error
- func (d *Data) InsertDrift(orgID cloud.UUID, drift Drift) (int, error)
- func (d *Data) InsertOutput(orgUUID cloud.UUID, output *cloud.StoreOutput) error
- func (d *Data) MarshalJSON() ([]byte, error)
- func (d *Data) MustGetUser(email string) cloud.User
- func (d *Data) MustOrgByName(name string) Org
- func (d *Data) OrgByName(name string) (Org, bool)
- func (d *Data) SetDeploymentStatus(org Org, deploymentID cloud.UUID, stackID int64, status deployment.Status) error
- func (d *Data) UpdateOutputValue(orgUUID cloud.UUID, id cloud.UUID, newval string) error
- func (d *Data) UpdateStackPreview(org Org, stackPreviewID string, status string, ...) (*StackPreview, bool)
- func (d *Data) UpsertOrg(org Org)
- func (d *Data) UpsertPreview(orguuid cloud.UUID, p Preview) (string, error)
- func (d *Data) UpsertStack(orguuid cloud.UUID, st Stack) (int64, error)
- func (d *Data) UpsertStackPreview(org Org, previewID string, sp *StackPreview) (string, error)
- type Deployment
- type DeploymentState
- type Drift
- type Member
- type Org
- type OutputKey
- type Preview
- type Stack
- type StackPreview
- type StackState
Constants ¶
const ( // ErrAlreadyExists is the error for the case where the record already exists. ErrAlreadyExists errors.Kind = "record already exists" // ErrNotExists is the error when the record does not exists. ErrNotExists errors.Kind = "record does not exist" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
Orgs map[string]Org `json:"orgs"`
Users map[string]cloud.User `json:"users"`
WellKnown *cloud.WellKnown `json:"well_known"`
Github struct {
GetPullRequestResponse json.RawMessage `json:"get_pull_request_response"`
GetCommitResponse json.RawMessage `json:"get_commit_response"`
} `json:"github"`
// contains filtered or unexported fields
}
Data is the in-memory data store. It has public fields but they *SHALL NOT* be directly manipulated unless for the case of initialiting the data.
func LoadDatastore ¶
LoadDatastore loads the data store from a JSON file.
func (*Data) AppendPreviewLogs ¶ added in v0.5.4
AppendPreviewLogs appends logs to the given stack preview.
func (*Data) DeleteOutput ¶ added in v0.12.0
DeleteOutput deletes the output with the given id.
func (*Data) FindDeploymentForCommit ¶ added in v0.5.0
FindDeploymentForCommit returns the deployment for the given commit.
func (*Data) GetDeployment ¶
GetDeployment returns the given deployment.
func (*Data) GetDeploymentEvents ¶
func (d *Data) GetDeploymentEvents(orgID, deploymentID cloud.UUID) (map[string][]deployment.Status, error)
GetDeploymentEvents returns the events of the given deployment.
func (*Data) GetDeploymentLogs ¶
func (d *Data) GetDeploymentLogs(orgID cloud.UUID, stackMetaID string, stackTarget string, deploymentID cloud.UUID, fromLine int) (cloud.CommandLogs, error)
GetDeploymentLogs returns the logs of the given deployment.
func (*Data) GetGithubCommitResponse ¶ added in v0.5.4
func (d *Data) GetGithubCommitResponse() json.RawMessage
GetGithubCommitResponse returns the github commit response.
func (*Data) GetGithubPullRequestResponse ¶ added in v0.5.4
func (d *Data) GetGithubPullRequestResponse() json.RawMessage
GetGithubPullRequestResponse returns the github pull request response.
func (*Data) GetMemberships ¶
GetMemberships returns the organizations that user is member of.
func (*Data) GetMembershipsForKey ¶ added in v0.11.5
GetMembershipsForKey returns the memberships for the given key.
func (*Data) GetOutputByKey ¶ added in v0.12.0
func (d *Data) GetOutputByKey(orgUUID cloud.UUID, key cloud.StoreOutputKey) (cloud.StoreOutput, error)
GetOutputByKey retrieves the output for the given key.
func (*Data) GetPreviewByID ¶ added in v0.5.4
GetPreviewByID returns the preview associated with previewID.
func (*Data) GetStackByMetaID ¶
GetStackByMetaID returns the given stack.
func (*Data) GetStackDrifts ¶
GetStackDrifts returns the drifts of the provided stack.
func (*Data) GetWellKnown ¶
GetWellKnown gets the defined well-known.
func (*Data) InsertDeployment ¶
func (d *Data) InsertDeployment(orgID cloud.UUID, deploy Deployment) error
InsertDeployment inserts the given deployment in the data store.
func (*Data) InsertDeploymentLogs ¶
func (d *Data) InsertDeploymentLogs( orgID cloud.UUID, stackMetaID string, stackTarget string, deploymentID cloud.UUID, logs cloud.CommandLogs, ) error
InsertDeploymentLogs inserts logs for the given deployment.
func (*Data) InsertDrift ¶
InsertDrift inserts a new drift into the store for the provided org.
func (*Data) InsertOutput ¶ added in v0.12.0
InsertOutput inserts the given output into the store.
func (*Data) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface to the data store. It's required to avoid data races if store is concurrently accessed.
func (*Data) MustGetUser ¶
MustGetUser retrieves the user by email or panics.
func (*Data) MustOrgByName ¶
MustOrgByName must return an organization with the provided name otherwise it panics.
func (*Data) SetDeploymentStatus ¶
func (d *Data) SetDeploymentStatus(org Org, deploymentID cloud.UUID, stackID int64, status deployment.Status) error
SetDeploymentStatus sets the given deployment stack to the given status.
func (*Data) UpdateOutputValue ¶ added in v0.12.0
UpdateOutputValue updates the value of the output.
func (*Data) UpdateStackPreview ¶ added in v0.5.4
func (d *Data) UpdateStackPreview(org Org, stackPreviewID string, status string, changeset *cloud.ChangesetDetails) (*StackPreview, bool)
UpdateStackPreview updates the given stack preview.
func (*Data) UpsertPreview ¶ added in v0.5.4
UpsertPreview inserts or updates the given preview.
func (*Data) UpsertStack ¶
UpsertStack inserts or updates the given stack.
func (*Data) UpsertStackPreview ¶ added in v0.5.4
UpsertStackPreview inserts or updates the given stack preview.
type Deployment ¶
type Deployment struct {
UUID cloud.UUID `json:"uuid"`
Stacks []int64 `json:"stacks"`
Workdir string `json:"workdir"`
StackCommands map[string]string `json:"stack_commands"`
DeploymentURL string `json:"deployment_url,omitempty"`
Status deployment.Status `json:"status"`
Metadata *cloud.DeploymentMetadata `json:"metadata"`
ReviewRequest *cloud.ReviewRequest `json:"review_request"`
State DeploymentState `json:"state"`
}
Deployment model.
type DeploymentState ¶
type DeploymentState struct {
StackStatus map[int64]deployment.Status `json:"stacks_status"`
StackStatusEvents map[int64][]deployment.Status `json:"stacks_events"`
StackLogs map[int64]cloud.CommandLogs `json:"stacks_logs"`
}
DeploymentState is the state of a deployment.
type Drift ¶
type Drift struct {
ID int64 `json:"id"`
StackMetaID string `json:"stack_meta_id"`
StackTarget string `json:"stack_target"`
Status drift.Status `json:"status"`
Details *cloud.ChangesetDetails `json:"details"`
Metadata *cloud.DeploymentMetadata `json:"metadata"`
Command []string `json:"command"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
Drift model.
type Member ¶
type Member struct {
UserUUID cloud.UUID `json:"user_uuid"`
APIKey string `json:"apikey"`
Role string `json:"role"`
Status string `json:"status"`
MemberID int64 // implicit from the members list position index.
Org *Org // back-pointer set while retrieving memberships.
}
Member represents the organization member.
type Org ¶
type Org struct {
UUID cloud.UUID `json:"uuid"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Domain string `json:"domain"`
Status string `json:"status"`
Members []Member `json:"members"`
Stacks []Stack `json:"stacks"`
Deployments map[cloud.UUID]*Deployment `json:"deployments"`
Drifts []Drift `json:"drifts"`
Previews []Preview `json:"previews"`
ReviewRequests []cloud.ReviewRequest `json:"review_requests"`
Outputs map[string]cloud.StoreOutput `json:"outputs"` // map of (encoded key) -> output'
}
Org is the organization model.
type OutputKey ¶ added in v0.12.0
type OutputKey struct {
OrgUUID cloud.UUID `json:"org_uuid"`
Repository string `json:"repository"`
StackMetaID string `json:"stack_meta_id"`
Target string `json:"target"`
Name string `json:"name"`
}
OutputKey is the primary key of an output.
type Preview ¶ added in v0.5.4
type Preview struct {
PreviewID string `json:"preview_id"`
PushedAt int64 `json:"pushed_at"`
CommitSHA string `json:"commit_sha"`
Technology string `json:"technology"`
TechnologyLayer string `json:"technology_layer"`
ReviewRequest *cloud.ReviewRequest `json:"review_request,omitempty"`
Metadata *cloud.DeploymentMetadata `json:"metadata,omitempty"`
StackPreviews []*StackPreview `json:"stack_previews"`
}
Preview is the preview model.
type Stack ¶
type Stack struct {
cloud.Stack
State StackState `json:"state"`
}
Stack is the stack representation.
type StackPreview ¶ added in v0.5.4
type StackPreview struct {
Stack
ID string `json:"stack_preview_id"`
Status preview.StackStatus `json:"status"`
Cmd []string `json:"cmd,omitempty"`
ChangesetDetails *cloud.ChangesetDetails `json:"changeset_details,omitempty"`
Logs cloud.CommandLogs `json:"logs,omitempty"`
}
StackPreview is the stack preview model.
type StackState ¶
type StackState struct {
Status stack.Status `json:"status"`
DeploymentStatus deployment.Status `json:"deployment_status"`
DriftStatus drift.Status `json:"drift_status"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
SeenAt *time.Time `json:"seen_at,omitempty"`
}
StackState represents the state of the stack.