http

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package http provides an HTTP interface allowing HTTP clients to interact with OTF.

Index

Constants

View Source
const (

	// DefaultBasePath on which the API is served.
	DefaultBasePath = "/api/v2/"
	// PingEndpoint is a no-op API endpoint used to configure the rate limiter
	PingEndpoint = "ping"
)
View Source
const (
	DefaultAddress = "localhost:8080"
)

Variables

This section is empty.

Functions

func DecodeQuery

func DecodeQuery(opts interface{}, query url.Values) error

DecodeQuery unmarshals a query string (k1=v1&k2=v2...) into a struct.

func MarshalPayload

func MarshalPayload(w io.Writer, r *http.Request, models interface{}) error

MarshalPayload marshals the models object into a JSON-API response.

func NewLogHandler added in v0.0.8

func NewLogHandler(logger logr.Logger) negroni.HandlerFunc

NewLogHandler returns negroni middleware that logs HTTP requests

func NewRouter

func NewRouter(server *Server) *negroni.Negroni

NewRouter constructs a negroni-wrapped HTTP router

func SanitizeAddress added in v0.0.8

func SanitizeAddress(address string) (string, error)

SanitizeAddress ensures address is in format https://<host>:<port>

func SanitizeHostname added in v0.0.8

func SanitizeHostname(hostname string) (string, error)

SanitizeHostname ensures hostname is in the format <host>:<port>

func WithCode

func WithCode(code int) func(w http.ResponseWriter)

WithCode is a helper func for writing an HTTP status code to a response stream. For use with WriteResponse.

func WriteError

func WriteError(w http.ResponseWriter, code int, err error)

WriteError writes an HTTP response with a JSON-API marshalled error obj.

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *http.Request, obj interface{}, opts ...func(http.ResponseWriter))

WriteResponse writes an HTTP response with a JSON-API marshalled payload.

Types

type Apply added in v0.0.8

type Apply struct {
	ID                   string                 `jsonapi:"primary,applies"`
	LogReadURL           string                 `jsonapi:"attr,log-read-url"`
	ResourceAdditions    int                    `jsonapi:"attr,resource-additions"`
	ResourceChanges      int                    `jsonapi:"attr,resource-changes"`
	ResourceDestructions int                    `jsonapi:"attr,resource-destructions"`
	Status               otf.ApplyStatus        `jsonapi:"attr,status"`
	StatusTimestamps     *ApplyStatusTimestamps `jsonapi:"attr,status-timestamps"`
}

Apply represents a Terraform Enterprise apply.

func ApplyJSONAPIObject added in v0.0.8

func ApplyJSONAPIObject(req *http.Request, a *otf.Apply) *Apply

ApplyJSONAPIObject converts a Apply to a struct that can be marshalled into a JSON-API object

func (*Apply) ToDomain added in v0.0.8

func (a *Apply) ToDomain() *otf.Apply

ToDomain converts http organization obj to a domain organization obj.

type ApplyStatusTimestamps added in v0.0.8

type ApplyStatusTimestamps struct {
	CanceledAt      *time.Time `json:"canceled-at,omitempty"`
	ErroredAt       *time.Time `json:"errored-at,omitempty"`
	FinishedAt      *time.Time `json:"finished-at,omitempty"`
	ForceCanceledAt *time.Time `json:"force-canceled-at,omitempty"`
	QueuedAt        *time.Time `json:"queued-at,omitempty"`
	StartedAt       *time.Time `json:"started-at,omitempty"`
}

ApplyStatusTimestamps holds the timestamps for individual apply statuses.

type CVStatusTimestamps added in v0.0.8

type CVStatusTimestamps 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 Client added in v0.0.8

type Client interface {
	Organizations() otf.OrganizationService
	Workspaces() otf.WorkspaceService
}

type ClientFactory added in v0.0.8

type ClientFactory interface {
	NewClient() (Client, error)
}

