config

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package config loads the Apple Business API settings from the gitignored .env.

Index

Constants

View Source
const (
	DefaultScope    = "business.api"
	DefaultTokenURL = "https://account.apple.com/auth/oauth2/token"
	DefaultTokenAud = "https://account.apple.com/auth/oauth2/v2/token"
	DefaultAPIBase  = "https://api-business.apple.com/v1/"
)

Default Apple Business endpoints/scope (used when unset in a context/.env/env).

Variables

This section is empty.

Functions

func ContextsPath

func ContextsPath() string

ContextsPath is ~/.abctl/contexts.yaml, overridable via $ABCTL_CONTEXTS (tests/CI).

Types

type Config

type Config struct {
	ClientID string
	KeyPath  string // absolute path to the unencrypted EC private key (PKCS#8 or SEC1)
	Scope    string
	TokenURL string
	TokenAud string
	APIBase  string
	EnvDir   string // base dir the gitops tree + secrets/ paths resolve against
}

Config is the resolved Apple Business API configuration.

func Load

func Load() (*Config, error)

Load resolves config with no explicit context selector.

func Resolve

func Resolve(explicitContext string) (*Config, error)

Resolve resolves the Apple Business config. Precedence: (1) a named connection context — the explicit selector, else $ABCTL_CONTEXT, else the active context in ~/.abctl/contexts.yaml; then (2) $ABCTL_ENV / the nearest .env walking up from the cwd; then (3) the process environment (AB_* — the 12-factor CI path).

type Context

type Context struct {
	ClientID string `yaml:"client_id" json:"client_id"`
	KeyPath  string `yaml:"key" json:"key"` // path to the EC private key (resolved relative to the file if not absolute)
	APIBase  string `yaml:"api_base,omitempty" json:"api_base,omitempty"`
	Scope    string `yaml:"scope,omitempty" json:"scope,omitempty"`
	TokenURL string `yaml:"token_url,omitempty" json:"token_url,omitempty"`
	TokenAud string `yaml:"token_aud,omitempty" json:"token_aud,omitempty"`
}

Context is one named Apple Business connection (client id + key + endpoints), stored in ~/.abctl/contexts.yaml so an operator can switch between organizations/tenants. The json tags mirror the yaml tags so `context get -o json|yaml` emits lowercase snake_case (client_id/key/api_base/…) consistent with every other payload — not the Go field names. Only the key PATH is ever surfaced, never key material.

type Contexts

type Contexts struct {
	Current  string             `yaml:"current,omitempty" json:"current,omitempty"`
	Contexts map[string]Context `yaml:"contexts" json:"contexts"`
}

Contexts is the on-disk store: a set of named contexts + the active one.

func LoadContexts

func LoadContexts() (*Contexts, error)

LoadContexts reads the context store; a missing file yields an empty store.

func (*Contexts) Names

func (s *Contexts) Names() []string

Names returns the context names, sorted.

func (*Contexts) Save

func (s *Contexts) Save() error

Save writes the context store (0600, creating ~/.abctl).

Jump to

Keyboard shortcuts

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