resource

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MPL-2.0 Imports: 2 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 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
}

Resource describes a known API resource type.

func All

func All() []Resource

All returns all registered resources.

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(name string) *Resource

ByName 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