pro

package
v1.221.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package pro is a generated GoMock package.

Index

Constants

View Source
const (
	DefaultHTTPTimeoutSecs           = 30
	DefaultDialTimeoutSecs           = 10
	DefaultIdleConnTimeoutSecs       = 30
	DefaultResponseHeaderTimeoutSecs = 15
	DefaultExpectContinueTimeoutSecs = 1
)
View Source
const (
	// DefaultMaxPayloadBytes is the maximum payload size before chunking is triggered.
	// Set below Vercel's ~4.5MB serverless function body limit.
	DefaultMaxPayloadBytes = 4 * 1024 * 1024

	// BatchFieldsOverheadBytes is the estimated JSON byte overhead for batch metadata fields.
	BatchFieldsOverheadBytes = 200

	// DefaultMetadataOverheadBytes is the conservative fallback for metadata size estimation.
	DefaultMetadataOverheadBytes = 512
)
View Source
const (
	// DefaultMaxRetries is the maximum number of retry attempts for upload operations.
	// Total attempts = 1 (initial) + DefaultMaxRetries.
	DefaultMaxRetries = 3
	// DefaultBaseDelay is the initial backoff delay before the first retry.
	DefaultBaseDelay = 1 * time.Second
)
View Source
const AtmosProBotActor = "atmos-pro[bot]"

AtmosProBotActor is the GitHub actor name for the Atmos Pro GitHub App. When the app pushes a commit, the subsequent CI run sees this as the actor.

View Source
const (
	// DefaultHTTPClientTimeout is the default timeout for HTTP client requests.
	DefaultHTTPClientTimeout = 10 * time.Second
)
View Source
const DefaultProAudience = "atmos-pro.com"

DefaultProAudience is the default OIDC audience for Atmos Pro token exchange.

Variables

This section is empty.

Functions

func ExchangeOIDCToken added in v1.221.0

func ExchangeOIDCToken(baseURL, baseAPIEndpoint, oidcToken, workspaceID string) (string, error)

ExchangeOIDCToken exchanges a GitHub Actions OIDC token for an Atmos Pro session JWT via POST {baseURL}/{baseAPIEndpoint}/auth/github-oidc. Exported for reuse by the atmos/pro auth provider.

func ExecuteCommit added in v1.215.0

func ExecuteCommit(atmosConfig *schema.AtmosConfiguration, message, comment, addPattern string, stageAll bool) error

ExecuteCommit detects changed files in the git index, base64-encodes their contents, and sends them to Atmos Pro to create a server-side commit via the GitHub App. This ensures commits trigger CI (unlike GITHUB_TOKEN commits).

Loop prevention: if GITHUB_ACTOR is the Atmos Pro bot, the command exits early with a success message. This protects users who forget to add the `if: github.actor != 'atmos-pro[bot]'` guard to their workflow.

func MintGitHubOIDCToken added in v1.221.0

func MintGitHubOIDCToken(githubOIDCSettings schema.GithubOIDCSettings, audience string) (string, error)

MintGitHubOIDCToken mints a GitHub Actions OIDC token for the given audience. Exported for reuse by the atmos/pro auth provider. When audience is empty, DefaultProAudience is used.

Types

type APIClient added in v1.195.0

type APIClient interface {
	// UploadInstances uploads component instances to Atmos Pro.
	UploadInstances(req *dtos.InstancesUploadRequest) error
}

APIClient defines operations for interacting with Atmos Pro API. This interface allows mocking of API operations in tests.

type APIError added in v1.213.0

type APIError struct {
	StatusCode int
	Operation  string
	Err        error
}

APIError represents an error from the Atmos Pro API that includes the HTTP status code. This allows retry logic to distinguish retryable errors (401, 5xx) from non-retryable ones (400, 403, 404).

func (*APIError) Error added in v1.213.0

func (e *APIError) Error() string

Error returns a human-readable description of the API error.

For 4xx responses the server's error message is already user-facing ("Drift detection validation failed: ..."), so the redundant "HTTP <code>:" prefix is dropped — the user sees "UploadInstances: <message>".

For 5xx and other errors the prefix is kept because the inner cause is usually a generic fallback like "API request failed with status N" and the explicit status code helps both users and support.

func (*APIError) IsAuthError added in v1.213.0

func (e *APIError) IsAuthError() bool

IsAuthError returns true if the error is a 401 Unauthorized.

func (*APIError) IsRetryable added in v1.213.0

func (e *APIError) IsRetryable() bool

IsRetryable returns true if the error represents a retryable HTTP status (401 or 5xx).

func (*APIError) Unwrap added in v1.213.0

func (e *APIError) Unwrap() error

Unwrap returns the underlying error for use with errors.Is and errors.As.

type AtmosProAPIClient

type AtmosProAPIClient struct {
	APIToken        string
	BaseAPIEndpoint string
	BaseURL         string
	HTTPClient      *http.Client

	MaxPayloadBytes int // Configurable max payload size before chunking. 0 uses default.
	// contains filtered or unexported fields
}

AtmosProAPIClient represents the client to interact with the AtmosPro API.

func NewAtmosProAPIClient

func NewAtmosProAPIClient(baseURL, baseAPIEndpoint, apiToken string) *AtmosProAPIClient

NewAtmosProAPIClient creates a new instance of AtmosProAPIClient.

func NewAtmosProAPIClientFromEnv

func NewAtmosProAPIClientFromEnv(atmosConfig *schema.AtmosConfiguration) (*AtmosProAPIClient, error)

