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) 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 EmptyResponse
- type GitHubMetadata
- type MemberOrganization
- type MemberOrganizations
- type Resource
- type Stack
- 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" // 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) 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 GitHubMetadata
DeploymentMetadata stores the metadata available in the target platform. For now, we only support GitHub 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 {
CommitSHA string `json:"commit_sha,omitempty"`
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"`
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 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 GitHubMetadata ¶ added in v0.4.1
type GitHubMetadata struct {
Platform string `json:"platform"`
PullRequestAuthorLogin string `json:"pull_request_author_login,omitempty"`
PullRequestAuthorAvatarURL string `json:"pull_request_author_avatar_url,omitempty"`
PullRequestAuthorGravatarID string `json:"pull_request_author_gravatar_id,omitempty"`
PullRequestHeadLabel string `json:"pull_request_head_label,omitempty"`
PullRequestHeadRef string `json:"pull_request_head_ref,omitempty"`
PullRequestHeadSHA string `json:"pull_request_head_sha,omitempty"`
PullRequestHeadAuthorLogin string `json:"pull_request_head_author_login,omitempty"`
PullRequestHeadAuthorAvatarURL string `json:"pull_request_head_author_avatar_url,omitempty"`
PullRequestHeadAuthorGravatarID string `json:"pull_request_head_author_gravatar_id,omitempty"`
PullRequestBaseLabel string `json:"pull_request_base_label,omitempty"`
PullRequestBaseRef string `json:"pull_request_base_ref,omitempty"`
PullRequestBaseSHA string `json:"pull_request_base_sha,omitempty"`
PullRequestBaseAuthorLogin string `json:"pull_request_base_author_login,omitempty"`
PullRequestBaseAuthorAvatarURL string `json:"pull_request_base_author_avatar_url,omitempty"`
PullRequestBaseAuthorGravatarID string `json:"pull_request_base_author_gravatar_id,omitempty"`
PullRequestCreatedAt time.Time `json:"pull_request_created_at,omitempty"`
PullRequestUpdatedAt time.Time `json:"pull_request_updated_at,omitempty"`
PullRequestClosedAt time.Time `json:"pull_request_closed_at,omitempty"`
PullRequestMergedAt time.Time `json:"pull_request_merged_at,omitempty"`
DeploymentBranch string `json:"deployment_branch,omitempty"`
DeploymentCommitVerified *bool `json:"deployment_commit_verified,omitempty"`
DeploymentCommitVerifiedReason string `json:"deployment_commit_verified_reason,omitempty"`
DeploymentCommitTitle string `json:"deployment_commit_title,omitempty"`
DeploymentCommitDescription string `json:"deployment_commit_description,omitempty"`
DeploymentCommitAuthorLogin string `json:"deployment_commit_author_login,omitempty"`
DeploymentCommitAuthorAvatarURL string `json:"deployment_commit_author_avatar_url,omitempty"`
DeploymentCommitAuthorGravatarID string `json:"deployment_commit_author_gravatar_id,omitempty"`
DeploymentCommitAuthorGitName string `json:"deployment_commit_author_git_name,omitempty"`
DeploymentCommitAuthorGitEmail string `json:"deployment_commit_author_git_email,omitempty"`
DeploymentCommitAuthorGitDate time.Time `json:"deployment_commit_author_git_date,omitempty"`
DeploymentCommitCommitterLogin string `json:"deployment_commit_committer_login,omitempty"`
DeploymentCommitCommitterAvatarURL string `json:"deployment_commit_committer_avatar_url,omitempty"`
DeploymentCommitCommitterGravatarID string `json:"deployment_commit_committer_gravatar_id,omitempty"`
DeploymentCommitCommitterGitName string `json:"deployment_commit_committer_git_name,omitempty"`
DeploymentCommitCommitterGitEmail string `json:"deployment_commit_committer_git_email,omitempty"`
DeploymentCommitCommitterGitDate time.Time `json:"deployment_commit_committer_git_date,omitempty"`
DeploymentTriggeredBy string `json:"deployment_triggered_by,omitempty"`
}
GitHubMetadata stores the GitHub related metadata.
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 {
ID int `json:"stack_id"`
Repository string `json:"repository"`
Path string `json:"path"`
MetaID string `json:"meta_id"`
MetaName string `json:"meta_name"`
MetaDescription string `json:"meta_description"`
MetaTags []string `json:"meta_tags"`
Status stack.Status `json:"status"`
// readonly fields
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
SeenAt time.Time `json:"seen_at"`
}
Stack represents a stack in the Terramate Cloud.
type StacksResponse ¶ added in v0.4.1
type StacksResponse struct {
Stacks []Stack `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. |