cloud

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: MPL-2.0 Imports: 24 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 (
	// 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 (
	// 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"
)
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 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

func BaseDomain(region Region) string

BaseDomain returns the official API base domain for the Terramate Cloud.

func BaseURL

func BaseURL(region Region) string

BaseURL returns the official API base URL for the Terramate Cloud.

func HTMLURL added in v0.12.0

func HTMLURL(region Region) string

HTMLURL returns the Terramate Cloud frontend URL.

Types

type Client

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

Client is the cloud SDK client.

func NewClient added in v0.13.1

func NewClient(opts ...Option) *Client

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) BaseURL

func (c *Client) BaseURL() string

BaseURL returns the API base URL of the 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 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

func (c *Client) GetOrgSingleSignOnID(ctx context.Context, orgName string) (string, error)

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

func (c *Client) HTTPClient() *stdhttp.Client

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) Region added in v0.12.0

func (c *Client) Region() Region

Region returns the region of the client.

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

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 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.

func (*Client) UpdateStoreOutputValue added in v0.12.0

func (c *Client) UpdateStoreOutputValue(ctx context.Context, orgUUID resources.UUID, id resources.UUID, value string) error

UpdateStoreOutputValue updates the value of the output in the Terramate Cloud store.

func (*Client) Users

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

Users retrieves the user details for the signed in user.

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

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

CreatedPreview is the result of CreatePreview

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 resources.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 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

func WithBaseURL(baseURL string) Option

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

func WithHTTPClient(httpClient *stdhttp.Client) Option

WithHTTPClient sets the HTTP client to be used in the client.

func WithLogger added in v0.13.1

func WithLogger(logger *zerolog.Logger) Option

WithLogger sets the logger to be used in the client.

func WithRegion added in v0.13.1

func WithRegion(region Region) Option

WithRegion sets the region to be used in the client.

type Options added in v0.13.1

type Options []Option

Options is a list of functional options.

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

func ParseRegion(str string) (Region, error)

ParseRegion parses a user-supplied region name.

func (Region) String added in v0.12.0

func (r Region) String() string

String returns the string representation of the region.

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.

func (Regions) String added in v0.12.0

func (rs Regions) String() string

String returns the string representation of the regions list.

type RunContext added in v0.5.0

type RunContext struct {
	StackID string
	Cmd     []string
}

RunContext is the context for a run

type Syncer added in v0.4.3

type Syncer func(l resources.CommandLogs)

Syncer 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
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