NewAtmosProAPIClientFromEnv creates a new AtmosProAPIClient from environment variables.

func (*AtmosProAPIClient) CreateCommit added in v1.215.0

func (c *AtmosProAPIClient) CreateCommit(dto *dtos.CommitRequest) (*dtos.CommitResponse, error)

CreateCommit sends file changes to Atmos Pro to create a server-side commit via the GitHub App. It retries on transient 401/5xx failures with exponential backoff, refreshing the OIDC token on 401 errors before each retry.

func (*AtmosProAPIClient) LockStack

LockStack locks a specific stack.

func (*AtmosProAPIClient) RefreshToken added in v1.213.0

func (c *AtmosProAPIClient) RefreshToken() error

RefreshToken re-exchanges the OIDC token for a fresh Atmos Pro JWT. This is used by retry logic when a 401 suggests the original JWT was signed by a different deployment instance. Returns a no-op nil error when the client was created with a static token (no OIDC).

func (*AtmosProAPIClient) UnlockStack

UnlockStack unlocks a specific stack.

func (*AtmosProAPIClient) UploadAffectedStacks

func (c *AtmosProAPIClient) UploadAffectedStacks(dto *dtos.UploadAffectedStacksRequest) error

UploadAffectedStacks uploads information about affected stacks. Large payloads are automatically split into chunks to stay within server body size limits. Each chunk is retried on transient 401/5xx failures with exponential backoff, refreshing the OIDC token on 401 errors before each retry.

func (*AtmosProAPIClient) UploadInstanceStatus added in v1.192.0

func (c *AtmosProAPIClient) UploadInstanceStatus(dto *dtos.InstanceStatusUploadRequest) error

UploadInstanceStatus uploads the drift detection result status to the pro API. It retries on transient 401/5xx failures with exponential backoff, refreshing the OIDC token on 401 errors before each retry.

func (*AtmosProAPIClient) UploadInstances added in v1.192.0

func (c *AtmosProAPIClient) UploadInstances(dto *dtos.InstancesUploadRequest) error

UploadInstances uploads drift detection data to the API. Large payloads are automatically split into chunks to stay within server body size limits. Each chunk is retried on transient 401/5xx failures with exponential backoff, refreshing the OIDC token on 401 errors before each retry.

type AtmosProAPIClientInterface added in v1.192.0

type AtmosProAPIClientInterface interface {
	UploadInstances(req *dtos.InstancesUploadRequest) error
	UploadInstanceStatus(dto *dtos.InstanceStatusUploadRequest) error
	UploadAffectedStacks(dto *dtos.UploadAffectedStacksRequest) error
	LockStack(dto *dtos.LockStackRequest) (dtos.LockStackResponse, error)
	UnlockStack(dto *dtos.UnlockStackRequest) (dtos.UnlockStackResponse, error)
}

AtmosProAPIClientInterface defines the interface for the AtmosProAPIClient.

type BatchInfo added in v1.213.0

type BatchInfo struct {
	BatchID    string `json:"batch_id"`
	BatchIndex int    `json:"batch_index"`
	BatchTotal int    `json:"batch_total"`
}

BatchInfo holds metadata for chunked uploads.

type ClientFactory added in v1.195.0

type ClientFactory interface {
	// NewClient creates a new API client from the given configuration.
	NewClient(atmosConfig *schema.AtmosConfiguration) (APIClient, error)
}

ClientFactory creates an APIClient from configuration.

type DefaultClientFactory added in v1.195.0

type DefaultClientFactory struct{}

DefaultClientFactory implements ClientFactory using real API client creation.

func (*DefaultClientFactory) NewClient added in v1.195.0

func (d *DefaultClientFactory) NewClient(atmosConfig *schema.AtmosConfiguration) (APIClient, error)

NewClient creates a new API client from environment variables.

type MockAPIClient added in v1.195.0

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

MockAPIClient is a mock of APIClient interface.

func NewMockAPIClient added in v1.195.0

func NewMockAPIClient(ctrl *gomock.Controller) *MockAPIClient

NewMockAPIClient creates a new mock instance.

func (*MockAPIClient) EXPECT added in v1.195.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAPIClient) UploadInstances added in v1.195.0

func (m *MockAPIClient) UploadInstances(req *dtos.InstancesUploadRequest) error

UploadInstances mocks base method.

type MockAPIClientMockRecorder added in v1.195.0

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

MockAPIClientMockRecorder is the mock recorder for MockAPIClient.

func (*MockAPIClientMockRecorder) UploadInstances added in v1.195.0

func (mr *MockAPIClientMockRecorder) UploadInstances(req any) *gomock.Call

UploadInstances indicates an expected call of UploadInstances.

type MockClientFactory added in v1.195.0

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

MockClientFactory is a mock of ClientFactory interface.

func NewMockClientFactory added in v1.195.0

func NewMockClientFactory(ctrl *gomock.Controller) *MockClientFactory

NewMockClientFactory creates a new mock instance.

func (*MockClientFactory) EXPECT added in v1.195.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClientFactory) NewClient added in v1.195.0

func (m *MockClientFactory) NewClient(atmosConfig *schema.AtmosConfiguration) (APIClient, error)

NewClient mocks base method.

type MockClientFactoryMockRecorder added in v1.195.0

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

MockClientFactoryMockRecorder is the mock recorder for MockClientFactory.

func (*MockClientFactoryMockRecorder) NewClient added in v1.195.0

func (mr *MockClientFactoryMockRecorder) NewClient(atmosConfig any) *gomock.Call

NewClient indicates an expected call of NewClient.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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