ClientFactory implementations of capable of constructing new OTF clients

type Config added in v0.0.8

type Config struct {
	// The address of the Terraform Enterprise API.
	Address string

	// The base path on which the API is served.
	BasePath string

	// API token used to access the Terraform Enterprise API.
	Token string

	// Headers that will be added to every request.
	Headers http.Header

	// A custom HTTP client to use.
	HTTPClient *http.Client

	// RetryLogHook is invoked each time a request is retried.
	RetryLogHook RetryLogHook
	// contains filtered or unexported fields
}

Config provides configuration details to the API client.

func NewConfig added in v0.0.8

func NewConfig(opts ...ConfigOption) (*Config, error)

NewConfig constructs a new http client config. Options are only applied when NewClient() is called.

func (*Config) NewClient added in v0.0.8

func (config *Config) NewClient() (Client, error)

NewClient creates a new Terraform Enterprise API client.

type ConfigOption added in v0.0.8

type ConfigOption func(*Config) error

type ConfigurationVersion added in v0.0.8

type ConfigurationVersion struct {
	ID               string                  `jsonapi:"primary,configuration-versions"`
	AutoQueueRuns    bool                    `jsonapi:"attr,auto-queue-runs"`
	Error            string                  `jsonapi:"attr,error"`
	ErrorMessage     string                  `jsonapi:"attr,error-message"`
	Source           otf.ConfigurationSource `jsonapi:"attr,source"`
	Speculative      bool                    `jsonapi:"attr,speculative "`
	Status           otf.ConfigurationStatus `jsonapi:"attr,status"`
	StatusTimestamps *CVStatusTimestamps     `jsonapi:"attr,status-timestamps"`
	UploadURL        string                  `jsonapi:"attr,upload-url"`
}

ConfigurationVersion is a representation of an uploaded or ingressed Terraform configuration in TFE. A workspace must have at least one configuration version before any runs may be queued on it.

func ConfigurationVersionJSONAPIObject added in v0.0.8

func ConfigurationVersionJSONAPIObject(cv *otf.ConfigurationVersion) *ConfigurationVersion

ConfigurationVersionJSONAPIObject converts a ConfigurationVersion to a struct that can be marshalled into a JSON-API object

func (*ConfigurationVersion) ToDomain added in v0.0.8

ToDomain converts http config version obj to a domain config version obj.

type ConfigurationVersionList added in v0.0.8

type ConfigurationVersionList struct {
	*otf.Pagination
	Items []*ConfigurationVersion
}

ConfigurationVersionList represents a list of configuration versions.

type FakeClient added in v0.0.8

type FakeClient struct {
	Client
}

func (FakeClient) Organizations added in v0.0.8

func (f FakeClient) Organizations() otf.OrganizationService

func (FakeClient) Workspaces added in v0.0.8

func (f FakeClient) Workspaces() otf.WorkspaceService

type FakeClientFactory added in v0.0.8

type FakeClientFactory struct{}

func (FakeClientFactory) NewClient added in v0.0.8

func (f FakeClientFactory) NewClient() (Client, error)

type FakeOrganizationsClient added in v0.0.8

type FakeOrganizationsClient struct {
	otf.OrganizationService
}

func (*FakeOrganizationsClient) Create added in v0.0.8

type FakeWorkspacesClient added in v0.0.8

type FakeWorkspacesClient struct {
	otf.WorkspaceService
}

func (*FakeWorkspacesClient) Get added in v0.0.8

func (*FakeWorkspacesClient) List added in v0.0.8

func (*FakeWorkspacesClient) Lock added in v0.0.8

func (*FakeWorkspacesClient) Unlock added in v0.0.8

func (f *FakeWorkspacesClient) Unlock(ctx context.Context, id string) (*otf.Workspace, error)

func (*FakeWorkspacesClient) Update added in v0.0.8

type Organization added in v0.0.8

