cloud

package
v0.9.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package cloud implements a client SDK for communication with the cloud API.

Package cloud implements the SDK for communicating with the Terramate Cloud.

Index

Constants

View Source
const (
	// WellKnownCLIPath is the well-known base path.
	WellKnownCLIPath = "/.well-known/cli.json"

	// UsersPath is the users endpoint base path.
	UsersPath = "/v1/users"
	// MembershipsPath is the memberships endpoint base path.
	MembershipsPath = "/v1/memberships"
	// DeploymentsPath is the deployments endpoint base path.
	DeploymentsPath = "/v1/deployments"
	// DriftsPath is the drifts endpoint base path.
	DriftsPath = "/v1/drifts"
	// StacksPath is the stacks endpoint base path.
	StacksPath = "/v1/stacks"
	// ReviewRequestsPath is the review requests endpoint base path.
	ReviewRequestsPath = "/v1/review_requests"
)
View Source
const (
	// PreviewsPath is the previews endpoints base path.
	PreviewsPath = "/v1/previews"
	// StackPreviewsPath is the stack previews endpoint base path.
	StackPreviewsPath = "/v1/stack_previews"
)
View Source
const BaseURL = "https://" + Host

BaseURL is the default cloud.terramate.io base API URL.

View Source
const DefaultLogBatchSize = 256

DefaultLogBatchSize is the default batch size.

View Source
const DefaultLogSyncInterval = 1 * time.Second

DefaultLogSyncInterval is the maximum idle duration before a sync could happen.

View Source
const ErrNotFound errors.Kind = "resource not found (HTTP Status 404)"

ErrNotFound indicates the requested resource does not exist in the server.

View Source
const ErrUnexpectedResponseBody errors.Kind = "unexpected API response body"

ErrUnexpectedResponseBody indicates the server responded with an unexpected body.

View Source
const ErrUnexpectedStatus errors.Kind = "unexpected status code"

ErrUnexpectedStatus indicates the server responded with an unexpected status code.

View Source
const Host = "api.terramate.io"

Host of the official Terramate Cloud API.

Variables

This section is empty.

Functions

func Get

func Get[T Resource](ctx context.Context, client *Client, u url.URL) (entity T, err error)

Get requests the endpoint components list making a GET request and decode the response into the entity T if validates successfully.

func NormalizeGitURI

func NormalizeGitURI(raw string) string

NormalizeGitURI normalizes the raw uri in a Terramate Cloud compatible form.

func Patch

func Patch[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error)

Patch requests the endpoint components list making a PATCH request and decode the response into the entity T if validates successfully.

func Post

func Post[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error)

Post requests the endpoint components list making a POST request and decode the response into the entity T if validates successfully.

func Put added in v0.4.1

func Put[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error)

Put requests the endpoint components list making a PUT request and decode the response into the entity T if validated successfully.

func Request

func Request[T Resource](ctx context.Context, c *Client, method string, url url.URL, postBody io.Reader) (entity T, err error)

Request makes a request to the Terramate Cloud using client. The instantiated type gets decoded and return as the entity T,

Types

type ChangesetDetails added in v0.4.5

type ChangesetDetails struct {
	Provisioner    string `json:"provisioner"`
	ChangesetASCII string `json:"changeset_ascii,omitempty"`
	ChangesetJSON  string `json:"changeset_json,omitempty"`
}

ChangesetDetails represents the details of a changeset (e.g. the terraform plan).

func (ChangesetDetails) Validate added in v0.4.5

func (ds ChangesetDetails) Validate() error

Validate the drift details.

type Client

type Client struct {
	// BaseURL is the cloud base endpoint URL.
	// If not set, it defaults to [BaseURL].
	BaseURL    string
	IDPKey     string
	Credential Credential

	// HTTPClient is the HTTP client reused in all connections.
	// if not set, a new instance of http.Client is created on the first request.
	HTTPClient *http.Client

	Logger *zerolog.Logger
	// contains filtered or unexported fields
}

Client is the cloud SDK client.

func (*Client) CheckVersion added in v0.4.4

func (c *Client) CheckVersion(ctx context.Context) error

CheckVersion checks if current Terramate version can be used to communicate with the cloud.

func (*Client) CreateDeploymentStacks

