Documentation
¶
Overview ¶
Package resource contains code common to all resources (orgs, workspaces, runs, etc)
Index ¶
- Constants
- Variables
- func GenerateRandomStringFromAlphabet(size int, alphabet string) string
- func ListAll[T any](fn func(PageOptions) (*Page[T], error)) ([]T, error)
- func ValidateName(name *string) error
- type Deleter
- type ID
- type Kind
- type Page
- type PageOptions
- type Pagination
- type TfeID
- func (id TfeID) IsZero() bool
- func (id TfeID) Kind() Kind
- func (id TfeID) MarshalText() ([]byte, error)
- func (id *TfeID) Scan(text any) error
- func (id *TfeID) Set(text string) error
- func (id TfeID) String() string
- func (*TfeID) Type() string
- func (id *TfeID) UnmarshalText(text []byte) error
- func (id *TfeID) Value() (driver.Value, error)
Constants ¶
const ( DefaultPageNumber = 1 DefaultPageSize = 20 MaxPageSize = 100 )
Variables ¶
var ErrInfinitePaginationDetected = errors.New("infinite pagination detected")
var ReStringID = regexp.MustCompile(`^[a-zA-Z0-9\-\._]+$`)
ReStringID is a regular expression used to validate common string ID patterns.
var SiteID site
SiteID identifies the "site", a top-level abstraction identifying the OTF system as a whole.
Functions ¶
func GenerateRandomStringFromAlphabet ¶ added in v0.3.6
GenerateRandomStringFromAlphabet generates a random string of a given size using characters from the given alphabet.
func ListAll ¶
ListAll is a helper for retrieving all pages. The provided fn should perform an operation that retrieves a page at a time.
func ValidateName ¶ added in v0.1.8
Types ¶
type Deleter ¶ added in v0.4.9
type Deleter[R deleteableResource] struct {
logr.Logger
OverrideCheckInterval time.Duration
AgeThreshold time.Duration
Client deleterClient[R]
}
Deleter deletes resources that are older than a user-specified age.
type Kind ¶ added in v0.3.6
type Kind string
const ( SiteKind Kind = "site" OrganizationKind Kind = "org" WorkspaceKind Kind = "ws" RunKind Kind = "run" ConfigVersionKind Kind = "cv" IngressAttributesKind Kind = "ia" JobKind Kind = "job" ChunkKind Kind = "chunk" UserKind Kind = "user" TeamKind Kind = "team" ModuleKind Kind = "mod" ModuleVersionKind Kind = "modver" NotificationConfigurationKind Kind = "nc" AgentPoolKind Kind = "apool" RunnerKind Kind = "runner" StateVersionKind Kind = "sv" StateVersionOutputKind Kind = "wsout" VariableSetKind Kind = "varset" VariableKind Kind = "var" VCSProviderKind Kind = "vcs" OrganizationTokenKind Kind = "ot" UserTokenKind Kind = "ut" TeamTokenKind Kind = "tt" AgentTokenKind Kind = "at" )
type Page ¶
type Page[T any] struct { Items []T *Pagination }
Page is a segment of a result set.
func NewPage ¶
NewPage constructs a page from a list of resources. If the list argument represents the full result set then count should be nil; if count is non-nil then the list is deemed to be a segment of a result set and count is the size of the full result set. This latter case is useful, say, if a database has already produced a segment of a full result set, e.g. using LIMIT and OFFSET.
type PageOptions ¶
type PageOptions struct {
// The page number to request. The results vary based on the PageSize.
PageNumber int `schema:"page,omitempty"`
// The number of elements returned in a single page.
PageSize int `schema:"page_size,omitempty"`
}
PageOptions are used to request a specific page.
type Pagination ¶
type Pagination struct {
CurrentPage int `json:"current-page"`
PreviousPage *int `json:"prev-page"`
NextPage *int `json:"next-page"`
TotalPages int `json:"total-pages"`
TotalCount int `json:"total-count"`
}
Pagination provides metadata about a page.
type TfeID ¶ added in v0.3.17
type TfeID struct {
// contains filtered or unexported fields
}
TfeID is an ID using the same format used for Terraform Enterprise resources, with a prefix designating the type of resource, appended with a unique base58 encoded id.
func ConvertTfeID ¶ added in v0.3.17
ConvertTfeID converts an ID for use with a different resource kind, e.g. convert run-123 to plan-123.
func MustHardcodeTfeID ¶ added in v0.3.17
func ParseTfeID ¶ added in v0.3.17
ParseTfeID parses the ID from a string representation.