type Organization struct {
	Name                  string                       `jsonapi:"primary,organizations"`
	CostEstimationEnabled bool                         `jsonapi:"attr,cost-estimation-enabled"`
	CreatedAt             time.Time                    `jsonapi:"attr,created-at,iso8601"`
	Email                 string                       `jsonapi:"attr,email"`
	ExternalID            string                       `jsonapi:"attr,external-id"`
	OwnersTeamSAMLRoleID  string                       `jsonapi:"attr,owners-team-saml-role-id"`
	Permissions           *otf.OrganizationPermissions `jsonapi:"attr,permissions"`
	SAMLEnabled           bool                         `jsonapi:"attr,saml-enabled"`
	SessionRemember       int                          `jsonapi:"attr,session-remember"`
	SessionTimeout        int                          `jsonapi:"attr,session-timeout"`
	TrialExpiresAt        time.Time                    `jsonapi:"attr,trial-expires-at,iso8601"`
	TwoFactorConformant   bool                         `jsonapi:"attr,two-factor-conformant"`
}

Organization represents a Terraform Enterprise organization.

func OrganizationJSONAPIObject added in v0.0.8

func OrganizationJSONAPIObject(org *otf.Organization) *Organization

OrganizationJSONAPIObject converts a Organization to a struct that can be marshalled into a JSON-API object

func (*Organization) ToDomain added in v0.0.8

func (o *Organization) ToDomain() *otf.Organization

ToDomain converts http organization obj to a domain organization obj.

type OrganizationList added in v0.0.8

type OrganizationList struct {
	*otf.Pagination
	Items []*Organization
}

OrganizationList represents a list of organizations.

func OrganizationListJSONAPIObject added in v0.0.8

func OrganizationListJSONAPIObject(cvl *otf.OrganizationList) *OrganizationList

OrganizationListJSONAPIObject converts a OrganizationList to a struct that can be marshalled into a JSON-API object

type Plan added in v0.0.8

type Plan struct {
	ID                   string                `jsonapi:"primary,plans"`
	HasChanges           bool                  `jsonapi:"attr,has-changes"`
	LogReadURL           string                `jsonapi:"attr,log-read-url"`
	ResourceAdditions    int                   `jsonapi:"attr,resource-additions"`
	ResourceChanges      int                   `jsonapi:"attr,resource-changes"`
	ResourceDestructions int                   `jsonapi:"attr,resource-destructions"`
	Status               otf.PlanStatus        `jsonapi:"attr,status"`
	StatusTimestamps     *PlanStatusTimestamps `jsonapi:"attr,status-timestamps"`
}

Plan represents a Terraform Enterprise plan.

func PlanJSONAPIObject added in v0.0.8

func PlanJSONAPIObject(r *http.Request, p *otf.Plan) *Plan

PlanJSONAPIObject converts a Plan to a struct that can be marshalled into a JSON-API object

func (*Plan) ToDomain added in v0.0.8

func (p *Plan) ToDomain() *otf.Plan

ToDomain converts http organization obj to a domain organization obj.

type PlanStatusTimestamps added in v0.0.8

type PlanStatusTimestamps struct {
	CanceledAt      *time.Time `json:"canceled-at,omitempty"`
	ErroredAt       *time.Time `json:"errored-at,omitempty"`
	FinishedAt      *time.Time `json:"finished-at,omitempty"`
	ForceCanceledAt *time.Time `json:"force-canceled-at,omitempty"`
	QueuedAt        *time.Time `json:"queued-at,omitempty"`
	StartedAt       *time.Time `json:"started-at,omitempty"`
}

PlanStatusTimestamps holds the timestamps for individual plan statuses.

type RetryLogHook added in v0.0.8

type RetryLogHook func(attemptNum int, resp *http.Response)

RetryLogHook allows a function to run before each retry.

type Run added in v0.0.8

