Documentation
¶
Index ¶
- Constants
- Variables
- func ExternalAuthAccessTokenEnvironmentVariable(id string) string
- func IsPrebuildEnvironmentVariable() string
- func New() *schema.Provider
- func ParameterEnvironmentVariable(name string) string
- func ParameterEnvironmentVariablePrevious(name string) string
- func RunningAgentTokenEnvironmentVariable(agentID string) string
- func ValidateFormType(paramType OptionType, optionCount int, specifiedFormType ParameterFormType) (OptionType, ParameterFormType, error)
- type Option
- type OptionType
- type Parameter
- type ParameterFormType
- type Validation
- type WorkspacePrebuild
- type WorkspacePreset
- type WorkspaceTags
Constants ¶
const ( ValidationMonotonicIncreasing = "increasing" ValidationMonotonicDecreasing = "decreasing" )
Variables ¶
var ScriptCRONParser = cron.NewParser(cron.Second | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
Functions ¶
func IsPrebuildEnvironmentVariable ¶ added in v2.4.0
func IsPrebuildEnvironmentVariable() string
IsPrebuildEnvironmentVariable returns the name of the environment variable that indicates whether the workspace is an unclaimed prebuilt workspace.
Knowing whether the workspace is an unclaimed prebuilt workspace allows template authors to conditionally execute code in the template based on whether the workspace has been assigned to a user or not. This allows identity specific configuration to be applied only after the workspace is claimed, while the rest of the workspace can be pre-configured.
The value of this environment variable should be set to "true" if the workspace is prebuilt and it has not yet been claimed by a user. Any other values, including "false" and "" will be interpreted to mean that the workspace is not prebuilt, or was prebuilt but has since been claimed by a user.
func ParameterEnvironmentVariable ¶
ParameterEnvironmentVariable returns the environment variable to specify for a parameter by it's name. It's hashed because spaces and special characters can be used in parameter names that may not be valid in env vars.
func ParameterEnvironmentVariablePrevious ¶ added in v2.4.0
ParameterEnvironmentVariablePrevious returns the environment variable to specify for a parameter's previous value. This is used for workspace subsequent builds after the first. Primarily to validate monotonicity in the `validation` block.
func RunningAgentTokenEnvironmentVariable ¶ added in v2.4.0
RunningAgentTokenEnvironmentVariable returns the name of an environment variable that contains the token to use for the running agent. This is used for prebuilds, where we want to reuse the same token for the next iteration of a workspace agent before and after the workspace was claimed by a user.
By reusing an existing token, we can avoid the need to change a value that may have been used immutably. Thus, allowing us to avoid reprovisioning resources that may take a long time to replace.
agentID is unused for now, but will be used as soon as we support multiple agents.
func ValidateFormType ¶ added in v2.4.0
func ValidateFormType(paramType OptionType, optionCount int, specifiedFormType ParameterFormType) (OptionType, ParameterFormType, error)
ValidateFormType handles the truth table for the valid set of `type` and `form_type` options. The OptionType is also returned because it is possible the 'type' of the 'value' & 'default' fields is different from the 'type' of the options. The use case is when using multi-select. The options are 'string' and the value is 'list(string)'.
Types ¶
type OptionType ¶ added in v2.4.0
type OptionType = string
OptionType is a type of option that can be used in the 'type' argument of a parameter. These should match types as defined in terraform:
https://developer.hashicorp.com/terraform/language/expressions/types
The value have to be string literals, as type constraint keywords are not supported in providers.
const ( OptionTypeString OptionType = "string" OptionTypeNumber OptionType = "number" OptionTypeBoolean OptionType = "bool" OptionTypeListString OptionType = "list(string)" )
func OptionTypes ¶ added in v2.4.0
func OptionTypes() []OptionType
type Parameter ¶
type Parameter struct { Name string DisplayName string `mapstructure:"display_name"` Description string Type OptionType FormType ParameterFormType Mutable bool Default *string Icon string Option []Option Validation []Validation Optional bool Order int Ephemeral bool }
func (*Parameter) ValidOptions ¶ added in v2.4.0
func (v *Parameter) ValidOptions(optionType OptionType) (map[string]struct{}, diag.Diagnostics)
func (*Parameter) ValidateInput ¶ added in v2.4.0
type ParameterFormType ¶ added in v2.4.0
type ParameterFormType string
ParameterFormType is the list of supported form types for display in the Coder "create workspace" form. These form types are functional as well as cosmetic. Refer to `formTypeTruthTable` for the allowed pairings. For example, "multi-select" has the type "list(string)" but the option values are "string".
const ( ParameterFormTypeDefault ParameterFormType = "" ParameterFormTypeRadio ParameterFormType = "radio" ParameterFormTypeSlider ParameterFormType = "slider" ParameterFormTypeInput ParameterFormType = "input" ParameterFormTypeDropdown ParameterFormType = "dropdown" ParameterFormTypeCheckbox ParameterFormType = "checkbox" ParameterFormTypeSwitch ParameterFormType = "switch" ParameterFormTypeMultiSelect ParameterFormType = "multi-select" ParameterFormTypeTagSelect ParameterFormType = "tag-select" ParameterFormTypeTextArea ParameterFormType = "textarea" ParameterFormTypeError ParameterFormType = "error" )
func ParameterFormTypes ¶ added in v2.4.0
func ParameterFormTypes() []ParameterFormType
ParameterFormTypes should be kept in sync with the enum list above.
type Validation ¶
type Validation struct { Min int MinDisabled bool `mapstructure:"min_disabled"` Max int MaxDisabled bool `mapstructure:"max_disabled"` Monotonic string Regex string Error string }
func (*Validation) Valid ¶
func (v *Validation) Valid(typ OptionType, value string, previous *string) error
type WorkspacePrebuild ¶ added in v2.4.0
type WorkspacePrebuild struct {
Instances int `mapstructure:"instances"`
}
type WorkspacePreset ¶ added in v2.1.3
type WorkspacePreset struct { Name string `mapstructure:"name"` Parameters map[string]string `mapstructure:"parameters"` // There should always be only one prebuild block, but Terraform's type system // still parses them as a slice, so we need to handle it as such. We could use // an anonymous type and rd.Get to avoid a slice here, but that would not be possible // for utilities that parse our terraform output using this type. To remain compatible // with those cases, we use a slice here. Prebuilds []WorkspacePrebuild `mapstructure:"prebuilds"` }