Documentation
¶
Overview ¶
Package hclconfig reads and writes TFx profile blocks in ~/.tfx.hcl.
Profile block format:
profile "default" {
hostname = "app.terraform.io"
organization = "my-org"
token = "abc123..."
}
The block label is the profile name (a user-editable alias — not the hostname). hostname is an optional key inside the block; it defaults to DefaultHostname ("app.terraform.io") when omitted.
Index ¶
Constants ¶
const ( // DefaultProfileName is the profile name used when none is specified. DefaultProfileName = "default" // DefaultHostname is the TFE/HCP Terraform hostname used when none is specified. DefaultHostname = "app.terraform.io" )
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
DefaultConfigPath returns the canonical path to ~/.tfx.hcl.
func WriteProfile ¶
WriteProfile adds or replaces the named profile block in the file at path. If path does not exist it is created. All other profiles and file content are preserved. The file is written with 0600 permissions because it contains an API token.
name defaults to DefaultProfileName when empty. hostname defaults to DefaultHostname when empty. organization may be empty; a commented placeholder is written instead.
Types ¶
type Profile ¶
type Profile struct {
Name string // block label — user-editable alias
Hostname string // hostname value; defaults to DefaultHostname if omitted
Organization string // organization value; may be empty
Token string // token value
}
Profile holds configuration for one TFx profile.
func ListProfiles ¶
ListProfiles parses path and returns all profile blocks in file order.
- Each profile block becomes one Profile. Name = block label; Hostname = hostname inside the block, or DefaultHostname when absent.
- File not found: returns nil, nil.
- Files without profile blocks: returns nil, nil.