type Run struct {
	ID                     string               `jsonapi:"primary,runs"`
	Actions                *RunActions          `jsonapi:"attr,actions"`
	CreatedAt              time.Time            `jsonapi:"attr,created-at,iso8601"`
	ForceCancelAvailableAt time.Time            `jsonapi:"attr,force-cancel-available-at,iso8601"`
	HasChanges             bool                 `jsonapi:"attr,has-changes"`
	IsDestroy              bool                 `jsonapi:"attr,is-destroy"`
	Message                string               `jsonapi:"attr,message"`
	Permissions            *otf.RunPermissions  `jsonapi:"attr,permissions"`
	PositionInQueue        int                  `jsonapi:"attr,position-in-queue"`
	Refresh                bool                 `jsonapi:"attr,refresh"`
	RefreshOnly            bool                 `jsonapi:"attr,refresh-only"`
	ReplaceAddrs           []string             `jsonapi:"attr,replace-addrs,omitempty"`
	Source                 string               `jsonapi:"attr,source"`
	Status                 otf.RunStatus        `jsonapi:"attr,status"`
	StatusTimestamps       *RunStatusTimestamps `jsonapi:"attr,status-timestamps"`
	TargetAddrs            []string             `jsonapi:"attr,target-addrs,omitempty"`

	// Relations
	Apply                *Apply                `jsonapi:"relation,apply"`
	ConfigurationVersion *ConfigurationVersion `jsonapi:"relation,configuration-version"`
	CreatedBy            *User                 `jsonapi:"relation,created-by"`
	Plan                 *Plan                 `jsonapi:"relation,plan"`
	Workspace            *Workspace            `jsonapi:"relation,workspace"`
}

Run represents a Terraform Enterprise run.

func RunJSONAPIObject added in v0.0.8

func RunJSONAPIObject(req *http.Request, r *otf.Run) *Run

RunJSONAPIObject converts a Run to a struct that can be marshalled into a JSON-API object

func (*Run) ToDomain added in v0.0.8

func (r *Run) ToDomain() *otf.Run

ToDomain converts http run obj to a domain run obj.

type RunActions added in v0.0.8

type RunActions struct {
	IsCancelable      bool `json:"is-cancelable"`
	IsConfirmable     bool `json:"is-confirmable"`
	IsDiscardable     bool `json:"is-discardable"`
	IsForceCancelable bool `json:"is-force-cancelable"`
}

RunActions represents the run actions.

type RunList added in v0.0.8

type RunList struct {
	*otf.Pagination
	Items []*Run
}

RunList represents a list of runs.

func RunListJSONAPIObject added in v0.0.8

func RunListJSONAPIObject(req *http.Request, cvl *otf.RunList) *RunList

RunListJSONAPIObject converts a RunList to a struct that can be marshalled into a JSON-API object

type RunStatusTimestamps added in v0.0.8

type RunStatusTimestamps struct {
	AppliedAt            *time.Time `json:"applied-at,omitempty"`
	ApplyQueuedAt        *time.Time `json:"apply-queued-at,omitempty"`
	ApplyingAt           *time.Time `json:"applying-at,omitempty"`
	CanceledAt           *time.Time `json:"canceled-at,omitempty"`
	ConfirmedAt          *time.Time `json:"confirmed-at,omitempty"`
	CostEstimatedAt      *time.Time `json:"cost-estimated-at,omitempty"`
	CostEstimatingAt     *time.Time `json:"cost-estimating-at,omitempty"`
	DiscardedAt          *time.Time `json:"discarded-at,omitempty"`
	ErroredAt            *time.Time `json:"errored-at,omitempty"`
	ForceCanceledAt      *time.Time `json:"force-canceled-at,omitempty"`
	PlanQueueableAt      *time.Time `json:"plan-queueable-at,omitempty"`
	PlanQueuedAt         *time.Time `json:"plan-queued-at,omitempty"`
	PlannedAndFinishedAt *time.Time `json:"planned-and-finished-at,omitempty"`
	PlannedAt            *time.Time `json:"planned-at,omitempty"`
	PlanningAt           *time.Time `json:"planning-at,omitempty"`
	PolicyCheckedAt      *time.Time `json:"policy-checked-at,omitempty"`
	PolicySoftFailedAt   *time.Time `json:"policy-soft-failed-at,omitempty"`
}

