configversion

package
v0.3.24 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package configversion handles terraform configurations.

templ: version: v0.3.865

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 SourceIconAPI added in v0.3.24

func SourceIconAPI() templ.Component

func SourceIconTerraform added in v0.3.24

func SourceIconTerraform() templ.Component

func SourceIconUI added in v0.3.24

func SourceIconUI() templ.Component

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.TfeID) ([]byte, error)

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

func (Client) GetSourceIcon added in v0.3.24

func (db Client) GetSourceIcon(source Source) templ.Component

func (Client) RegisterSourceIcon added in v0.3.24

func (db Client) RegisterSourceIcon(source Source, icon templ.Component)

type ConfigurationStatus

type ConfigurationStatus string

ConfigurationStatus represents a configuration version status.

type ConfigurationVersion

type ConfigurationVersion struct {
	ID                resource.TfeID
	CreatedAt         time.Time
	AutoQueueRuns     bool
	Source            Source
	Speculative       bool
	Status            ConfigurationStatus
	StatusTimestamps  []StatusTimestamp
	WorkspaceID       resource.TfeID
	IngressAttributes *IngressAttributes
}

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

func NewConfigurationVersion

func NewConfigurationVersion(workspaceID resource.TfeID, opts CreateOptions) *ConfigurationVersion

NewConfigurationVersion creates a ConfigurationVersion object from scratch

func (*ConfigurationVersion) StatusTimestamp

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

type ConfigurationVersionGetOptions

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

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

	// 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 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.TfeID, []byte) error

type IngressAttributes

type IngressAttributes struct {
	Branch                 string
	CommitSHA              string
	Repo                   string
	IsPullRequest          bool
	OnDefaultBranch        bool
	ConfigurationVersionID resource.TfeID
	CommitURL              string
	PullRequestNumber      int
	PullRequestURL         string
	PullRequestTitle       string
	Tag                    string
	SenderUsername         string
	SenderAvatarURL        string
	SenderHTMLURL          string
}

type IngressAttributesModel added in v0.3.17

type IngressAttributesModel struct {
	Branch                 string
	CommitSHA              string         `db:"commit_sha"`
	Repo                   string         `db:"identifier"`
	IsPullRequest          bool           `db:"is_pull_request"`
	OnDefaultBranch        bool           `db:"on_default_branch"`
	ConfigurationVersionID resource.TfeID `db:"configuration_version_id"`
	CommitURL              string         `db:"commit_url"`
	PullRequestNumber      int            `db:"pull_request_number"`
	PullRequestURL         string         `db:"pull_request_url"`
	PullRequestTitle       string         `db:"pull_request_title"`
	Tag                    string         `db:"tag"`
	SenderUsername         string         `db:"sender_username"`
	SenderAvatarURL        string         `db:"sender_avatar_url"`
	SenderHTMLURL          string         `db:"sender_html_url"`
}

func (IngressAttributesModel) ToIngressAttributes added in v0.3.17

func (m IngressAttributesModel) ToIngressAttributes() *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.TfeID, opts CreateOptions) (*ConfigurationVersion, error)

func (*Service) Delete added in v0.2.2

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

func (*Service) DownloadConfig

func (s *Service) DownloadConfig(ctx context.Context, cvID resource.TfeID) ([]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.TfeID) (*ConfigurationVersion, error)

func (Service) GetSourceIcon added in v0.3.24

func (db Service) GetSourceIcon(source Source) templ.Component

func (*Service) List added in v0.2.2

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

func (Service) RegisterSourceIcon added in v0.3.24

func (db Service) RegisterSourceIcon(source Source, icon templ.Component)

func (*Service) UploadConfig