func (c *Client) CreateDeploymentStacks(
	ctx context.Context,
	orgUUID UUID,
	deploymentUUID UUID,
	deploymentStacksPayload DeploymentStacksPayloadRequest,
) (DeploymentStacksResponse, error)

CreateDeploymentStacks creates a new deployment for provided stacks payload.

func (*Client) CreatePreview added in v0.5.0

func (c *Client) CreatePreview(ctx context.Context, opts CreatePreviewOpts) (*CreatedPreview, error)

CreatePreview creates a new preview in the cloud

func (*Client) CreateStackDrift added in v0.4.2

func (c *Client) CreateStackDrift(
	ctx context.Context,
	orgUUID UUID,
	driftPayload DriftStackPayloadRequest,
) (EmptyResponse, error)

CreateStackDrift pushes a new drift status for the given stack.

func (*Client) DriftDetails added in v0.4.3

func (c *Client) DriftDetails(ctx context.Context, orgUUID UUID, stackID int64, driftID int64) (Drift, error)

DriftDetails retrieves details of the given driftID.

func (*Client) GetStack added in v0.4.3

func (c *Client) GetStack(ctx context.Context, orgUUID UUID, repo, target, metaID string) (StackObject, bool, error)

GetStack retrieves the details of the stack with given repo and metaID.

func (*Client) ListReviewRequests added in v0.5.0

func (c *Client) ListReviewRequests(ctx context.Context, orgUUID UUID) (ReviewRequestResponses, error)

ListReviewRequests retrieves the review requests for the given organization.

func (*Client) MemberOrganizations

func (c *Client) MemberOrganizations(ctx context.Context) (orgs MemberOrganizations, err error)

MemberOrganizations returns all organizations which are associated with the user.

func (*Client) StackLastDrift added in v0.4.4

func (c *Client) StackLastDrift(ctx context.Context, orgUUID UUID, stackID int64) (DriftsStackPayloadResponse, error)

StackLastDrift returns the drifts of the given stack.

func (*Client) StacksByStatus added in v0.4.3

func (c *Client) StacksByStatus(ctx context.Context, orgUUID UUID, repository string, target string, status stack.FilterStatus) ([]StackObject, error)

StacksByStatus returns all stacks for the given organization. It paginates as needed and returns the total stacks response.

func (*Client) SyncCommandLogs added in v0.5.0

func (c *Client) SyncCommandLogs(
	ctx context.Context,
	orgUUID UUID,
	stackID int64,
	deploymentUUID UUID,
	logs CommandLogs,
	stackPreviewID string,
) error

SyncCommandLogs sends a batch of command logs to Terramate Cloud.

func (*Client) URL added in v0.4.4

func (c *Client) URL(path string, queries ...url.Values) url.URL

URL builds an URL for the given path and queries from the client's base URL.

func (*Client) UpdateDeploymentStacks

func (c *Client) UpdateDeploymentStacks(ctx context.Context, orgUUID UUID, deploymentUUID UUID, payload UpdateDeploymentStacks) error

UpdateDeploymentStacks updates the deployment status of each stack in the payload set.

func (*Client) UpdateStackPreview added in v0.5.0

func (c *Client) UpdateStackPreview(ctx context.Context, opts UpdateStackPreviewOpts) error

UpdateStackPreview updates a stack preview in the cloud.

func (*Client) Users

func (c *Client) Users(ctx context.Context) (user User, err error)

Users retrieves the user details for the signed in user.

type CommandLog added in v0.5.0

type CommandLog struct {
	Line      int64      `json:"log_line"`
	Timestamp *time.Time `json:"timestamp"`
	Channel   LogChannel `json:"channel"`
	Message   string     `json:"message"`
}

CommandLog represents a single log message.

func (CommandLog) Validate added in v0.5.0

func (l CommandLog) Validate() error

Validate a command log.

type CommandLogs added in v0.5.0

type CommandLogs []*CommandLog

CommandLogs represents a batch of log messages.

func (CommandLogs) Validate added in v0.5.0

func (ls CommandLogs) Validate() error

Validate a list of command logs.

type CreatePreviewOpts added in v0.5.0

