Documentation
¶
Index ¶
- Constants
- func AutoRefreshToken(cfg *ConfigFile) (string, error)
- func BuildCommands(spec *Spec) []*cli.Command
- func ConfigDir() string
- func ConfigPath() string
- func ExchangeAPIKey(cfg *ConfigFile, configPath string) (string, error)
- func FormatOutput(data []byte, format string) error
- func GetAuthToken(cfg *ConfigFile) string
- func HasAPIKeyConfig(cfg *ConfigFile) bool
- func HasOIDCConfig(cfg *ConfigFile) bool
- func InitCommand() *cli.Command
- func LoginCommand() *cli.Command
- func NewApp(specData []byte) (*cli.App, error)
- func ReadBodyInput(data, dataFile string) ([]byte, error)
- func ResolveToken(token, tokenCommand string) (string, error)
- func SaveConfig(cfg *ConfigFile) error
- func SaveConfigToPath(cfg *ConfigFile, path string) error
- func SetConfigPath(path string)
- type APIError
- type Client
- type Components
- type ConfigAPI
- type ConfigAPIKey
- type ConfigAuth
- type ConfigFile
- type ConfigOIDC
- type MediaType
- type Operation
- type Parameter
- type PathItem
- type RequestBody
- type Schema
- type SchemaType
- type Server
- type Spec
- type SpecInfo
- type Tag
- type TokenResponse
Constants ¶
const SampleConfig = `` /* 900-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func AutoRefreshToken ¶
func AutoRefreshToken(cfg *ConfigFile) (string, error)
AutoRefreshToken attempts to refresh the OIDC token if it is near expiry.
func BuildCommands ¶
BuildCommands converts parsed OpenAPI operations into a cli.Command tree grouped by tag.
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the directory containing the active config file.
func ExchangeAPIKey ¶
func ExchangeAPIKey(cfg *ConfigFile, configPath string) (string, error)
ExchangeAPIKey exchanges an NGC API key for a bearer token, updates the config, and saves it. Returns the new token.
func FormatOutput ¶
func GetAuthToken ¶
func GetAuthToken(cfg *ConfigFile) string
GetAuthToken returns the best available bearer token from the config. Priority: auth.token > auth.oidc.token > auth.api_key.token
func HasAPIKeyConfig ¶
func HasAPIKeyConfig(cfg *ConfigFile) bool
HasAPIKeyConfig returns true when NGC API key settings are present.
func HasOIDCConfig ¶
func HasOIDCConfig(cfg *ConfigFile) bool
HasOIDCConfig returns true when OIDC credentials are present in the config.
func InitCommand ¶
InitCommand returns the 'init' CLI command that generates a sample config.
func ReadBodyInput ¶
ReadBodyInput reads request body from --data flag or --data-file flag. Use "--data-file -" to read from stdin.
func ResolveToken ¶
ResolveToken returns the token or executes the token command.
func SaveConfig ¶
func SaveConfig(cfg *ConfigFile) error
SaveConfig writes the config back to ConfigPath(), preserving unknown keys.
func SaveConfigToPath ¶
func SaveConfigToPath(cfg *ConfigFile, path string) error
SaveConfigToPath writes the config to a specific path, preserving any unknown keys the user may have manually added.
func SetConfigPath ¶
func SetConfigPath(path string)
SetConfigPath overrides the default config file path for the process lifetime.
Types ¶
type Client ¶
type Components ¶
type ConfigAPIKey ¶
type ConfigAuth ¶
type ConfigAuth struct {
Token string `yaml:"token,omitempty"`
OIDC *ConfigOIDC `yaml:"oidc,omitempty"`
APIKey *ConfigAPIKey `yaml:"api_key,omitempty"`
}
type ConfigFile ¶
type ConfigFile struct {
API ConfigAPI `yaml:"api"`
Auth ConfigAuth `yaml:"auth"`
}
ConfigFile mirrors the ~/.carbide/config.yaml structure.
func LoadConfig ¶
func LoadConfig() (*ConfigFile, error)
LoadConfig reads config from the active path (override or default).
func LoadConfigFromPath ¶
func LoadConfigFromPath(path string) (*ConfigFile, error)
LoadConfigFromPath reads a config file at a specific path.
type ConfigOIDC ¶
type ConfigOIDC struct {
TokenURL string `yaml:"token_url,omitempty"`
ClientID string `yaml:"client_id,omitempty"`
ClientSecret string `yaml:"client_secret,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Token string `yaml:"token,omitempty"`
RefreshToken string `yaml:"refresh_token,omitempty"`
ExpiresAt string `yaml:"expires_at,omitempty"`
}
type RequestBody ¶
type Schema ¶
type Schema struct {
Ref string `yaml:"$ref"`
Type SchemaType `yaml:"type"`
Format string `yaml:"format"`
Enum []string `yaml:"enum"`
Properties map[string]*Schema `yaml:"properties"`
Required []string `yaml:"required"`
Items *Schema `yaml:"items"`
MinLength *int `yaml:"minLength"`
MaxLength *int `yaml:"maxLength"`
Minimum *int `yaml:"minimum"`
Maximum *int `yaml:"maximum"`
Default interface{} `yaml:"default"`
}
type SchemaType ¶
type SchemaType string
SchemaType handles OpenAPI 3.1 type fields that can be a string or a list of strings.
func (*SchemaType) UnmarshalYAML ¶
func (t *SchemaType) UnmarshalYAML(value *yaml.Node) error
type Spec ¶
type Spec struct {
Info SpecInfo `yaml:"info"`
Servers []Server `yaml:"servers"`
Tags []Tag `yaml:"tags"`
Paths map[string]PathItem `yaml:"paths"`
Components Components `yaml:"components"`
}