configversion

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 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

This section is empty.

Types

type Client

type Client struct {
	*otfapi.Client

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

func (*Client) DownloadConfig

func (c *Client) DownloadConfig(ctx context.Context, cvID resource.ID) ([]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                resource.ID
	CreatedAt         time.Time
	AutoQueueRuns     bool
	Source            Source
	Speculative       bool
	Status            ConfigurationStatus
	StatusTimestamps  []ConfigurationVersionStatusTimestamp
	WorkspaceID       resource.ID
	IngressAttributes *IngressAttributes
}

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

func NewConfigurationVersion

func NewConfigurationVersion(workspaceID resource.ID, opts CreateOptions) (*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) 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 ConfigurationVersionGetOptions

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

	// Get latest config version for this workspace ID
	WorkspaceID *resource.ID

	// 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 ConfigurationVersionStatusTimestamp

type ConfigurationVersionStatusTimestamp struct {
	Status    ConfigurationStatus
	Timestamp time.Time
}

type CreateOptions added in v0.2.2

type CreateOptions struct {
	AutoQueueRuns *bool
	Speculative   *bool
	Source        Source
	*IngressAttributes
}

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

type FakeService added in v0.2.2

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

func (*FakeService) Create added in v0.2.2

func (*FakeService) Get added in v0.2.2

func (*FakeService) GetLatest added in v0.2.2

func (*FakeService) UploadConfig added in v0.2.2

func (f *FakeService) UploadConfig(context.Context, resource.ID, []byte) error

type IngressAttributes

type IngressAttributes struct {
	// ID     resource.ID
	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 *sqlc.IngressAttribute) *IngressAttributes

type ListOptions added in v0.2.2

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

	resource.PageOptions
}

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

type Options

type Options struct {
	logr.Logger

	MaxConfigSize int64
	Authorizer    *authz.Authorizer

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

type Service

type Service struct {
	logr.Logger
	*authz.Authorizer
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) *Service

func (*Service) AddHandlers added in v0.2.2

func (s *Service) AddHandlers(r *mux.Router)

func (*Service) Create added in v0.2.2

func (s *Service) Create(ctx context.Context, workspaceID resource.ID, opts CreateOptions) (*ConfigurationVersion, error)

func (*Service) Delete added in v0.2.2

func (s *Service) Delete(ctx context.Context, cvID resource.ID) error

func (*Service) DownloadConfig

func (s *Service) DownloadConfig(ctx context.Context, cvID resource.ID) ([]byte, error)

DownloadConfig retrieves a tarball from the db

func (*Service) Get added in v0.2.2

func (*Service) GetLatest added in v0.2.2

func (s *Service) GetLatest(ctx context.Context, workspaceID resource.ID) (*ConfigurationVersion, error)

func (*Service) List added in v0.2.2

func (s *Service) List(ctx context.Context, workspaceID resource.ID, opts ListOptions) (*resource.Page[*ConfigurationVersion], error)

func (*Service) UploadConfig

func (s *Service) UploadConfig(ctx context.Context, cvID resource.ID, config []byte) error

UploadConfig saves a configuration tarball to the db

NOTE: unauthenticated - access granted only via signed URL

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