type CreatePreviewOpts struct {
	Runs            []RunContext
	AffectedStacks  map[string]*config.Stack
	OrgUUID         UUID
	UpdatedAt       int64
	PushedAt        int64
	CommitSHA       string
	Technology      string
	TechnologyLayer string
	Repository      string
	Target          string
	FromTarget      string
	DefaultBranch   string
	ReviewRequest   *ReviewRequest
	Metadata        *DeploymentMetadata
}

CreatePreviewOpts is the options for the CreatePreview function

type CreatePreviewPayloadRequest added in v0.5.0

type CreatePreviewPayloadRequest struct {
	CommitSHA       string              `json:"commit_sha"`
	PushedAt        int64               `json:"pushed_at"`
	UpdatedAt       int64               `json:"updated_at"`
	Technology      string              `json:"technology"`
	TechnologyLayer string              `json:"technology_layer"`
	ReviewRequest   *ReviewRequest      `json:"review_request,omitempty"`
	Metadata        *DeploymentMetadata `json:"metadata,omitempty"`
	Stacks          PreviewStacks       `json:"stacks"`
}

CreatePreviewPayloadRequest is the request payload for the creation of stack deployments.

func (CreatePreviewPayloadRequest) Validate added in v0.5.0

func (r CreatePreviewPayloadRequest) Validate() error

Validate the CreatePreviewPayloadRequest object.

type CreatePreviewResponse added in v0.5.0

type CreatePreviewResponse struct {
	PreviewID string                `json:"preview_id"`
	Stacks    ResponsePreviewStacks `json:"stacks"`
}

CreatePreviewResponse represents the deployment creation response item.

func (CreatePreviewResponse) Validate added in v0.5.0

func (r CreatePreviewResponse) Validate() error

Validate validates the CreatePreviewResponse payload

type CreatedPreview added in v0.5.0

type CreatedPreview struct {
	ID                    string
	StackPreviewsByMetaID map[string]string
}

CreatedPreview is the result of CreatePreview

type Credential

type Credential interface {
	// Token retrieves a new token ready be used (the credential provider must refresh the token if needed)
	Token() (string, error)
}

Credential is the interface for the credential providers.

type DeploymentMetadata added in v0.4.1