func (s *Service) UploadConfig(ctx context.Context, cvID resource.TfeID, 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 is the source or origin of the configuration

var (
	DefaultSource          = SourceAPI
	SourceAPI       Source = "tfe-api"
	SourceUI        Source = "tfe-ui"
	SourceTerraform Source = "terraform+cloud"
)

func Ptr added in v0.3.24

func Ptr(s Source) *Source

type StatusTimestamp added in v0.3.17

type StatusTimestamp struct {
	ConfigurationVersionID resource.TfeID `db:"-"`
	Status                 ConfigurationStatus
	Timestamp              time.Time
}

type TFECVStatusTimestamps added in v0.3.17

type TFECVStatusTimestamps struct {
	FinishedAt *time.Time `json:"finished-at,omitempty"`
	QueuedAt   *time.Time `json:"queued-at,omitempty"`
	StartedAt  *time.Time `json:"started-at,omitempty"`
}

CVStatusTimestamps holds the timestamps for individual configuration version statuses.

type TFEConfigurationVersion added in v0.3.17

type TFEConfigurationVersion struct {
	ID               resource.TfeID         `jsonapi:"primary,configuration-versions"`
	AutoQueueRuns    bool                   `jsonapi:"attribute" json:"auto-queue-runs"`
	Error            string                 `jsonapi:"attribute" json:"error"`
	ErrorMessage     string                 `jsonapi:"attribute" json:"error-message"`
	Source           string                 `jsonapi:"attribute" json:"source"`
	Speculative      bool                   `jsonapi:"attribute" json:"speculative"`
	Status           string                 `jsonapi:"attribute" json:"status"`
	StatusTimestamps *TFECVStatusTimestamps `jsonapi:"attribute" json:"status-timestamps"`
	UploadURL        string                 `jsonapi:"attribute" json:"upload-url"`

	// Relations
	IngressAttributes *TFEIngressAttributes `jsonapi:"relationship" json:"ingress-attributes"`
}

TFEConfigurationVersion is an uploaded or ingressed Terraform configuration. A workspace must have at least one configuration version before any runs may be queued on it.

type TFEConfigurationVersionCreateOptions added in v0.3.17

type TFEConfigurationVersionCreateOptions struct {
	// Type is a public field utilized by JSON:API to
	// set the resource type via the field tag.
	// It is not a user-defined value and does not need to be set.
	// https://jsonapi.org/format/#crud-creating
	Type string `jsonapi:"primary,configuration-versions"`

	// When true, runs are queued automatically when the configuration version
	// is uploaded.
	AutoQueueRuns *bool `jsonapi:"attribute" json:"auto-queue-runs,omitempty"`

	// When true, this configuration version can only be used for planning.
	Speculative *bool `jsonapi:"attribute" json:"speculative,omitempty"`
}

ConfigurationVersionCreateOptions represents the options for creating a configuration version.

type TFEConfigurationVersionList added in v0.3.17

type TFEConfigurationVersionList struct {
	*types.Pagination
	Items []*TFEConfigurationVersion
}

ConfigurationVersionList represents a list of configuration versions.

type TFEIngressAttributes added in v0.3.17

type TFEIngressAttributes struct {
	ID                resource.TfeID `jsonapi:"primary,ingress-attributes"`
	Branch            string         `jsonapi:"attribute" json:"branch"`
	CloneURL          string         `jsonapi:"attribute" json:"clone-url"`
	CommitMessage     string         `jsonapi:"attribute" json:"commit-message"`
	CommitSHA         string         `jsonapi:"attribute" json:"commit-sha"`
	CommitURL         string         `jsonapi:"attribute" json:"commit-url"`
	CompareURL        string         `jsonapi:"attribute" json:"compare-url"`
	Identifier        string         `jsonapi:"attribute" json:"identifier"`
	IsPullRequest     bool           `jsonapi:"attribute" json:"is-pull-request"`
	OnDefaultBranch   bool           `jsonapi:"attribute" json:"on-default-branch"`
	PullRequestNumber int            `jsonapi:"attribute" json:"pull-request-number"`
	PullRequestURL    string         `jsonapi:"attribute" json:"pull-request-url"`
	PullRequestTitle  string         `jsonapi:"attribute" json:"pull-request-title"`
	PullRequestBody   string         `jsonapi:"attribute" json:"pull-request-body"`
	Tag               string         `jsonapi:"attribute" json:"tag"`
	SenderUsername    string         `jsonapi:"attribute" json:"sender-username"`
	SenderAvatarURL   string         `jsonapi:"attribute" json:"sender-avatar-url"`
	SenderHTMLURL     string         `jsonapi:"attribute" json:"sender-html-url"`
}

Jump to

Keyboard shortcuts

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