types

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockTypeParameter    = "coder_parameter"
	BlockTypeWorkspaceTag = "coder_workspace_tag"

	ValidationMonotonicIncreasing = "increasing"
	ValidationMonotonicDecreasing = "decreasing"
)

@typescript-ignore BlockTypeParameter @typescript-ignore BlockTypeWorkspaceTag

View Source
const (
	UnknownStringValue = "??"
)

Variables

This section is empty.

Functions

func CtyValueString

func CtyValueString(val cty.Value) (string, error)

CtyValueString converts a cty.Value to a string. It supports only primitive types - bool, number, and string. As a special case, it also supports map[string]interface{} with key "value".

func SortParameters

func SortParameters(lists []Parameter)

Types

type DiagnosticSeverityString

type DiagnosticSeverityString string
const (
	DiagnosticSeverityError   DiagnosticSeverityString = "error"
	DiagnosticSeverityWarning DiagnosticSeverityString = "warning"
)

type Diagnostics

type Diagnostics hcl.Diagnostics

Diagnostics is a JSON friendly form of hcl.Diagnostics. Data is lost when doing a json marshal.

func (Diagnostics) MarshalJSON

func (d Diagnostics) MarshalJSON() ([]byte, error)

type FriendlyDiagnostic

type FriendlyDiagnostic struct {
	Severity DiagnosticSeverityString `json:"severity"`
	Summary  string                   `json:"summary"`
	Detail   string                   `json:"detail"`
}

type HCLString

type HCLString struct {
	Value cty.Value

	// ValueDiags are any diagnostics that occurred
	// while evaluating the value
	ValueDiags hcl.Diagnostics
	// ValueExp is the underlying source expression
	ValueExpr hcl.Expression
	// Source is the literal hcl text that was parsed.
	// This is a best effort, it may not be available.
	Source *string
}

@typescript-ignore HCLString

func StringLiteral

func StringLiteral(s string) HCLString

func ToHCLString

func ToHCLString(block *terraform.Block, attr *terraform.Attribute) HCLString

func (HCLString) AsString

func (s HCLString) AsString() string

AsString is a safe function. It will always return a string. The caller should check if this value is Valid and known before calling this function.

func (HCLString) IsKnown

func (s HCLString) IsKnown() bool

func (HCLString) MarshalJSON

func (s HCLString) MarshalJSON() ([]byte, error)

func (*HCLString) UnmarshalJSON

func (s *HCLString) UnmarshalJSON(data []byte) error

func (HCLString) Valid

func (s HCLString) Valid() bool

type NullHCLString

type NullHCLString struct {
	Value string `json:"value"`
	Valid bool   `json:"valid"`
}

type Parameter

type Parameter struct {
	ParameterData
	// Value is not immediately cast into a string.
	// Value is not required at template import, so defer
	// casting to a string until it is absolutely necessary.
	Value HCLString `json:"value"`

	// Diagnostics is used to store any errors that occur during parsing
	// of the parameter.
	Diagnostics Diagnostics `json:"diagnostics"`
}

type ParameterData

type ParameterData struct {
	Name         string                     `json:"name"`
	DisplayName  string                     `json:"display_name"`
	Description  string                     `json:"description"`
	Type         ParameterType              `json:"type"`
	FormType     provider.ParameterFormType `json:"form_type"`
	Styling      any                        `json:"styling"`
	Mutable      bool                       `json:"mutable"`
	DefaultValue HCLString                  `json:"default_value"`
	Icon         string                     `json:"icon"`
	Options      []*ParameterOption         `json:"options"`
	Validations  []*ParameterValidation     `json:"validations"`
	Required     bool                       `json:"required"`
	// legacy_variable_name was removed (= 14)
	Order     int64 `json:"order"`
	Ephemeral bool  `json:"ephemeral"`

	// Unexported fields, not always available.
	Source *terraform.Block `json:"-"`
}

func (*ParameterData) CtyType

func (r *ParameterData) CtyType() (cty.Type, error)

