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 BaseDomain(region Region) string
- func BaseURL(region Region) string
- func HTMLURL(region Region) string
- type BufferGroup
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) CheckVersion(ctx context.Context) error
- func (c *Client) CreateDeploymentStacks(ctx context.Context, orgUUID resources.UUID, deploymentUUID resources.UUID, ...) (resources.DeploymentStacksResponse, error)
- func (c *Client) CreatePreview(ctx context.Context, opts CreatePreviewOpts) (*CreatedPreview, error)
- func (c *Client) CreateStackDrift(ctx context.Context, orgUUID resources.UUID, ...) (resources.EmptyResponse, error)
- func (c *Client) CreateStoreOutput(ctx context.Context, orgUUID resources.UUID, ...) (resources.StoreOutput, error)
- func (c *Client) Credential() http.Credential
- func (c *Client) DeleteStoreOutput(ctx context.Context, orgUUID resources.UUID, id resources.UUID) error
- func (c *Client) DriftDetails(ctx context.Context, orgUUID resources.UUID, stackID int64, driftID int64) (resources.Drift, error)
- func (c *Client) GetOrgSingleSignOnID(ctx context.Context, orgName string) (string, error)
- func (c *Client) GetStack(ctx context.Context, orgUUID resources.UUID, repo, target, metaID string) (resources.StackObject, bool, error)
- func (c *Client) GetStoreOutput(ctx context.Context, orgUUID resources.UUID, id resources.UUID) (resources.StoreOutput, error)
- func (c *Client) HTTPClient() *stdhttp.Client
- func (c *Client) ListReviewRequests(ctx context.Context, orgUUID resources.UUID) (resources.ReviewRequestResponses, error)
- func (c *Client) LookupStoreOutput(ctx context.Context, orgUUID resources.UUID, key resources.StoreOutputKey) (resources.StoreOutput, error)
- func (c *Client) MemberOrganizations(ctx context.Context) (orgs resources.MemberOrganizations, err error)
- func (c *Client) Region() Region
- func (c *Client) SetCredential(credential http.Credential)
- func (c *Client) StackLastDrift(ctx context.Context, orgUUID resources.UUID, stackID int64) (resources.DriftsStackPayloadResponse, error)
- func (c *Client) StacksByStatus(ctx context.Context, orgUUID resources.UUID, repository string, target string, ...) ([]resources.StackObject, error)
- func (c *Client) SyncCommandLogs(ctx context.Context, orgUUID resources.UUID, stackID int64, ...) error
- func (c *Client) URL(path string, queries ...url.Values) url.URL
- func (c *Client) UpdateDeploymentStacks(ctx context.Context, orgUUID resources.UUID, deploymentUUID resources.UUID, ...) error
- func (c *Client) UpdateStackPreview(ctx context.Context, opts UpdateStackPreviewOpts) error
- func (c *Client) UpdateStoreOutputValue(ctx context.Context, orgUUID resources.UUID, id resources.UUID, value string) error
- func (c *Client) Users(ctx context.Context) (user resources.User, err error)
- type CreatePreviewOpts
- type CreatedPreview
- type LogSyncer
- type Option
- type Options
- type Region
- type Regions
- type RunContext
- type SyncFunc
- type UpdateStackPreviewOpts
Constants ¶
const ( // PreviewsPath is the previews endpoints base path. PreviewsPath = "/v1/previews" // StackPreviewsPath is the stack previews endpoint base path. StackPreviewsPath = "/v1/stack_previews" )
const ( // WellKnownCLIPath is the well-known base path. WellKnownCLIPath = "/.well-known/cli.json" // SingleSignOnDetailByNamePath is the path to the organization SSO details. SingleSignOnDetailByNamePath = "/v1/organizations/name" // 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" // StorePath is the store endpoint base path. StorePath = "/v1/store" )
const DefaultLogBatchSize = 256
DefaultLogBatchSize is the default batch size.
const DefaultLogSyncInterval = 1 * time.Second
DefaultLogSyncInterval is the maximum idle duration before a sync could happen.
const DefaultTimeout = 60 * time.Second
DefaultTimeout is a (optional) good default timeout to be used by TMC clients.
Variables ¶
This section is empty.
Functions ¶
func BaseDomain ¶ added in v0.12.0
BaseDomain returns the official API base domain for the Terramate Cloud.
Types ¶
type BufferGroup ¶ added in v0.14.4
type BufferGroup struct {
// contains filtered or unexported fields
}
BufferGroup manages a group of synchronized buffers.
func NewBufferGroup ¶ added in v0.14.4
func NewBufferGroup(logSyncer *LogSyncer) *BufferGroup
NewBufferGroup creates a new buffer group with an optional LogSyncer.
func (*BufferGroup) NewBuffer ¶ added in v0.14.4
func (s *BufferGroup) NewBuffer(channel resources.LogChannel, out io.Writer) io.Writer
NewBuffer creates a new synchronized buffer.
func (*BufferGroup) Wait ¶ added in v0.14.4
func (s *BufferGroup) Wait()
Wait waits for the processing all output for the buffers within this group. If a LogSyncher is attached, it will also wait for it to finish. After calling this method, it's not safe to call any other method, as it closes the internal channels and shutdown all goroutines.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the cloud SDK client.
func NewClient ¶ added in v0.13.1
NewClient creates a new cloud client. It uses the default region (EU) and calls BaseURL(region) to set the base URL if WithBaseURL is not provided.
func (*Client) CheckVersion ¶ added in v0.4.4
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 resources.UUID, deploymentUUID resources.UUID, deploymentStacksPayload resources.DeploymentStacksPayloadRequest, ) (resources.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 resources.UUID, driftPayload resources.DriftStackPayloadRequest, ) (resources.EmptyResponse, error)
CreateStackDrift pushes a new drift status for the given stack.
func (*Client) CreateStoreOutput ¶ added in v0.12.0
func (c *Client) CreateStoreOutput(ctx context.Context, orgUUID resources.UUID, output resources.StoreOutputRequest) (resources.StoreOutput, error)
CreateStoreOutput creates a new output in the Terramate Cloud store.
func (*Client) Credential ¶
func (c *Client) Credential() http.Credential
Credential returns the cloud credential.
func (*Client) DeleteStoreOutput ¶ added in v0.12.0
func (c *Client) DeleteStoreOutput(ctx context.Context, orgUUID resources.UUID, id resources.UUID) error
DeleteStoreOutput deletes the output from the Terramate Cloud store.
func (*Client) DriftDetails ¶ added in v0.4.3
func (c *Client) DriftDetails(ctx context.Context, orgUUID resources.UUID, stackID int64, driftID int64) (resources.Drift, error)
DriftDetails retrieves details of the given driftID.
func (*Client) GetOrgSingleSignOnID ¶ added in v0.13.0
GetOrgSingleSignOnID returns the organization SSO ID.
func (*Client) GetStack ¶ added in v0.4.3
func (c *Client) GetStack(ctx context.Context, orgUUID resources.UUID, repo, target, metaID string) (resources.StackObject, bool, error)
GetStack retrieves the details of the stack with given repo and metaID.
func (*Client) GetStoreOutput ¶ added in v0.12.0
func (c *Client) GetStoreOutput(ctx context.Context, orgUUID resources.UUID, id resources.UUID) (resources.StoreOutput, error)
GetStoreOutput retrieves the output from the Terramate Cloud store.
func (*Client) HTTPClient ¶
HTTPClient returns the HTTP client used by the client.
func (*Client) ListReviewRequests ¶ added in v0.5.0
func (c *Client) ListReviewRequests(ctx context.Context, orgUUID resources.UUID) (resources.ReviewRequestResponses, error)
ListReviewRequests retrieves the review requests for the given organization.
func (*Client) LookupStoreOutput ¶ added in v0.12.0
func (c *Client) LookupStoreOutput(ctx context.Context, orgUUID resources.UUID, key resources.StoreOutputKey) (resources.StoreOutput, error)
LookupStoreOutput retrieves the output from the Terramate Cloud store by its key.
func (*Client) MemberOrganizations ¶
func (c *Client) MemberOrganizations(ctx context.Context) (orgs resources.MemberOrganizations, err error)
MemberOrganizations returns all organizations which are associated with the user.
func (*Client) SetCredential ¶ added in v0.13.1
func (c *Client) SetCredential(credential http.Credential)
SetCredential sets the client cloud credential.
func (*Client) StackLastDrift ¶ added in v0.4.4
func (c *Client) StackLastDrift(ctx context.Context, orgUUID resources.UUID, stackID int64) (resources.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 resources.UUID, repository string, target string, stackFilters resources.StatusFilters) ([]resources.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 resources.UUID, stackID int64, deploymentUUID resources.UUID, logs resources.CommandLogs, stackPreviewID string, ) error
SyncCommandLogs sends a batch of command logs to Terramate Cloud.
func (*Client) URL ¶ added in v0.4.4
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 resources.UUID, deploymentUUID resources.UUID, payload resources.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.
type CreatePreviewOpts ¶ added in v0.5.0
type CreatePreviewOpts struct {
Runs []RunContext
AffectedStacks map[string]resources.Stack
OrgUUID resources.UUID
PushedAt int64
CommitSHA string
Technology string
TechnologyLayer string
ReviewRequest *resources.ReviewRequest
Metadata *resources.DeploymentMetadata
}
CreatePreviewOpts is the options for the CreatePreview function
type CreatedPreview ¶ added in v0.5.0
CreatedPreview is the result of CreatePreview
type LogSyncer ¶ added in v0.4.3
type LogSyncer struct {
// contains filtered or unexported fields
}
LogSyncer synchronizes log lines, typically from a single buffer group.
func NewLogSyncer ¶ added in v0.4.3
NewLogSyncer creates a new log syncer with default parameters.
func NewLogSyncerWith ¶ added in v0.4.3
NewLogSyncerWith creates a new customizable syncer.
func (*LogSyncer) ProcessLine ¶ added in v0.14.4
func (s *LogSyncer) ProcessLine(channel resources.LogChannel, linenum int64, line []byte)
ProcessLine creates a new synchronized buffer.
type Option ¶ added in v0.13.1
type Option func(*Client)
Option is a functional option for the client.
func WithBaseURL ¶ added in v0.13.1
WithBaseURL sets the base URL to be used in the client.
func WithCredential ¶ added in v0.13.1
func WithCredential(credential http.Credential) Option
WithCredential sets the credential to be used in the client.
func WithHTTPClient ¶ added in v0.13.1
WithHTTPClient sets the HTTP client to be used in the client.
func WithLogger ¶ added in v0.13.1
WithLogger sets the logger to be used in the client.
func WithRegion ¶ added in v0.13.1
WithRegion sets the region to be used in the client.
type Region ¶ added in v0.12.0
type Region int
Region is the Terramate Cloud region (EU, US, etc).
const ( // For backward compatibility we want the zero value to be the default // if not set in the [cloud.Client] struct. EU Region = iota US )
Available cloud locations.
func ParseRegion ¶ added in v0.12.0
ParseRegion parses a user-supplied region name.
type Regions ¶ added in v0.12.0
type Regions []Region
Regions is a list of cloud regions.
func AvailableRegions ¶ added in v0.12.0
func AvailableRegions() Regions
AvailableRegions returns a list of available cloud regions.
type RunContext ¶ added in v0.5.0
RunContext is the context for a run
type SyncFunc ¶ added in v0.14.4
type SyncFunc func(l resources.CommandLogs)
SyncFunc is the actual synchronizer callback.
type UpdateStackPreviewOpts ¶ added in v0.5.0
type UpdateStackPreviewOpts struct {
OrgUUID resources.UUID
StackPreviewID string
Status preview.StackStatus
ChangesetDetails *resources.ChangesetDetails
}
UpdateStackPreviewOpts is the options for UpdateStackPreview
Directories
¶
| Path | Synopsis |
|---|---|
|
api
|
|
|
deployment
Package deployment provides types and helpers for cloud deployments.
|
Package deployment provides types and helpers for cloud deployments. |
|
drift
Package drift provides types and helpers for cloud drifts.
|
Package drift provides types and helpers for cloud drifts. |
|
metadata
Package metadata contains data structures for platform metadata that is sent to TMC, i.e.
|
Package metadata contains data structures for platform metadata that is sent to TMC, i.e. |
|
preview
Package preview contains functionality for the preview feature in Terramate Cloud.
|
Package preview contains functionality for the preview feature in Terramate Cloud. |
|
resources
Package resources contains the resource entities used in the Terramate Cloud API.
|
Package resources contains the resource entities used in the Terramate Cloud API. |
|
stack
Package stack provides types and helpers for cloud stacks.
|
Package stack provides types and helpers for cloud stacks. |
|
status
Package status provides utilities for parsing Terramate Cloud status filters.
|
Package status provides utilities for parsing Terramate Cloud status filters. |
|
integrations
|
|
|
bitbucket
Package bitbucket implements the client for Bitbucket Cloud.
|
Package bitbucket implements the client for Bitbucket Cloud. |
|
github
Package github implements a client SDK for the Github API.
|
Package github implements a client SDK for the Github API. |
|
gitlab
Package gitlab provides a SDK and helpers for the gitlab provider.
|
Package gitlab provides a SDK and helpers for the gitlab provider. |
|
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
command
Package main implements the cloudmock service.
|
Package main implements the cloudmock service. |