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
- func Get[T Resource](ctx context.Context, client *Client, endpoint ...string) (entity T, err error)
- func NormalizeGitURI(raw string) string
- func Patch[T Resource](ctx context.Context, client *Client, payload interface{}, endpoint ...string) (entity T, err error)
- func Post[T Resource](ctx context.Context, client *Client, payload interface{}, endpoint ...string) (entity T, err error)
- func Put[T Resource](ctx context.Context, client *Client, payload interface{}, endpoint ...string) (entity T, err error)
- func Request[T Resource](ctx context.Context, c *Client, method string, resourceURL string, ...) (entity T, err error)
- type Client
- func (c *Client) CreateDeploymentStacks(ctx context.Context, orgUUID string, deploymentUUID string, ...) (DeploymentStacksResponse, error)
- func (c *Client) CreateStackDrift(ctx context.Context, orgUUID string, driftPayload DriftStackPayloadRequest) (EmptyResponse, error)
- func (c *Client) MemberOrganizations(ctx context.Context) (orgs MemberOrganizations, err error)
- func (c *Client) Stacks(ctx context.Context, orgUUID string, status stack.FilterStatus) (StacksResponse, error)
- func (c *Client) UpdateDeploymentStacks(ctx context.Context, orgUUID string, deploymentUUID string, ...) error
- func (c *Client) Users(ctx context.Context) (user User, err error)
- type Credential
- type DeploymentMetadata
- type DeploymentReviewRequest
- type DeploymentStackRequest
- type DeploymentStackRequests
- type DeploymentStackResponse
- type DeploymentStacksPayloadRequest
- type DeploymentStacksResponse
- type DriftStackPayloadRequest
- type DriftStackPayloadRequests
- type EmptyResponse
- type MemberOrganization
- type MemberOrganizations
- type Resource
- type Stack
- type StackResponse
- type StacksResponse
- type UpdateDeploymentStack
- type UpdateDeploymentStacks
- type User
Constants ¶
const ( // 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" )
const BaseURL = "https://" + Host
BaseURL is the default cloud.terramate.io base API URL.
const ErrNotFound errors.Kind = "resource not found (HTTP Status 404)"
ErrNotFound indicates the requested resource does not exist in the server.
const ErrUnexpectedResponseBody errors.Kind = "unexpected API response body"
ErrUnexpectedResponseBody indicates the server responded with an unexpected body.
const ErrUnexpectedStatus errors.Kind = "unexpected status code"
ErrUnexpectedStatus indicates the server responded with an unexpected status code.
const Host = "api.terramate.io"
Host of the official Terramate Cloud API.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get requests the endpoint components list making a GET request and decode the response into the entity T if validates successfully.
func NormalizeGitURI ¶
NormalizeGitURI normalizes the raw uri in a Terramate Cloud compatible form.
func Patch ¶
func Patch[T Resource](ctx context.Context, client *Client, payload interface{}, endpoint ...string) (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{}, endpoint ...string) (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.
Types ¶
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
}
Client is the cloud SDK client.
func (*Client) CreateDeploymentStacks ¶
func (c *Client) CreateDeploymentStacks( ctx context.Context, orgUUID string, deploymentUUID string, deploymentStacksPayload DeploymentStacksPayloadRequest, ) (DeploymentStacksResponse, error)
CreateDeploymentStacks creates a new deployment for provided stacks payload.
func (*Client) CreateStackDrift ¶ added in v0.4.2
func (c *Client) CreateStackDrift( ctx context.Context, orgUUID string, driftPayload DriftStackPayloadRequest, ) (EmptyResponse, error)
CreateStackDrift pushes a new drift status for the given stack.
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) Stacks ¶ added in v0.4.1
func (c *Client) Stacks(ctx context.Context, orgUUID string, status stack.FilterStatus) (StacksResponse, error)
Stacks returns all stacks for the given organization.
func (*Client) UpdateDeploymentStacks ¶
func (c *Client) UpdateDeploymentStacks(ctx context.Context, orgUUID string, deploymentUUID string, payload UpdateDeploymentStacks) error
UpdateDeploymentStacks updates the deployment status of each stack in the payload set.
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 {
GitHeadCommitSHA string `json:"git_head_commit_sha,omitempty"`
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"`
GithubActionsDeploymentTriggeredBy string `json:"github_actions_triggered_by,omitempty"`
GithubActionsRunID string `json:"github_actions_run_id,omitempty"`
GithubActionsRunAttempt string `json:"github_actions_run_attempt,omitempty"`
}
DeploymentMetadata stores the metadata available in the target platform. For now, we only support GitHub and Github Actions Metadata. 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 DeploymentReviewRequest ¶
type DeploymentReviewRequest 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"`
}
DeploymentReviewRequest is the review_request object.
func (DeploymentReviewRequest) Validate ¶
func (rr DeploymentReviewRequest) Validate() error
Validate the DeploymentReviewRequest object.
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 int `json:"stack_id"`
StackMetaID string `json:"meta_id"`
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 *DeploymentReviewRequest `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 ¶
func (d DeploymentStacksPayloadRequest) Validate() error
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 DriftStackPayloadRequest ¶ added in v0.4.2
type DriftStackPayloadRequest struct {
Stack Stack `json:"stack"`
Status stack.Status `json:"drift_status"`
Metadata *DeploymentMetadata `json:"metadata,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 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 MemberOrganization ¶
type MemberOrganization struct {
MemberID int `json:"member_id,omitempty"`
Name string `json:"org_name"`
DisplayName string `json:"org_display_name"`
Domain string `json:"org_domain"`
UUID string `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 representation of the list of organization associated with the user.
func (MemberOrganizations) Validate ¶
func (orgs MemberOrganizations) Validate() error
Validate if the organization list is valid.
type Resource ¶
type Resource interface {
Validate() error
}
Resource is the interface used to represent resource entities.
type Stack ¶
type Stack struct {
Repository string `json:"repository"`
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.
type StackResponse ¶ added in v0.4.2
type StackResponse struct {
ID int `json:"stack_id"`
Stack
Status stack.Status `json:"status"`
// readonly fields
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
SeenAt *time.Time `json:"seen_at,omitempty"`
}
StackResponse represents a stack in the Terramate Cloud.
func (StackResponse) Validate ¶ added in v0.4.2
func (stack StackResponse) Validate() error
Validate the stack entity.
type StacksResponse ¶ added in v0.4.1
type StacksResponse struct {
Stacks []StackResponse `json:"stacks"`
}
StacksResponse represents the stacks object response.
func (StacksResponse) Validate ¶ added in v0.4.1
func (stacksResp StacksResponse) Validate() error
Validate the StacksResponse object.
type UpdateDeploymentStack ¶
type UpdateDeploymentStack struct {
StackID int `json:"stack_id"`
Status deployment.Status `json:"status"`
}
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package deployment provides types and helpers for cloud deployments.
|
Package deployment provides types and helpers for cloud deployments. |
|
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. |
|
cmd/fakecloud
command
Package main implements the cloudmock service.
|
Package main implements the cloudmock service. |