config

package
v1.260716.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CredentialKeyTypeTeam is the default App Store Connect API key type.
	CredentialKeyTypeTeam = "team"
	// CredentialKeyTypeIndividual signs JWTs with sub:"user" and no issuer.
	CredentialKeyTypeIndividual = "individual"
)

Variables

View Source
var ErrInvalidConfig = errors.New("invalid configuration")

ErrInvalidConfig is returned when config values fail validation.

View Source
var ErrInvalidPath = errors.New("invalid config path")

ErrInvalidPath is returned when the config path is invalid.

View Source
var ErrNotFound = fmt.Errorf("configuration not found")

ErrNotFound is returned when the config file doesn't exist

Functions

func GlobalPath

func GlobalPath() (string, error)

GlobalPath returns the global configuration file path.

func IsIndividualCredentialKeyType added in v1.260613.0

func IsIndividualCredentialKeyType(value string) bool

IsIndividualCredentialKeyType reports whether value names an individual key.

func IsValidCredentialKeyType added in v1.260613.0

func IsValidCredentialKeyType(value string) bool

IsValidCredentialKeyType reports whether value names a supported key type.

func LocalPath

func LocalPath() (string, error)

LocalPath returns the local configuration file path.

func NormalizeCredentialKeyType added in v1.260613.0

func NormalizeCredentialKeyType(value string) string

NormalizeCredentialKeyType returns the canonical credential key type.

func Path

func Path() (string, error)

Path returns the active configuration file path.

func Remove

func Remove() error

Remove removes the config file

func RemoveAt

func RemoveAt(path string) error

RemoveAt removes the config file at the provided path.

func Save

func Save(cfg *Config) error

Save saves the configuration to the config file

func SaveAt

func SaveAt(path string, cfg *Config) error

SaveAt saves the configuration to the provided path.

Types

type AdsConfig added in v1.260601.0

type AdsConfig struct {
	DefaultKeyName   string                `json:"default_key_name,omitempty"`
	Keys             []AdsCredential       `json:"keys,omitempty"`
	KeychainMetadata []AdsKeychainMetadata `json:"keychain_metadata,omitempty"`
	OrgID            string                `json:"org_id,omitempty"`
}

AdsConfig stores Apple Ads-specific auth configuration.

type AdsCredential added in v1.260601.0

type AdsCredential struct {
	Name           string `json:"name"`
	ClientID       string `json:"client_id"`
	TeamID         string `json:"team_id"`
	KeyID          string `json:"key_id"`
	PrivateKeyPath string `json:"private_key_path"`
	OrgID          string `json:"org_id,omitempty"`
}

AdsCredential stores a named Apple Ads API credential in config.json.

type AdsKeychainMetadata added in v1.260601.0

type AdsKeychainMetadata struct {
	Name       string `json:"name"`
	ClientID   string `json:"client_id"`
	TeamID     string `json:"team_id"`
	KeyID      string `json:"key_id"`
	OrgID      string `json:"org_id,omitempty"`
	ModifiedAt string `json:"modified_at,omitempty"`
}

AdsKeychainMetadata stores non-secret metadata for keychain-backed Apple Ads credentials.

type Config

type Config struct {
	KeyID            string             `json:"key_id"`
	IssuerID         string             `json:"issuer_id"`
	PrivateKeyPath   string             `json:"private_key_path"`
	PrivateKeyPEM    string             `json:"-"`
	KeyType          string             `json:"key_type,omitempty"`
	DefaultKeyName   string             `json:"default_key_name"`
	Keys             []Credential       `json:"keys,omitempty"`
	KeychainMetadata []KeychainMetadata `json:"keychain_metadata,omitempty"`
	AppID            string             `json:"app_id"`

	VendorNumber          string `json:"vendor_number"`
	AnalyticsVendorNumber string `json:"analytics_vendor_number"`
	SkillsCheckedAt       string `json:"skills_checked_at,omitempty"`

	Timeout              DurationValue `json:"timeout"`
	TimeoutSeconds       DurationValue `json:"timeout_seconds"`
	UploadTimeout        DurationValue `json:"upload_timeout"`
	UploadTimeoutSeconds DurationValue `json:"upload_timeout_seconds"`
	MaxRetries           string        `json:"max_retries"`
	BaseDelay            string        `json:"base_delay"`
	MaxDelay             string        `json:"max_delay"`
	RetryLog             string        `json:"retry_log"`
	Debug                string        `json:"debug"`

	Ads      AdsConfig      `json:"ads,omitempty"`
	StoreKit StoreKitConfig `json:"storekit,omitempty"`
}

Config holds the application configuration

func Load

func Load() (*Config, error)

Load loads the configuration from the config file

func LoadAt

func LoadAt(path string) (*Config, error)

LoadAt loads the configuration from the provided path.

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures configuration values are parseable and within safe bounds.

type Credential

type Credential struct {
	Name           string `json:"name"`
	KeyID          string `json:"key_id"`
	IssuerID       string `json:"issuer_id"`
	PrivateKeyPath string `json:"private_key_path"`
	KeyType        string `json:"key_type,omitempty"`
}

Credential stores a named API credential in config.json.

type DurationValue

type DurationValue struct {
	Duration time.Duration
	Raw      string
}

DurationValue stores a duration with its raw string representation. It marshals to/from JSON as a string to preserve config compatibility.

func ParseDurationValue

func ParseDurationValue(raw string) (DurationValue, error)

ParseDurationValue parses a duration string or seconds value into a DurationValue.

func (DurationValue) MarshalJSON

func (d DurationValue) MarshalJSON() ([]byte, error)

MarshalJSON stores the raw string when available, preserving the config format.

func (DurationValue) String

func (d DurationValue) String() string

String returns the raw string when available, falling back to the duration value.

func (*DurationValue) UnmarshalJSON

func (d *DurationValue) UnmarshalJSON(data []byte) error

UnmarshalJSON parses duration strings or seconds values from JSON.

func (DurationValue) Value

func (d DurationValue) Value() (time.Duration, bool)

Value returns the parsed duration if it's positive.

type KeychainMetadata

type KeychainMetadata struct {
	Name       string `json:"name"`
	KeyID      string `json:"key_id"`
	IssuerID   string `json:"issuer_id"`
	KeyType    string `json:"key_type,omitempty"`
	ModifiedAt string `json:"modified_at,omitempty"`
}

KeychainMetadata stores non-secret metadata for keychain-backed credentials.

type StoreKitConfig added in v1.260622.0

type StoreKitConfig struct {
	DefaultKeyName string               `json:"default_key_name,omitempty"`
	Keys           []StoreKitCredential `json:"keys,omitempty"`
}

StoreKitConfig stores StoreKit-specific authentication configuration.

type StoreKitCredential added in v1.260622.0

type StoreKitCredential struct {
	Name           string `json:"name"`
	KeyID          string `json:"key_id"`
	IssuerID       string `json:"issuer_id"`
	PrivateKeyPath string `json:"private_key_path"`
	BundleID       string `json:"bundle_id"`
}

StoreKitCredential stores a named In-App Purchase API credential. Private key material stays in the keychain; config-backed credentials store only a path to the key file.

Jump to

Keyboard shortcuts

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