config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Process

func Process(target interface{}, flags *pflag.FlagSet) *diagnostic.Diagnostics

Process populates a struct's fields from environment variables and command-line flags.

The target must be a pointer to a struct. Each field can be tagged with `env`, `flag`, `usage`, and `default` to specify how the field should be populated.

If no tag is specified, the field name is used as the basis for both the environment variable (converted to SCREAMING_SNAKE_CASE) and the flag name (converted to kebab-case). This behavior can be disabled by setting the `env` or `flag` tag to `-`.

Example:

type MyConfig struct {
  MyField string `env:"MY_FIELD" flag:"my-field;hidden" usage:"my field usage" default:"my-default"`
}

Flags can be marked as hidden by appending `;hidden` to the `flag` tag.

Process supports nested structs, and basic types such as strings, integers, and booleans. Additionally, any type implementing the pflag.Value interface is supported.

Types

type Config

type Config struct {
	// Environment is the environment to target for operations / authentication (development or production). Defaults to
	// production.
	Environment environment.Environment `flag:"environment;hidden" usage:"The environment to use for authentication" default:"prod"`

	// Currency is the currency to use for prices. Defaults to USD.
	Currency string `env:"INFRACOST_CLI_CURRENCY" flag:"currency" usage:"The currency to use for prices" default:"USD"`

	// PricingEndpoint is the endpoint to use for prices. Defaults to https://pricing.api.infracost.io.
	PricingEndpoint string `` /* 157-byte string literal not displayed */

	// OrgID is the organization ID to use for authentication. Defaults to the value of the INFRACOST_ORG_ID environment variable.
	OrgID string `env:"INFRACOST_CLI_ORG_ID" flag:"org-id;hidden" usage:"The organization ID to use for authentication"`

	// ClaudePath is the path to the Claude CLI binary. Defaults to "claude" (looked up on PATH).
	ClaudePath string `env:"INFRACOST_CLI_CLAUDE_PATH" flag:"claude-path;hidden" usage:"Path to the Claude CLI binary"`

	// Dashboard contains the configuration for the dashboard API.
	Dashboard dashboard.Config

	// Events contains the configuration for the events API.
	Events events.Config

	// Auth contains the configuration for authenticating with Infracost.
	Auth auth.Config

	// Logging contains the configuration for logging.
	Logging logging.Config

	// Plugins contains the configuration for plugins.
	Plugins plugins.Config

	// Cache contains the configuration for the cache.
	Cache cache.Config
}

Config contains the configuration for the CLI.

func (*Config) RegisterEventMetadata

func (config *Config) RegisterEventMetadata(cmd *cobra.Command)

Jump to

Keyboard shortcuts

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