RunStatusTimestamps holds the timestamps for individual run statuses.

type Server

type Server struct {
	logr.Logger

	EnableRequestLogging bool

	SSL               bool
	CertFile, KeyFile string

	// Listening Address in the form <ip>:<port>
	Addr string

	OrganizationService         otf.OrganizationService
	WorkspaceService            otf.WorkspaceService
	StateVersionService         otf.StateVersionService
	ConfigurationVersionService otf.ConfigurationVersionService
	EventService                otf.EventService
	RunService                  otf.RunService
	PlanService                 otf.PlanService
	ApplyService                otf.ApplyService
	// contains filtered or unexported fields
}

Server provides an HTTP/S server

func NewServer

func NewServer() *Server

NewServer is the constructor for Server

func (*Server) ApplyRun

func (s *Server) ApplyRun(w http.ResponseWriter, r *http.Request)

func (*Server) CancelRun

func (s *Server) CancelRun(w http.ResponseWriter, r *http.Request)

func (*Server) Close

func (s *Server) Close() error

Close gracefully shuts down the server.

func (*Server) ConfigurationVersionListJSONAPIObject

func (s *Server) ConfigurationVersionListJSONAPIObject(cvl *otf.ConfigurationVersionList) *ConfigurationVersionList

ConfigurationVersionListJSONAPIObject converts a ConfigurationVersionList to a struct that can be marshalled into a JSON-API object

func (*Server) CreateConfigurationVersion

func (s *Server) CreateConfigurationVersion(w http.ResponseWriter, r *http.Request)

func (*Server) CreateOrganization

func (s *Server) CreateOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) CreateRun

func (s *Server) CreateRun(w http.ResponseWriter, r *http.Request)

func (*Server) CreateStateVersion

func (s *Server) CreateStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) CreateWorkspace

func (s *Server) CreateWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) CurrentStateVersion

func (s *Server) CurrentStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteOrganization

func (s *Server) DeleteOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteWorkspace

func (s *Server) DeleteWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteWorkspaceByID

func (s *Server) DeleteWorkspaceByID(w http.ResponseWriter, r *http.Request)

func (*Server) DiscardRun

func (s *Server) DiscardRun(w http.ResponseWriter, r *http.Request)

func (*Server) DownloadStateVersion

func (s *Server) DownloadStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) ForceCancelRun

func (s *Server) ForceCancelRun(w http.ResponseWriter, r *http.Request)

func (*Server) GetApply

func (s *Server) GetApply(w http.ResponseWriter, r *http.Request)

func (*Server) GetApplyLogs

func (s *Server) GetApplyLogs(w http.ResponseWriter, r *http.Request)

func (*Server) GetConfigurationVersion

func (s *Server) GetConfigurationVersion(w http.ResponseWriter, r *http.Request)

func (*Server) GetEntitlements

func (s *Server) GetEntitlements(w http.ResponseWriter, r *http.Request)

func (*Server) GetJSONPlanByRunID added in v0.0.8

func (s *Server) GetJSONPlanByRunID(w http.ResponseWriter, r *http.Request)

func (*Server) GetOrganization

func (s *Server) GetOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) GetPlan

func (s *Server) GetPlan(w http.ResponseWriter, r *http.Request)

func (*Server) GetPlanFile added in v0.0.8

func (s *Server) GetPlanFile(w http.ResponseWriter, r *http.Request)

func (*Server) GetPlanJSON