type DeploymentMetadata struct {
	GitMetadata

	GithubPullRequestAuthorLogin      string `json:"github_pull_request_author_login,omitempty"`
	GithubPullRequestAuthorAvatarURL  string `json:"github_pull_request_author_avatar_url,omitempty"`
	GithubPullRequestAuthorGravatarID string `json:"github_pull_request_author_gravatar_id,omitempty"`

	GithubPullRequestURL            string `json:"github_pull_request_url,omitempty"`
	GithubPullRequestNumber         int    `json:"github_pull_request_number,omitempty"`
	GithubPullRequestTitle          string `json:"github_pull_request_title,omitempty"`
	GithubPullRequestDescription    string `json:"github_pull_request_description,omitempty"`
	GithubPullRequestState          string `json:"github_pull_request_state,omitempty"`
	GithubPullRequestMergeCommitSHA string `json:"github_pull_request_merge_commit_sha,omitempty"`

	GithubPullRequestHeadLabel            string `json:"github_pull_request_head_label,omitempty"`
	GithubPullRequestHeadRef              string `json:"github_pull_request_head_ref,omitempty"`
	GithubPullRequestHeadSHA              string `json:"github_pull_request_head_sha,omitempty"`
	GithubPullRequestHeadAuthorLogin      string `json:"github_pull_request_head_author_login,omitempty"`
	GithubPullRequestHeadAuthorAvatarURL  string `json:"github_pull_request_head_author_avatar_url,omitempty"`
	GithubPullRequestHeadAuthorGravatarID string `json:"github_pull_request_head_author_gravatar_id,omitempty"`

	GithubPullRequestBaseLabel            string `json:"github_pull_request_base_label,omitempty"`
	GithubPullRequestBaseRef              string `json:"github_pull_request_base_ref,omitempty"`
	GithubPullRequestBaseSHA              string `json:"github_pull_request_base_sha,omitempty"`
	GithubPullRequestBaseAuthorLogin      string `json:"github_pull_request_base_author_login,omitempty"`
	GithubPullRequestBaseAuthorAvatarURL  string `json:"github_pull_request_base_author_avatar_url,omitempty"`
	GithubPullRequestBaseAuthorGravatarID string `json:"github_pull_request_base_author_gravatar_id,omitempty"`

	GithubPullRequestCreatedAt *time.Time `json:"github_pull_request_created_at,omitempty"`
	GithubPullRequestUpdatedAt *time.Time `json:"github_pull_request_updated_at,omitempty"`
	GithubPullRequestClosedAt  *time.Time `json:"github_pull_request_closed_at,omitempty"`
	GithubPullRequestMergedAt  *time.Time `json:"github_pull_request_merged_at,omitempty"`

	GithubCommitVerified       *bool  `json:"github_commit_verified,omitempty"`
	GithubCommitVerifiedReason string `json:"github_commit_verified_reason,omitempty"`

	GithubCommitTitle            string     `json:"github_commit_title,omitempty"`
	GithubCommitDescription      string     `json:"github_commit_description,omitempty"`
	GithubCommitAuthorLogin      string     `json:"github_commit_author_login,omitempty"`
	GithubCommitAuthorAvatarURL  string     `json:"github_commit_author_avatar_url,omitempty"`
	GithubCommitAuthorGravatarID string     `json:"github_commit_author_gravatar_id,omitempty"`
	GithubCommitAuthorGitName    string     `json:"github_commit_author_git_name,omitempty"`
	GithubCommitAuthorGitEmail   string     `json:"github_commit_author_git_email,omitempty"`
	GithubCommitAuthorGitDate    *time.Time `json:"github_commit_author_git_date,omitempty"`

	GithubCommitCommitterLogin      string     `json:"github_commit_committer_login,omitempty"`
	GithubCommitCommitterAvatarURL  string     `json:"github_commit_committer_avatar_url,omitempty"`
	GithubCommitCommitterGravatarID string     `json:"github_commit_committer_gravatar_id,omitempty"`
	GithubCommitCommitterGitName    string     `json:"github_commit_committer_git_name,omitempty"`
	GithubCommitCommitterGitEmail   string     `json:"github_commit_committer_git_email,omitempty"`
	GithubCommitCommitterGitDate    *time.Time `json:"github_commit_committer_git_date,omitempty"`

	GithubActionsDeploymentBranch      string `json:"github_actions_deployment_branch,omitempty"`
	GithubActionsDeploymentActor       string `json:"github_actions_deployment_actor,omitempty"`
	GithubActionsDeploymentTriggeredBy string `json:"github_actions_triggered_by,omitempty"`
	GithubActionsRunID                 string `json:"github_actions_run_id,omitempty"`
	GithubActionsRunAttempt            string `json:"github_actions_run_attempt,omitempty"`
	GithubActionsWorkflowName          string `json:"github_actions_workflow_name,omitempty"`
	GithubActionsWorkflowRef           string `json:"github_actions_workflow_ref,omitempty"`
}

DeploymentMetadata stores the metadata available in the target platform. It's marshaled as a flat hashmap of values. Note: no sensitive information must be stored here because it could be logged.

func (DeploymentMetadata) Validate added in v0.4.1

func (m DeploymentMetadata) Validate() error

Validate the metadata.

type DeploymentStackRequest

type DeploymentStackRequest struct {
	Stack

	CommitSHA         string            `json:"commit_sha,omitempty"`
	DeploymentURL     string            `json:"deployment_url,omitempty"`
	DeploymentStatus  deployment.Status `json:"deployment_status,omitempty"`
	DeploymentCommand string            `json:"deployment_cmd"`
}

DeploymentStackRequest represents the stack object of the request payload type for the creation of stack deployments.

func (DeploymentStackRequest) Validate

func (d DeploymentStackRequest) Validate() error

Validate the deployment stack request.

type DeploymentStackRequests

type DeploymentStackRequests []DeploymentStackRequest

DeploymentStackRequests is a list of DeploymentStacksRequest.

func (DeploymentStackRequests) Validate

func (d DeploymentStackRequests) Validate() error

Validate the list of deployment stack requests.

type DeploymentStackResponse

