{"modulePath":"github.com/coder/preview","version":"v1.0.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package types\n\n## Constants\n\n```go\nconst (\n\t// DiagnosticCodeRequired is used when a parameter value is `null`, but\n\t// the parameter is required.\n\tDiagnosticCodeRequired = \"required\"\n\n\t// DiagnosticModuleNotLoaded is used when a module block is present, but\n\t// the mode failed to load. This can be because `.terraform/modules` is\n\t// not present.\n\tDiagnosticModuleNotLoaded = \"module_not_loaded\"\n)\n```\n\n```go\nconst (\n\tBlockTypeParameter    = \"coder_parameter\"\n\tBlockTypeWorkspaceTag = \"coder_workspace_tag\"\n\n\tValidationMonotonicIncreasing = \"increasing\"\n\tValidationMonotonicDecreasing = \"decreasing\"\n)\n```\n@typescript-ignore BlockTypeParameter @typescript-ignore BlockTypeWorkspaceTag\n\n```go\nconst (\n\tBlockTypePreset = \"coder_workspace_preset\"\n)\n```\n\n```go\nconst BlockTypeSecret = \"coder_secret\"\n```\n@typescript-ignore BlockTypeSecret\n\n```go\nconst (\n\tUnknownStringValue = \"\"\n)\n```\n\n## Functions\n\n```go\nfunc DiagnosticCode(diag *hcl.Diagnostic, code string) *hcl.Diagnostic\n```\n\n```go\nfunc SetDiagnosticExtra(diag *hcl.Diagnostic, extra DiagnosticExtra)\n```\n\n```go\nfunc SortParameters(lists []Parameter)\n```\n\n```go\nfunc SortSecretRequirements(reqs []SecretRequirement)\n```\nSortSecretRequirements orders requirements first by Env then by File so diagnostic output is stable across runs.\n\n## Types\n\n```go\ntype DiagnosticExtra struct {\n\tCode string `json:\"code\"`\n\n\t// If there was a previous extra, store it here for unwrapping.\n\tWrapped any\n}\n```\n\n```go\nfunc ExtractDiagnosticExtra(diag *hcl.Diagnostic) DiagnosticExtra\n```\n\n```go\nfunc (e DiagnosticExtra) UnwrapDiagnosticExtra() interface{}\n```\n\n```go\ntype DiagnosticSeverityString string\n```\n\n```go\nconst (\n\tDiagnosticSeverityError   DiagnosticSeverityString = \"error\"\n\tDiagnosticSeverityWarning DiagnosticSeverityString = \"warning\"\n)\n```\n\n```go\ntype Diagnostics hcl.Diagnostics\n```\nDiagnostics is a JSON friendly form of hcl.Diagnostics. Data is lost when doing a json marshal.\n\n```go\nfunc (d Diagnostics) FriendlyDiagnostics() []FriendlyDiagnostic\n```\n\n```go\nfunc (d Diagnostics) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (d *Diagnostics) UnmarshalJSON(data []byte) error\n```\n\n```go\ntype FriendlyDiagnostic struct {\n\tSeverity DiagnosticSeverityString `json:\"severity\"`\n\tSummary  string                   `json:\"summary\"`\n\tDetail   string                   `json:\"detail\"`\n\n\tExtra DiagnosticExtra `json:\"extra\"`\n}\n```\n\n```go\ntype HCLString struct {\n\tValue cty.Value\n\n\t// ValueDiags are any diagnostics that occurred\n\t// while evaluating the value\n\tValueDiags hcl.Diagnostics\n\t// ValueExp is the underlying source expression\n\tValueExpr hcl.Expression\n\t// Source is the literal hcl text that was parsed.\n\t// This is a best effort, it may not be available.\n\tSource *string\n}\n```\n@typescript-ignore HCLString\n\n```go\nfunc NullString() HCLString\n```\n\n```go\nfunc StringLiteral(s string) HCLString\n```\n\n```go\nfunc ToHCLString(block *terraform.Block, attr *terraform.Attribute) HCLString\n```\n\n```go\nfunc (s HCLString) AsString() string\n```\nAsString 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.\n\n```go\nfunc (s HCLString) IsKnown() bool\n```\n\n```go\nfunc (s HCLString) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (s HCLString) NullHCLString() NullHCLString\n```\n\n```go\nfunc (s *HCLString) UnmarshalJSON(data []byte) error\n```\n\n```go\nfunc (s HCLString) Valid() bool\n```\n\n```go\ntype NullHCLString struct {\n\tValue string `json:\"value\"`\n\tValid bool   `json:\"valid\"`\n}\n```\n\n```go\ntype Parameter struct {\n\tParameterData\n\t// Value is not immediately cast into a string.\n\t// Value is not required at template import, so defer\n\t// casting to a string until it is absolutely necessary.\n\tValue HCLString `json:\"value\"`\n\n\t// Diagnostics is used to store any errors that occur during parsing\n\t// of the parameter.\n\tDiagnostics Diagnostics `json:\"diagnostics\"`\n}\n```\n\n```go\ntype ParameterData struct {\n\tName         string                     `json:\"name\"`\n\tDisplayName  string                     `json:\"display_name\"`\n\tDescription  string                     `json:\"description\"`\n\tType         ParameterType              `json:\"type\"`\n\tFormType     provider.ParameterFormType `json:\"form_type\"`\n\tStyling      ParameterStyling           `json:\"styling\"`\n\tMutable      bool                       `json:\"mutable\"`\n\tDefaultValue HCLString                  `json:\"default_value\"`\n\tIcon         string                     `json:\"icon\"`\n\tOptions      []*ParameterOption         `json:\"options\"`\n\tValidations  []*ParameterValidation     `json:\"validations\"`\n\tRequired     bool                       `json:\"required\"`\n\t// legacy_variable_name was removed (= 14)\n\tOrder     int64 `json:\"order\"`\n\tEphemeral bool  `json:\"ephemeral\"`\n\n\t// Unexported fields, not always available.\n\tSource *terraform.Block `json:\"-\"`\n}\n```\n\n```go\nfunc (r *ParameterData) CtyType() (cty.Type, error)\n```\nCtyType returns the cty.Type for the ParameterData. A fixed set of types are supported.\n\n```go\nfunc (r *ParameterData) Valid(value HCLString) hcl.Diagnostics\n```\n\n```go\ntype ParameterOption struct {\n\tName        string    `json:\"name\"`\n\tDescription string    `json:\"description\"`\n\tValue       HCLString `json:\"value\"`\n\tIcon        string    `json:\"icon\"`\n}\n```\n\n```go\ntype ParameterStyling struct {\n\tPlaceholder *string `json:\"placeholder,omitempty\"`\n\tDisabled    *bool   `json:\"disabled,omitempty\"`\n\tLabel       *string `json:\"label,omitempty\"`\n\tMaskInput   *bool   `json:\"mask_input,omitempty\"`\n}\n```\n\n```go\ntype ParameterType provider.OptionType\n```\nTODO: Just use the provider type directly.\n\n```go\nconst (\n\tParameterTypeString     ParameterType = \"string\"\n\tParameterTypeNumber     ParameterType = \"number\"\n\tParameterTypeBoolean    ParameterType = \"bool\"\n\tParameterTypeListString ParameterType = \"list(string)\"\n)\n```\n\n```go\nfunc (t ParameterType) Valid() error\n```\n\n```go\ntype ParameterValidation struct {\n\tError string `json:\"validation_error\"`\n\n\t// All validation attributes are optional.\n\tRegex     *string `json:\"validation_regex\"`\n\tMin       *int64  `json:\"validation_min\"`\n\tMax       *int64  `json:\"validation_max\"`\n\tMonotonic *string `json:\"validation_monotonic\"`\n}\n```\n\n```go\ntype PrebuildData struct {\n\tInstances int `json:\"instances\"`\n}\n```\n\n```go\ntype Preset struct {\n\tPresetData\n\t// Diagnostics is used to store any errors that occur during parsing\n\t// of the preset.\n\tDiagnostics Diagnostics `json:\"diagnostics\"`\n}\n```\n\n```go\ntype PresetData struct {\n\tName       string            `json:\"name\"`\n\tParameters map[string]string `json:\"parameters\"`\n\tDefault    bool              `json:\"default\"`\n\tPrebuilds  *PrebuildData     `json:\"prebuilds,omitempty\"`\n}\n```\n\n```go\ntype SecretRequirement struct {\n\tEnv         string `json:\"env,omitempty\"`\n\tFile        string `json:\"file,omitempty\"`\n\tHelpMessage string `json:\"help_message,omitempty\"`\n}\n```\nSecretRequirement describes a \\`data \"coder\\_secret\"\\` block declared in a template. Exactly one of Env or File will be non-empty; validation of that invariant happens during extraction.\n\n```go\ntype Tag struct {\n\tKey   HCLString\n\tValue HCLString\n}\n```\n@typescript-ignore Tag\n\n```go\nfunc (t Tag) AsStrings() (key string, value string)\n```\n\n```go\nfunc (t Tag) IsKnown() bool\n```\n\n```go\nfunc (t Tag) KeyString() string\n```\n\n```go\nfunc (t Tag) References() []string\n```\n\n```go\nfunc (t Tag) Valid() bool\n```\n\n```go\ntype TagBlock struct {\n\tTags  Tags\n\tBlock *terraform.Block\n}\n```\n@typescript-ignore TagBlock\n\n```go\nfunc (b TagBlock) UnusableTags() Tags\n```\n\n```go\nfunc (b TagBlock) ValidTags() map[string]string\n```\n\n```go\ntype TagBlocks []TagBlock\n```\n@typescript-ignore TagBlocks\n\n```go\nfunc (b TagBlocks) Tags() map[string]string\n```\n\n```go\nfunc (b TagBlocks) UnusableTags() Tags\n```\n\n```go\ntype Tags []Tag\n```\n@typescript-ignore Tags\n\n```go\nfunc (t Tags) SafeNames() []string\n```\n\n```go\ntype Variable struct {\n\tName string `json:\"name\"`\n\t// JSON marshalling of cty types and values is not safe. Until these json values\n\t// are needed, serialization of them is not supported.\n\t// If serialization is supported, a custom marshaller will be needed.\n\tDefault     cty.Value `json:\"-\"`\n\tType        cty.Type  `json:\"-\"`\n\tDescription string    `json:\"description\"`\n\tNullable    bool      `json:\"nullable\"`\n\tSensitive   bool      `json:\"sensitive\"`\n\n\tDiagnostics Diagnostics `json:\"diagnostics\"`\n}\n```\n\n```go\ntype WorkspaceOwner struct {\n\tID           string `json:\"id\" cty:\"id\"`\n\tName         string `json:\"name\" cty:\"name\"`\n\tFullName     string `json:\"full_name\" cty:\"full_name\"`\n\tEmail        string `json:\"email\" cty:\"email\"`\n\tSSHPublicKey string `json:\"ssh_public_key\" cty:\"ssh_public_key\"`\n\t// SSHPrivateKey is intentionally omitted for now, due to the security risk\n\t// that exposing it poses.\n\t// SSHPrivateKey string `json:\"ssh_private_key\" cty:\"ssh_private_key\"`\n\tGroups []string `json:\"groups\" cty:\"groups\"`\n\t// SessionToken is intentionally omitted for now, due to the security risk\n\t// that exposing it poses.\n\t// SessionToken string `json:\"session_token\" cty:\"session_token\"`\n\t// OIDCAccessToken is intentionally omitted for now, due to the security risk\n\t// that exposing it poses.\n\t// OIDCAccessToken string `json:\"oidc_access_token\" cty:\"oidc_access_token\"`\n\tLoginType string                   `json:\"login_type\" cty:\"login_type\"`\n\tRBACRoles []WorkspaceOwnerRBACRole `json:\"rbac_roles\" cty:\"rbac_roles\"`\n}\n```\nBased on [https://github.com/coder/terraform-provider-coder/blob/9a745586b23a9cb5de2f65a2dcac12e48b134ffa/provider/workspace\\_owner.go#L72](https://github.com/coder/terraform-provider-coder/blob/9a745586b23a9cb5de2f65a2dcac12e48b134ffa/provider/workspace_owner.go#L72)\n\n```go\nfunc (o *WorkspaceOwner) ToCtyValue() (cty.Value, error)\n```\n\n```go\ntype WorkspaceOwnerRBACRole struct {\n\tName  string `json:\"name\" cty:\"name\"`\n\tOrgID string `json:\"org_id\" cty:\"org_id\"`\n}\n```\n\n","path":"github.com/coder/preview/types","name":"types","synopsis":"","isRedistributable":true}