func (s *Server) GetPlanJSON(w http.ResponseWriter, r *http.Request)

func (*Server) GetPlanLogs

func (s *Server) GetPlanLogs(w http.ResponseWriter, r *http.Request)

func (*Server) GetRun

func (s *Server) GetRun(w http.ResponseWriter, r *http.Request)

func (*Server) GetRunLogs added in v0.0.10

func (s *Server) GetRunLogs(w http.ResponseWriter, r *http.Request)

GetRunLogs gets the logs for a run, combining the logs of both its plan and then its apply.

func (*Server) GetStateVersion

func (s *Server) GetStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) GetWorkspace

func (s *Server) GetWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) GetWorkspaceByID

func (s *Server) GetWorkspaceByID(w http.ResponseWriter, r *http.Request)

func (*Server) ListConfigurationVersions

func (s *Server) ListConfigurationVersions(w http.ResponseWriter, r *http.Request)

func (*Server) ListOrganizations

func (s *Server) ListOrganizations(w http.ResponseWriter, r *http.Request)

func (*Server) ListRuns

func (s *Server) ListRuns(w http.ResponseWriter, r *http.Request)

func (*Server) ListStateVersions

func (s *Server) ListStateVersions(w http.ResponseWriter, r *http.Request)

func (*Server) ListWorkspaces

func (s *Server) ListWorkspaces(w http.ResponseWriter, r *http.Request)

func (*Server) LockWorkspace

func (s *Server) LockWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) Open

func (s *Server) Open() (err error)

Open validates the server options and begins listening on the bind address.

func (*Server) Port

func (s *Server) Port() int

Port returns the TCP port for the running server. This is useful in tests where we allocate a random port by using ":0".

func (*Server) SetupRoutes added in v0.0.8

func (s *Server) SetupRoutes()

func (*Server) UnlockWorkspace

func (s *Server) UnlockWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateOrganization

func (s *Server) UpdateOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateWorkspace

func (s *Server) UpdateWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateWorkspaceByID

func (s *Server) UpdateWorkspaceByID(w http.ResponseWriter, r *http.Request)

func (*Server) UploadApplyLogs added in v0.0.8

func (s *Server) UploadApplyLogs(w http.ResponseWriter, r *http.Request)

func (*Server) UploadConfigurationVersion

func (s *Server) UploadConfigurationVersion(w http.ResponseWriter, r *http.Request)

func (*Server) UploadPlanFile added in v0.0.8

func (s *Server) UploadPlanFile(w http.ResponseWriter, r *http.Request)

func (*Server) UploadPlanLogs added in v0.0.8

func (s *Server) UploadPlanLogs(w http.ResponseWriter, r *http.Request)

func (*Server) Wait

func (s *Server) Wait(ctx context.Context) error

Wait blocks until server stops listening or context is cancelled.

func (*Server) WellKnown

func (s *Server) WellKnown(w http.ResponseWriter, r *http.Request)

type StateVersion added in v0.0.8

type StateVersion struct {
	ID           string    `jsonapi:"primary,state-versions"`
	CreatedAt    time.Time `jsonapi:"attr,created-at,iso8601"`
	DownloadURL  string    `jsonapi:"attr,hosted-state-download-url"`
	Serial       int64     `jsonapi:"attr,serial"`
	VCSCommitSHA string    `jsonapi:"attr,vcs-commit-sha"`
	VCSCommitURL string    `jsonapi:"attr,vcs-commit-url"`

	// Relations
	Run     *Run                  `jsonapi:"relation,run"`
	Outputs []*StateVersionOutput `jsonapi:"relation,outputs"`
}

StateVersion represents a Terraform Enterprise state version.

func StateVersionJSONAPIObject added in v0.0.8

func StateVersionJSONAPIObject(r *otf.StateVersion) *StateVersion

StateVersionJSONAPIObject converts a StateVersion to a struct that can be marshalled into a JSON-API object