type DeploymentStackResponse struct {
	StackID     int64  `json:"stack_id"`
	StackMetaID string `json:"meta_id"`
	// TODO(snk): The target in the response is not handled yet. This needs to happen once we
	// support creating deployments with the same stack/meta_id on multiple targets.
	Target string            `json:"target"`
	Status deployment.Status `json:"status"`
}

DeploymentStackResponse represents the deployment creation response item.

func (DeploymentStackResponse) Validate

func (d DeploymentStackResponse) Validate() error

Validate the deployment stack response.

type DeploymentStacksPayloadRequest

type DeploymentStacksPayloadRequest struct {
	ReviewRequest *ReviewRequest          `json:"review_request,omitempty"`
	Stacks        DeploymentStackRequests `json:"stacks"`
	Workdir       project.Path            `json:"workdir"`
	Metadata      *DeploymentMetadata     `json:"metadata,omitempty"`
}

DeploymentStacksPayloadRequest is the request payload for the creation of stack deployments.

func (DeploymentStacksPayloadRequest) Validate

Validate the deployment stack payload.

type DeploymentStacksResponse

type DeploymentStacksResponse []DeploymentStackResponse

DeploymentStacksResponse represents the list of DeploymentStackResponse.

func (DeploymentStacksResponse) Validate

func (ds DeploymentStacksResponse) Validate() error

Validate the list of deployment stacks response.

type Drift added in v0.4.3

type Drift struct {
	ID       int64               `json:"id"`
	Status   drift.Status        `json:"status"`
	Details  *ChangesetDetails   `json:"drift_details,omitempty"`
	Metadata *DeploymentMetadata `json:"metadata,omitempty"`
}

Drift represents the drift information for a given stack.

func (Drift) Validate added in v0.4.3

func (d Drift) Validate() error

Validate a drift.

type DriftStackPayloadRequest added in v0.4.2

type DriftStackPayloadRequest struct {
	Stack      Stack               `json:"stack"`
	Status     drift.Status        `json:"drift_status"`
	Details    *ChangesetDetails   `json:"drift_details,omitempty"`
	Metadata   *DeploymentMetadata `json:"metadata,omitempty"`
	StartedAt  *time.Time          `json:"started_at,omitempty"`
	FinishedAt *time.Time          `json:"finished_at,omitempty"`
	Command    []string            `json:"command"`
}

DriftStackPayloadRequest is the payload for the drift sync.

func (DriftStackPayloadRequest) Validate added in v0.4.2

func (d DriftStackPayloadRequest) Validate() error

Validate the drift request payload.

type DriftStackPayloadRequests added in v0.4.2

type DriftStackPayloadRequests []DriftStackPayloadRequest

DriftStackPayloadRequests is a list of DriftStackPayloadRequest

func (DriftStackPayloadRequests) Validate added in v0.4.2

func (ds DriftStackPayloadRequests) Validate() error

Validate the list of drift requests.

type Drifts added in v0.4.3

type Drifts []Drift

Drifts is a list of drift.

func (Drifts) Validate added in v0.4.3

func (ds Drifts) Validate() error

Validate a list of drifts.

type DriftsStackPayloadResponse added in v0.4.3

type DriftsStackPayloadResponse struct {
	Drifts     Drifts          `json:"drifts"`
	Pagination PaginatedResult `json:"paginated_result"`
}

DriftsStackPayloadResponse is the payload returned when listing stack drifts.

func (DriftsStackPayloadResponse) Validate added in v0.4.3

func (ds DriftsStackPayloadResponse) Validate() error

Validate the drifts list response payload.

type EmptyResponse added in v0.4.1

type EmptyResponse string

EmptyResponse is used to represent an empty string response.

func (EmptyResponse) Validate added in v0.4.1

func (s EmptyResponse) Validate() error

Validate that content is empty.

type GitMetadata added in v0.5.0

type GitMetadata struct {
	GitCommitSHA         string     `json:"git_commit_sha,omitempty"`
	GitCommitAuthorName  string     `json:"git_commit_author_name,omitempty"`
	GitCommitAuthorEmail string     `json:"git_commit_author_email,omitempty"`
	GitCommitAuthorTime  *time.Time `json:"git_commit_author_time,omitempty"`
	GitCommitTitle       string     `json:"git_commit_title,omitempty"`
	GitCommitDescription string     `json:"git_commit_description,omitempty"`
}

