Thanks to visit codestin.com
Credit goes to pkg.go.dev

types

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: AGPL-3.0 Imports: 14 Imported by: 2

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 (
	// DiagnosticCodeRequired is used when a parameter value is `null`, but
	// the parameter is required.
	DiagnosticCodeRequired = "required"
)
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 CtyValueStringDefault added in v1.0.0

func CtyValueStringDefault(def string, val cty.Value) string

func DiagnosticCode added in v1.0.0

func DiagnosticCode(diag *hcl.Diagnostic, code string) *hcl.Diagnostic

func SetDiagnosticExtra added in v1.0.0

func SetDiagnosticExtra(diag *hcl.Diagnostic, extra DiagnosticExtra)

func SortParameters

func SortParameters(lists []Parameter)

Types

type DiagnosticExtra added in v1.0.0

type DiagnosticExtra struct {
	Code string `json:"code"`

	// If there was a previous extra, store it here for unwrapping.
	Wrapped any
}

func ExtractDiagnosticExtra added in v1.0.0

func ExtractDiagnosticExtra(diag *hcl.Diagnostic) DiagnosticExtra

func (DiagnosticExtra) UnwrapDiagnosticExtra added in v1.0.0

func (e DiagnosticExtra) UnwrapDiagnosticExtra() interface{}

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) FriendlyDiagnostics added in v1.0.0

func (d Diagnostics) FriendlyDiagnostics() []FriendlyDiagnostic

func (Diagnostics) MarshalJSON

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

func (*Diagnostics) UnmarshalJSON added in v1.0.0

func (d *Diagnostics) UnmarshalJSON(data []byte) error

type FriendlyDiagnostic

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

	Extra DiagnosticExtra `json:"extra"`
}

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 NullString added in v1.0.0

func NullString() 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) NullHCLString added in v1.0.0

func (s HCLString) NullHCLString() NullHCLString

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      ParameterStyling           `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.

func (*ParameterData) Valid added in v1.0.0

func (r *ParameterData) Valid(value HCLString) hcl.Diagnostics

type ParameterOption

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

type ParameterStyling added in v1.0.0

type ParameterStyling struct {
	Placeholder *string `json:"placeholder,omitempty"`
	Disabled    *bool   `json:"disabled,omitempty"`
	Label       *string `json:"label,omitempty"`
	MaskInput   *bool   `json:"mask_input,omitempty"`
}

type ParameterType

type ParameterType provider.OptionType

TODO: Just use the provider type directly.

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"`
}

type Tag

type Tag struct {
	Key   HCLString
	Value HCLString
}

@typescript-ignore Tag

func (Tag) AsStrings

func (t Tag) AsStrings() (key string, value 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