configversion

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package configversion handles terraform configurations.

Index

Constants

View Source
const (
	DefaultConfigurationSource = "tfe-api"
	DefaultAutoQueueRuns       = true

	// List all available configuration version statuses.
	ConfigurationErrored  ConfigurationStatus = "errored"
	ConfigurationPending  ConfigurationStatus = "pending"
	ConfigurationUploaded ConfigurationStatus = "uploaded"

	// Default maximum config size is 10mb.
	DefaultConfigMaxSize int64 = 1024 * 1024 * 10
)

Variables

This section is empty.

Functions

func NewService

func NewService(opts Options) *service

Types

type Client

type Client struct {
	internal.JSONAPIClient
}

func (*Client) DownloadConfig

func (c *Client) DownloadConfig(ctx context.Context, cvID string) ([]byte, error)

DownloadConfig downloads a configuration version tarball. Only configuration versions in the uploaded state may be downloaded.

type ConfigUploader

type ConfigUploader interface {
	// Upload uploads the config tarball and returns a status indicating success
	// or failure.
	Upload(ctx context.Context, config []byte) (ConfigurationStatus, error)
	// SetErrored sets the config version status to 'errored' in the store.
	SetErrored(ctx context.Context) error
}

ConfigUploader uploads a config

type ConfigurationSource

type ConfigurationSource string

ConfigurationSource represents a source of a configuration version.

type ConfigurationStatus

type ConfigurationStatus string

ConfigurationStatus represents a configuration version status.

type ConfigurationVersion

type ConfigurationVersion struct {
	ID                string
	CreatedAt         time.Time
	AutoQueueRuns     bool
	Source            ConfigurationSource
	Speculative       bool
	Status            ConfigurationStatus
	StatusTimestamps  []ConfigurationVersionStatusTimestamp
	WorkspaceID       string
	IngressAttributes *IngressAttributes
}

ConfigurationVersion is a representation of an uploaded or ingressed Terraform configuration.

func NewConfigurationVersion

func NewConfigurationVersion(workspaceID string, opts ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)

NewConfigurationVersion creates a ConfigurationVersion object from scratch

func (*ConfigurationVersion) AddStatusTimestamp

func (cv *ConfigurationVersion) AddStatusTimestamp(status ConfigurationStatus, timestamp time.Time)

func (*ConfigurationVersion) StatusTimestamp

func (cv *ConfigurationVersion) StatusTimestamp(status ConfigurationStatus) (time.Time, error)

func (*ConfigurationVersion) String

func (cv *ConfigurationVersion) String() string

func (*ConfigurationVersion) Upload

func (cv *ConfigurationVersion) Upload(ctx context.Context, config []byte, uploader ConfigUploader) error

Upload saves the config to the db and updates status accordingly.

type ConfigurationVersionCreateOptions

type ConfigurationVersionCreateOptions struct {
	AutoQueueRuns *bool
	Speculative   *bool
	*IngressAttributes
}

ConfigurationVersionCreateOptions represents the options for creating a configuration version. See jsonapi.ConfigurationVersionCreateOptions for more details.

type ConfigurationVersionGetOptions

type ConfigurationVersionGetOptions struct {
	// ID of config version to retrieve
	ID *string

	// Get latest config version for this workspace ID
	WorkspaceID *string

	// A list of relations to include
	Include *string `schema:"include"`
}

ConfigurationVersionGetOptions are options for retrieving a single config version. Either ID *or* WorkspaceID must be specfiied.

type ConfigurationVersionListOptions

type ConfigurationVersionListOptions struct {
	// A list of relations to include
	Include *string `schema:"include"`

	resource.PageOptions
}

ConfigurationVersionListOptions are options for paginating and filtering a list of configuration versions

type ConfigurationVersionService

type ConfigurationVersionService = Service

namespaced for disambiguation from other services

type ConfigurationVersionStatusTimestamp

type ConfigurationVersionStatusTimestamp struct {
	Status    ConfigurationStatus
	Timestamp time.Time
}

type IngressAttributes

type IngressAttributes struct {
	// ID     string
	Branch string
	// CloneURL          string
	// CommitMessage     string
	CommitSHA string
	// CommitURL         string
	// CompareURL        string
	Repo            string
	IsPullRequest   bool
	OnDefaultBranch bool
}

type Options

type Options struct {
	logr.Logger

	WorkspaceAuthorizer internal.Authorizer

	internal.Cache
	*sql.DB
	*surl.Signer
}

type Service

type Service interface {
	CreateConfigurationVersion(ctx context.Context, workspaceID string, opts ConfigurationVersionCreateOptions) (*ConfigurationVersion, error)
	GetConfigurationVersion(ctx context.Context, id string) (*ConfigurationVersion, error)
	GetLatestConfigurationVersion(ctx context.Context, workspaceID string) (*ConfigurationVersion, error)
	ListConfigurationVersions(ctx context.Context, workspaceID string, opts ConfigurationVersionListOptions) (*resource.Page[*ConfigurationVersion], error)

	// Upload handles verification and upload of the config tarball, updating
	// the config version upon success or failure.
	UploadConfig(ctx context.Context, id string, config []byte) error

	// Download retrieves the config tarball for the given config version ID.
	DownloadConfig(ctx context.Context, id string) ([]byte, error)

	DeleteConfigurationVersion(ctx context.Context, cvID string) error
}

Jump to

Keyboard shortcuts

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