GitMetadata are the git related metadata.

type Label added in v0.4.4

type Label struct {
	Name        string `json:"name"`
	Color       string `json:"color,omitempty"`
	Description string `json:"description,omitempty"`
}

Label of a review request.

func (Label) Validate added in v0.4.4

func (l Label) Validate() error

Validate the label.

type LogChannel added in v0.4.3

type LogChannel int

LogChannel is an enum-like type for the output channels supported.

const (
	StdoutLogChannel LogChannel // StdoutLogChannel is the stdout channel
	StderrLogChannel            // StderrLogChannel is the stderr channel
)

func (*LogChannel) MarshalJSON added in v0.4.3

func (c *LogChannel) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (LogChannel) String added in v0.4.3

func (c LogChannel) String() string

String returns the channel name.

func (*LogChannel) UnmarshalJSON added in v0.4.3

func (c *LogChannel) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type LogSyncer added in v0.4.3

type LogSyncer struct {
	// contains filtered or unexported fields
}

LogSyncer is the log syncer controller type.

func NewLogSyncer added in v0.4.3

func NewLogSyncer(syncfn Syncer) *LogSyncer

NewLogSyncer creates a new log syncer.

func NewLogSyncerWith added in v0.4.3

func NewLogSyncerWith(
	syncfn Syncer,
	batchSize int,
	syncInterval time.Duration,
) *LogSyncer

NewLogSyncerWith creates a new customizable syncer.

func (*LogSyncer) NewBuffer added in v0.4.3

func (s *LogSyncer) NewBuffer(channel LogChannel, out io.Writer) io.Writer

NewBuffer creates a new synchronized buffer.

func (*LogSyncer) Wait added in v0.4.3

func (s *LogSyncer) Wait()

Wait waits for the processing of all log messages. After calling this method, it's not safe to call any other method, as it closes the internal channels and shutdown all goroutines.

type MemberOrganization

type MemberOrganization struct {
	MemberID    int64  `json:"member_id,omitempty"`
	Name        string `json:"org_name"`
	DisplayName string `json:"org_display_name"`
	Domain      string `json:"org_domain"`
	UUID        UUID   `json:"org_uuid"`
	Role        string `json:"role,omitempty"`
	Status      string `json:"status"`
}

MemberOrganization represents the organization associated with the member.

func (MemberOrganization) Validate

func (org MemberOrganization) Validate() error

Validate checks if at least the fields required by Terramate CLI are set.

type MemberOrganizations

type MemberOrganizations []MemberOrganization

MemberOrganizations is a list of organizations associated with the member.

func (MemberOrganizations) String

func (orgs MemberOrganizations) String() string

String is a human readable list of organizations associated with a user.

func (MemberOrganizations) Validate

func (orgs MemberOrganizations) Validate() error

Validate if the organization list is valid.

type PaginatedResult added in v0.4.4

type PaginatedResult struct {
	Total   int64 `json:"total"`
	Page    int64 `json:"page"`
	PerPage int64 `json:"per_page"`
}

PaginatedResult represents the pagination object.

func (PaginatedResult) Validate added in v0.4.4

func (p PaginatedResult) Validate() error

Validate the "paginate_result" field.

type PreviewStack added in v0.5.0

type PreviewStack struct {
	Stack

	PreviewStatus preview.StackStatus `json:"preview_status"`
	Cmd           []string            `json:"cmd,omitempty"`
}

PreviewStack represents the stack object of the request payload type for the creation of stack deployments.

type PreviewStacks added in v0.5.0

type PreviewStacks []PreviewStack

PreviewStacks is a list of stack objects for the request payload

func (PreviewStacks) Validate added in v0.5.0

func (s PreviewStacks) Validate() error

Validate the PreviewStacks object.

type Resource

type Resource interface {
	Validate() error
}

Resource is the interface used to represent resource entities.

type ResponsePreviewStack added in v0.5.0

type ResponsePreviewStack struct {
	MetaID         string `json:"meta_id"`
	StackPreviewID string `json:"stack_preview_id"`
}

ResponsePreviewStack represents a specific stack in the preview response.

type ResponsePreviewStacks added in v0.5.0

