config

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeychainStore keychain.Store

KeychainStore allows overriding the keychain implementation for testing. When nil, the real system keychain is used.

Functions

func ConfigPath

func ConfigPath() string

ConfigPath returns the path to the config file using XDG conventions.

func GetKeychainStore

func GetKeychainStore() keychain.Store

GetKeychainStore returns the configured keychain store, falling back to the real system keychain when no override has been set via KeychainStore.

func ResolveSecret

func ResolveSecret(value string) (string, error)

ResolveSecret resolves a secret value that must use a recognized prefix:

  • "env:VAR_NAME" — reads the value from environment variable VAR_NAME
  • "file:/path" — reads the value from the file at /path
  • "keychain:ref" — reads the value from the system keychain

Empty strings are returned as-is. Any other value is rejected.

func Save

func Save(cfg *Config) error

Save writes the config to disk with 0600 permissions, creating parent directories as needed.

Types

type Config

type Config struct {
	DefaultProfile string             `yaml:"default-profile"`
	DefaultOutput  string             `yaml:"default-output,omitempty"`
	Profiles       map[string]Profile `yaml:"profiles"`
}

Config represents the CLI configuration

func Load

func Load() (*Config, error)

Load reads the config from disk. If the file doesn't exist, returns an empty config (not an error). Automatically migrates from the legacy ~/.config/jamfpro-cli/ location if found.

type Profile

type Profile struct {
	Product             string         `yaml:"product,omitempty"` // "pro" (default), "protect", or "school"
	URL                 string         `yaml:"url"`
	AuthMethod          string         `yaml:"auth-method"` // token, oauth2, platform, apikey
	Token               string         `yaml:"token,omitempty"`
	ClientID            string         `yaml:"client-id,omitempty"`
	ClientSecret        string         `yaml:"client-secret,omitempty"`
	TenantID            string         `yaml:"tenant-id,omitempty"`    // platform auth
	PlatformURL         string         `yaml:"platform-url,omitempty"` // school: separate gateway URL for Platform API
	NetworkID           string         `yaml:"network-id,omitempty"`   // school only
	APIKey              string         `yaml:"api-key,omitempty"`      // school only
	DestructiveCooldown *time.Duration `yaml:"destructive-cooldown,omitempty"`
}

Profile represents a server profile for a Jamf product.

func GetProfile

func GetProfile(cfg *Config, name string) (*Profile, string, error)

GetProfile returns the named profile, or the default profile if name is empty. Returns the profile and its name, or an error if not found.

Jump to

Keyboard shortcuts

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