resource

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package resource provides a registry of known HCP Terraform API resource types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColumnsForType

func ColumnsForType(typeName string) []string

ColumnsForType returns the preferred display columns for the given type, or nil.

func CompletionNames

func CompletionNames() []string

CompletionNames returns all type names and aliases (for shell autocompletion).

func CreatableNames

func CreatableNames() []string

CreatableNames returns names and aliases of resource types that support creation.

func ExcludeColumnsForType

func ExcludeColumnsForType(typeName string) []string

ExcludeColumnsForType returns columns to exclude for the given type, or nil.

func IDPrefixForType

func IDPrefixForType(typeName string) string

IDPrefixForType returns the ID prefix for the given type name, or "" if unknown.

func IsResolvableType

func IsResolvableType(typeName string) bool

IsResolvableType returns true if the given type name (e.g. "workspaces") supports name-to-ID resolution via the API.

func Names

func Names() []string

Names returns sorted canonical type names (for error messages).

Types

type Destroyability added in v0.4.0

type Destroyability int

Destroyability indicates whether a resource can be destroyed.

const (
	// NotDestroyable indicates that the resource cannot be destroyed.
	NotDestroyable Destroyability = iota
	// Destroyable indicates that the resource can be destroyed normally.
	Destroyable
	// DestroyableRecoverable indicates that the resource can be destroyed but also can be recovered.
	DestroyableRecoverable
	// DestroyableButSensitive indicates that the resource can be destroyed but is considered irreversible/sensitive.
	DestroyableButSensitive
)

type Resource

type Resource struct {
	Type           string         // JSON:API type: "workspaces"
	Aliases        []string       // shorthand: ["ws", "workspace"]
	IDPrefix       string         // "ws-" (empty if unknown)
	PathGet        string         // "/workspaces/{id}"
	PathList       string         // "/organizations/{organization_name}/workspaces" (empty if not top-level listable)
	PathCreate     string         // "/organizations/{organization_name}/workspaces" (empty if not supported)
	Resolvable     bool           // true if the API supports name-to-ID resolution for this type
	Columns        []string       // most important attributes for display (nil = auto-detect)
	ExcludeColumns []string       // attributes to exclude from display
	Destroyable    Destroyability // indicates if and how this resource can be destroyed
}

Resource describes a known API resource type.

func All

func All() []Resource

All returns all registered resources.

func AllDestroyable added in v0.4.0

func AllDestroyable() []Resource

AllDestroyable returns all registered resources that are destroyable.

func ByIDPrefix

func ByIDPrefix(value string) *Resource

ByIDPrefix scans the registry for a resource whose IDPrefix matches the beginning of value. Returns nil if no match is found or if value is empty.

func ByName

func ByName(typeName string) (Resource, bool)

ByName looks up a resource by type name and returns it along with a boolean indicating if it was found. Presumes that the registry is sorted by the Type field.

func ByNameOrAlias added in v0.4.0

func ByNameOrAlias(name string) *Resource

ByNameOrAlias matches the canonical Type or any Alias, case-insensitive. Returns nil if not found.

Jump to

Keyboard shortcuts

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