type ResponsePreviewStacks []ResponsePreviewStack

ResponsePreviewStacks is a list of stack objects in the response payload

func (ResponsePreviewStacks) Validate added in v0.5.0

func (s ResponsePreviewStacks) Validate() error

Validate the ResponsePreviewStacks object.

type ReviewRequest added in v0.5.0

type ReviewRequest struct {
	Platform              string     `json:"platform"`
	Repository            string     `json:"repository"`
	CommitSHA             string     `json:"commit_sha"`
	Number                int        `json:"number"`
	Title                 string     `json:"title"`
	Description           string     `json:"description"`
	URL                   string     `json:"url"`
	Labels                []Label    `json:"labels,omitempty"`
	Reviewers             Reviewers  `json:"reviewers,omitempty"`
	Status                string     `json:"status"`
	Draft                 bool       `json:"draft"`
	ReviewDecision        string     `json:"review_decision,omitempty"`
	ChangesRequestedCount int        `json:"changes_requested_count"`
	ApprovedCount         int        `json:"approved_count"`
	ChecksTotalCount      int        `json:"checks_total_count"`
	ChecksFailureCount    int        `json:"checks_failure_count"`
	ChecksSuccessCount    int        `json:"checks_success_count"`
	UpdatedAt             *time.Time `json:"updated_at,omitempty"`
	PushedAt              *time.Time `json:"pushed_at,omitempty"`
}

ReviewRequest is the review_request object.

func (ReviewRequest) Validate added in v0.5.0

func (rr ReviewRequest) Validate() error

Validate the DeploymentReviewRequest object.

type ReviewRequestResponse added in v0.5.0

type ReviewRequestResponse struct {
	ID        int64  `json:"review_request_id"`
	CommitSHA string `json:"commit_sha"`
	Number    int    `json:"number"`
}

ReviewRequestResponse is the response payload for the review request creation.

func (ReviewRequestResponse) Validate added in v0.5.0

func (rr ReviewRequestResponse) Validate() error

Validate the ReviewRequestResponse object.

type ReviewRequestResponsePayload added in v0.5.0

type ReviewRequestResponsePayload struct {
	ReviewRequests ReviewRequestResponses `json:"review_requests"`
	Pagination     PaginatedResult        `json:"paginated_result"`
}

ReviewRequestResponsePayload is the review request response payload.

func (ReviewRequestResponsePayload) Validate added in v0.5.0

func (rr ReviewRequestResponsePayload) Validate() error

Validate the review request response payload.

type ReviewRequestResponses added in v0.5.0

type ReviewRequestResponses []ReviewRequestResponse

ReviewRequestResponses is a list of review request responses.

func (ReviewRequestResponses) Validate added in v0.5.0

func (rrs ReviewRequestResponses) Validate() error

Validate the list of review request responses.

type Reviewer added in v0.4.4

type Reviewer struct {
	Login     string `json:"login"`
	AvatarURL string `json:"avatar_url,omitempty"`
}

Reviewer is the user's reviewer of a Pull/Merge Request.

func (Reviewer) Validate added in v0.4.4

func (r Reviewer) Validate() error

Validate the reviewer.

type Reviewers added in v0.4.4

type Reviewers []Reviewer

Reviewers is a list of reviewers.

func (Reviewers) Validate added in v0.4.4

func (rs Reviewers) Validate() error

Validate the reviewers list.

type RunContext added in v0.5.0

type RunContext struct {
	Stack *config.Stack
	Cmd   []string
}

RunContext is the context for a run

type Stack

type Stack struct {
	Repository      string   `json:"repository"`
	Target          string   `json:"target,omitempty"`
	FromTarget      string   `json:"from_target,omitempty"`
	DefaultBranch   string   `json:"default_branch"`
	Path            string   `json:"path"`
	MetaID          string   `json:"meta_id"`
	MetaName        string   `json:"meta_name,omitempty"`
	MetaDescription string   `json:"meta_description,omitempty"`
	MetaTags        []string `json:"meta_tags,omitempty"`
}

Stack represents the stack as defined by the user HCL code.

func (Stack) Validate

func (s Stack) Validate() error

Validate the stack object.

type StackObject added in v0.4.4