type StateVersionList added in v0.0.8

type StateVersionList struct {
	*otf.Pagination
	Items []*StateVersion
}

StateVersionList represents a list of state versions.

func StateVersionListJSONAPIObject added in v0.0.8

func StateVersionListJSONAPIObject(cvl *otf.StateVersionList) *StateVersionList

StateVersionListJSONAPIObject converts a StateVersionList to a struct that can be marshalled into a JSON-API object

type StateVersionOutput added in v0.0.8

type StateVersionOutput struct {
	ID        string `jsonapi:"primary,state-version-outputs"`
	Name      string `jsonapi:"attr,name"`
	Sensitive bool   `jsonapi:"attr,sensitive"`
	Type      string `jsonapi:"attr,type"`
	Value     string `jsonapi:"attr,value"`
}

func StateVersionOutputJSONAPIObject added in v0.0.8

func StateVersionOutputJSONAPIObject(svo *otf.StateVersionOutput) *StateVersionOutput

StateVersionOutputJSONAPIObject converts a StateVersionOutput to a struct that can be marshalled into a JSON-API object

func StateVersionOutputListJSONAPIObject added in v0.0.8

func StateVersionOutputListJSONAPIObject(svol otf.StateVersionOutputList) []*StateVersionOutput

StateVersionOutputListJSONAPIObject converts a StateVersionOutputList to a struct that can be marshalled into a JSON-API object

type TwoFactor added in v0.0.8

type TwoFactor struct {
	Enabled  bool `jsonapi:"attr,enabled"`
	Verified bool `jsonapi:"attr,verified"`
}

TwoFactor represents the organization permissions.

type User added in v0.0.8

type User struct {
	ID               string     `jsonapi:"primary,users"`
	AvatarURL        string     `jsonapi:"attr,avatar-url"`
	Email            string     `jsonapi:"attr,email"`
	IsServiceAccount bool       `jsonapi:"attr,is-service-account"`
	TwoFactor        *TwoFactor `jsonapi:"attr,two-factor"`
	UnconfirmedEmail string     `jsonapi:"attr,unconfirmed-email"`
	Username         string     `jsonapi:"attr,username"`
	V2Only           bool       `jsonapi:"attr,v2-only"`
}

User represents a Terraform Enterprise user.

type VCSRepoOptions added in v0.0.8

type VCSRepoOptions struct {
	Branch            *string `json:"branch,omitempty"`
	Identifier        *string `json:"identifier,omitempty"`
	IngressSubmodules *bool   `json:"ingress-submodules,omitempty"`
	OAuthTokenID      *string `json:"oauth-token-id,omitempty"`
}

VCSRepoOptions is used by workspaces, policy sets, and registry modules VCSRepoOptions represents the configuration options of a VCS integration.

type WebRoute

type WebRoute string
const (
	// ShutdownTimeout is the time given for outstanding requests to finish
	// before shutdown.
	ShutdownTimeout = 1 * time.Second

	UploadConfigurationVersionRoute WebRoute = "/configuration-versions/%v/upload"
	GetPlanLogsRoute                WebRoute = "plans/%v/logs"
	GetApplyLogsRoute               WebRoute = "applies/%v/logs"
)

type WellKnown

type WellKnown struct {
	ModulesV1  string `json:"modules.v1"`
	MotdV1     string `json:"motd.v1"`
	StateV2    string `json:"state.v2"`
	TfeV2      string `json:"tfe.v2"`
	TfeV21     string `json:"tfe.v2.1"`
	TfeV22     string `json:"tfe.v2.2"`
	VersionsV1 string `json:"versions.v1"`
}

type Workspace added in v0.0.8

