configversion

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package configversion handles terraform configurations.

Index

Constants

View Source
const (
	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

	// Client does not implement all of service yet
	Service
}

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 ConfigurationStatus

type ConfigurationStatus string

ConfigurationStatus represents a configuration version status.

type ConfigurationVersion

type ConfigurationVersion struct {
	ID                string
	CreatedAt         time.Time
	AutoQueueRuns     bool
	Source            Source
	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
	Source        Source
	*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
	PullRequestNumber int
	PullRequestURL    string
	PullRequestTitle  string
	// PullRequestBody   string
	Tag             string
	SenderUsername  string
	SenderAvatarURL string
	SenderHTMLURL   string
}

func NewIngressFromRow added in v0.1.6

func NewIngressFromRow(row *pggen.IngressAttributes) *IngressAttributes

type Options

type Options struct {
	logr.Logger

	WorkspaceAuthorizer internal.Authorizer
	MaxConfigSize       int64

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

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
}

type Source added in v0.1.8

type Source string

Source representse of a run.

const (
	SourceAPI       Source = "tfe-api"
	SourceGithub    Source = "github"
	SourceGitlab    Source = "gitlab"
	SourceTerraform Source = "terraform+cloud"

	DefaultSource = SourceAPI
)

Jump to

Keyboard shortcuts

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