type StackObject struct {
	ID int64 `json:"stack_id"`
	Stack
	Status           stack.Status      `json:"status"`
	DeploymentStatus deployment.Status `json:"deployment_status"`
	DriftStatus      drift.Status      `json:"drift_status"`

	// readonly fields
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	SeenAt    *time.Time `json:"seen_at,omitempty"`
}

StackObject represents a stack object in the Terramate Cloud.

func (StackObject) Validate added in v0.4.4

func (stack StackObject) Validate() error

Validate the stack entity.

type StacksResponse added in v0.4.1

type StacksResponse struct {
	Stacks     []StackObject   `json:"stacks"`
	Pagination PaginatedResult `json:"paginated_result"`
}

StacksResponse represents the stacks object response.

func (StacksResponse) Validate added in v0.4.1

func (stacksResp StacksResponse) Validate() error

Validate the StacksResponse object.

type Syncer added in v0.4.3

type Syncer func(l CommandLogs)

Syncer is the actual synchronizer callback.

type UUID added in v0.4.4

type UUID string

UUID represents an UUID string.

type UpdateDeploymentStack

type UpdateDeploymentStack struct {
	StackID int64             `json:"stack_id"`
	Status  deployment.Status `json:"status"`
	Details *ChangesetDetails `json:"changeset_details,omitempty"`
}

UpdateDeploymentStack is the request payload item for updating the deployment status.

func (UpdateDeploymentStack) Validate

func (d UpdateDeploymentStack) Validate() error

Validate the UpdateDeploymentStack object.

type UpdateDeploymentStacks

type UpdateDeploymentStacks struct {
	Stacks []UpdateDeploymentStack `json:"stacks"`
}

UpdateDeploymentStacks is the request payload for updating the deployment status.

func (UpdateDeploymentStacks) Validate

func (ds UpdateDeploymentStacks) Validate() error

Validate the list of UpdateDeploymentStack.

type UpdateStackPreviewOpts added in v0.5.0

type UpdateStackPreviewOpts struct {
	OrgUUID          UUID
	StackPreviewID   string
	Status           preview.StackStatus
	ChangesetDetails *ChangesetDetails
}

UpdateStackPreviewOpts is the options for UpdateStackPreview

type UpdateStackPreviewPayloadRequest added in v0.5.0

type UpdateStackPreviewPayloadRequest struct {
	Status           string            `json:"status"`
	ChangesetDetails *ChangesetDetails `json:"changeset_details,omitempty"`
}

UpdateStackPreviewPayloadRequest is the request payload for the update of stack previews.

func (UpdateStackPreviewPayloadRequest) Validate added in v0.5.0

Validate the UpdateStackPreviewPayloadRequest object.

type User

type User struct {
	Email       string `json:"email"`
	DisplayName string `json:"display_name"`
	JobTitle    string `json:"job_title"`
	UUID        UUID   `json:"user_uuid"`
}

User represents the signed in user information.

func (User) Validate

func (u User) Validate() error

Validate if the user has the Terramate CLI required fields.

type WellKnown added in v0.4.4

type WellKnown struct {
	RequiredVersion string `json:"required_version"`
}

WellKnown is the well-known payload for cli.json.

func (WellKnown) Validate added in v0.4.4

func (wk WellKnown) Validate() error

Validate the well-known payload.

Directories

Path Synopsis
Package deployment provides types and helpers for cloud deployments.
Package deployment provides types and helpers for cloud deployments.
Package drift provides types and helpers for cloud drifts.
Package drift provides types and helpers for cloud drifts.
Package preview contains functionality for the preview feature in Terramate Cloud.
Package preview contains functionality for the preview feature in Terramate Cloud.
Package stack provides types and helpers for cloud stacks.
Package stack provides types and helpers for cloud stacks.
Package testserver provides fake Terramate Cloud endpoints for testing purposes.
Package testserver provides fake Terramate Cloud endpoints for testing purposes.
cloudstore
Package cloudstore provides the in-memory store used by the fake Terramate Cloud server.
Package cloudstore provides the in-memory store used by the fake Terramate Cloud server.
cmd/testserver
Package main implements the cloudmock service.
Package main implements the cloudmock service.

Jump to

Keyboard shortcuts

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