type Workspace struct {
	ID                         string                    `jsonapi:"primary,workspaces"`
	Actions                    *otf.WorkspaceActions     `jsonapi:"attr,actions"`
	AgentPoolID                string                    `jsonapi:"attr,agent-pool-id"`
	AllowDestroyPlan           bool                      `jsonapi:"attr,allow-destroy-plan"`
	AutoApply                  bool                      `jsonapi:"attr,auto-apply"`
	CanQueueDestroyPlan        bool                      `jsonapi:"attr,can-queue-destroy-plan"`
	CreatedAt                  time.Time                 `jsonapi:"attr,created-at,iso8601"`
	Description                string                    `jsonapi:"attr,description"`
	Environment                string                    `jsonapi:"attr,environment"`
	ExecutionMode              string                    `jsonapi:"attr,execution-mode"`
	FileTriggersEnabled        bool                      `jsonapi:"attr,file-triggers-enabled"`
	GlobalRemoteState          bool                      `jsonapi:"attr,global-remote-state"`
	Locked                     bool                      `jsonapi:"attr,locked"`
	MigrationEnvironment       string                    `jsonapi:"attr,migration-environment"`
	Name                       string                    `jsonapi:"attr,name"`
	Operations                 bool                      `jsonapi:"attr,operations"`
	Permissions                *otf.WorkspacePermissions `jsonapi:"attr,permissions"`
	QueueAllRuns               bool                      `jsonapi:"attr,queue-all-runs"`
	SpeculativeEnabled         bool                      `jsonapi:"attr,speculative-enabled"`
	SourceName                 string                    `jsonapi:"attr,source-name"`
	SourceURL                  string                    `jsonapi:"attr,source-url"`
	StructuredRunOutputEnabled bool                      `jsonapi:"attr,structured-run-output-enabled"`
	TerraformVersion           string                    `jsonapi:"attr,terraform-version"`
	TriggerPrefixes            []string                  `jsonapi:"attr,trigger-prefixes"`
	VCSRepo                    *otf.VCSRepo              `jsonapi:"attr,vcs-repo"`
	WorkingDirectory           string                    `jsonapi:"attr,working-directory"`
	UpdatedAt                  time.Time                 `jsonapi:"attr,updated-at,iso8601"`
	ResourceCount              int                       `jsonapi:"attr,resource-count"`
	ApplyDurationAverage       time.Duration             `jsonapi:"attr,apply-duration-average"`
	PlanDurationAverage        time.Duration             `jsonapi:"attr,plan-duration-average"`
	PolicyCheckFailures        int                       `jsonapi:"attr,policy-check-failures"`
	RunFailures                int                       `jsonapi:"attr,run-failures"`
	RunsCount                  int                       `jsonapi:"attr,workspace-kpis-runs-count"`

	// Relations
	CurrentRun   *Run          `jsonapi:"relation,current-run"`
	Organization *Organization `jsonapi:"relation,organization"`
}

Workspace represents a Terraform Enterprise workspace.

func WorkspaceJSONAPIObject added in v0.0.8

func WorkspaceJSONAPIObject(ws *otf.Workspace) *Workspace

WorkspaceJSONAPIObject converts a Workspace to a struct that can be marshalled into a JSON-API object

func (*Workspace) ToDomain added in v0.0.8

func (w *Workspace) ToDomain() *otf.Workspace

ToDomain converts an http obj to its domain equivalent

type WorkspaceList added in v0.0.8

type WorkspaceList struct {
	*otf.Pagination
	Items []*Workspace
}

WorkspaceList represents a list of workspaces.

func WorkspaceListJSONAPIObject added in v0.0.8

func WorkspaceListJSONAPIObject(cvl *otf.WorkspaceList) *WorkspaceList

WorkspaceListJSONAPIObject converts a WorkspaceList to a struct that can be marshalled into a JSON-API object

func (*WorkspaceList) ToDomain added in v0.0.8

func (wl *WorkspaceList) ToDomain() *otf.WorkspaceList

ToDomain converts http workspace list obj to a domain workspace list obj.

Jump to

Keyboard shortcuts

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