{"modulePath":"github.com/coder/preview","version":"v1.0.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package preview\n\n## Functions\n\n```go\nfunc ValidatePrebuilds(ctx context.Context, input Input, preValid []types.Preset, dir fs.FS)\n```\nValidatePrebuilds will iterate over each preset, validate the inputs as a set, and attach any diagnostics to the preset if there are issues. This must be done because prebuilds have to be valid without user input.\n\nThis will only validate presets that have prebuilds configured and have no existing error diagnostics. This should only be used when doing Template Imports as a protection against invalid presets.\n\nA preset doesn't need to specify all required parameters, as users can provide the remaining values when creating a workspace. However, since prebuild creation has no user input, presets used for prebuilds must provide all required parameter values.\n\n## Types\n\n```go\ntype Input struct {\n\t// PlanJSONPath is an optional path to a plan file. If PlanJSON isn't\n\t// specified, and PlanJSONPath is, then the file will be read and treated\n\t// as if the contents were passed in directly.\n\tPlanJSONPath    string\n\tPlanJSON        json.RawMessage\n\tParameterValues map[string]string\n\tOwner           types.WorkspaceOwner\n\tLogger          *slog.Logger\n\t// TFVars will override any variables set in '.tfvars' files.\n\t// The value set must be a cty.Value, as the type can be anything.\n\tTFVars map[string]cty.Value\n}\n```\n\n```go\nfunc (i Input) RichParameterValue(key string) (string, bool)\n```\n\n```go\ntype Output struct {\n\t// ModuleOutput is any 'output' values from the terraform files. This has 0\n\t// effect on the parameters, tags, etc. It can be helpful for debugging, as it\n\t// allows exporting some terraform values to the caller to review.\n\t//\n\t// JSON marshalling is handled in the custom methods.\n\tModuleOutput cty.Value `json:\"-\"`\n\n\tParameters         []types.Parameter         `json:\"parameters\"`\n\tWorkspaceTags      types.TagBlocks           `json:\"workspace_tags\"`\n\tPresets            []types.Preset            `json:\"presets\"`\n\tVariables          []types.Variable          `json:\"variables\"`\n\tSecretRequirements []types.SecretRequirement `json:\"secret_requirements\"`\n\t// Files is included for printing diagnostics.\n\t// They can be marshalled, but not unmarshalled. This is a limitation\n\t// of the HCL library.\n\tFiles map[string]*hcl.File `json:\"-\"`\n}\n```\n\n```go\nfunc Preview(ctx context.Context, input Input, dir fs.FS) (output *Output, diagnostics hcl.Diagnostics)\n```\n\n```go\nfunc (o Output) MarshalJSON() ([]byte, error)\n```\nMarshalJSON includes the ModuleOutput and files in the JSON output. Output should never be unmarshalled. Marshalling to JSON is strictly useful for debugging information.\n\n","path":"github.com/coder/preview","name":"preview","synopsis":"","isRedistributable":true}