CtyType returns the cty.Type for the ParameterData. A fixed set of types are supported.

type ParameterOption

type ParameterOption struct {
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Value       HCLString `json:"value"`
	Icon        string    `json:"icon"`
}

type ParameterType

type ParameterType string
const (
	ParameterTypeString     ParameterType = "string"
	ParameterTypeNumber     ParameterType = "number"
	ParameterTypeBoolean    ParameterType = "bool"
	ParameterTypeListString ParameterType = "list(string)"
)

func (ParameterType) Valid

func (t ParameterType) Valid() error

type ParameterValidation

type ParameterValidation struct {
	Error string `json:"validation_error"`

	// All validation attributes are optional.
	Regex     *string `json:"validation_regex"`
	Min       *int64  `json:"validation_min"`
	Max       *int64  `json:"validation_max"`
	Monotonic *string `json:"validation_monotonic"`
	Invalid   *bool   `json:"validation_invalid"`
}

func (ParameterValidation) Valid

func (v ParameterValidation) Valid(typ string, value string) error

Valid takes the type of the value and the value itself and returns an error if the value is invalid.

type Tag

type Tag struct {
	Key   HCLString
	Value HCLString
}

@typescript-ignore Tag

func (Tag) AsStrings

func (t Tag) AsStrings() (string, string)

func (Tag) IsKnown

func (t Tag) IsKnown() bool

func (Tag) KeyString

func (t Tag) KeyString() string

func (Tag) References

func (t Tag) References() []string

func (Tag) Valid

func (t Tag) Valid() bool

type TagBlock

type TagBlock struct {
	Tags  Tags
	Block *terraform.Block
}

@typescript-ignore TagBlock

func (TagBlock) UnusableTags

func (b TagBlock) UnusableTags() Tags

func (TagBlock) ValidTags

func (b TagBlock) ValidTags() map[string]string

type TagBlocks

type TagBlocks []TagBlock

@typescript-ignore TagBlocks

func (TagBlocks) Tags

func (b TagBlocks) Tags() map[string]string

func (TagBlocks) UnusableTags

func (b TagBlocks) UnusableTags() Tags

type Tags

type Tags []Tag

@typescript-ignore Tags

func (Tags) SafeNames

func (t Tags) SafeNames() []string

type WorkspaceOwner

type WorkspaceOwner struct {
	ID           string `json:"id" cty:"id"`
	Name         string `json:"name" cty:"name"`
	FullName     string `json:"full_name" cty:"full_name"`
	Email        string `json:"email" cty:"email"`
	SSHPublicKey string `json:"ssh_public_key" cty:"ssh_public_key"`
	// SSHPrivateKey is intentionally omitted for now, due to the security risk
	// that exposing it poses.
	// SSHPrivateKey string `json:"ssh_private_key" cty:"ssh_private_key"`
	Groups []string `json:"groups" cty:"groups"`
	// SessionToken is intentionally omitted for now, due to the security risk
	// that exposing it poses.
	// SessionToken string `json:"session_token" cty:"session_token"`
	// OIDCAccessToken is intentionally omitted for now, due to the security risk
	// that exposing it poses.
	// OIDCAccessToken string `json:"oidc_access_token" cty:"oidc_access_token"`
	LoginType string                   `json:"login_type" cty:"login_type"`
	RBACRoles []WorkspaceOwnerRBACRole `json:"rbac_roles" cty:"rbac_roles"`
}

Based on https://github.com/coder/terraform-provider-coder/blob/9a745586b23a9cb5de2f65a2dcac12e48b134ffa/provider/workspace_owner.go#L72

func (*WorkspaceOwner) ToCtyValue

func (o *WorkspaceOwner) ToCtyValue() (cty.Value, error)

type WorkspaceOwnerRBACRole

type WorkspaceOwnerRBACRole struct {
	Name  string `json:"name" cty:"name"`
	OrgID string `json:"org_id" cty:"org_id"`
}

Jump to

Keyboard shortcuts

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