config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdAuthLogin   = "port auth login --org ORG_NAME"
	CmdConfigInit  = "port config --init"
	CmdConfigShow  = "port config --show"
	CmdExportCreds = "port export --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET"
	CmdImportCreds = "port import --target-client-id YOUR_CLIENT_ID --target-client-secret YOUR_CLIENT_SECRET"
)

Canonical CLI command strings referenced in user-facing auth errors.

Variables

View Source
var (
	ErrGetOrRefreshToken = errors.New("failed to get new token or refresh existing one")
	ErrNoStoredToken     = errors.New("no stored oauth token")
	ErrRefreshToken      = errors.New("failed to refresh stored oauth token")
)
View Source
var ErrOrgNotFound = errors.New("org not found in credentials")

ErrOrgNotFound is returned by GetToken when credentials exist on disk but no entry is present for the requested org. Callers can distinguish this from real I/O or parse failures using errors.Is.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the default path to the configuration file.

func EnvFileLoadingDisabled

func EnvFileLoadingDisabled() bool

EnvFileLoadingDisabled reports whether env file loading is disabled.

func MissingAuthCredentialsMessage

func MissingAuthCredentialsMessage(configPath string) string

MissingAuthCredentialsMessage is shown when no organization or credentials are configured.

func MissingCredentialsForOrgMessage

func MissingCredentialsForOrgMessage(orgType, configPath string) string

MissingCredentialsForOrgMessage is shown when partial CLI/env overrides omit client credentials.

func ShouldIgnoreGetOrRefreshTokenError

func ShouldIgnoreGetOrRefreshTokenError(err error) bool

Types

type BackendConfig

type BackendConfig struct {
	URL     string `yaml:"url"`
	Timeout int    `yaml:"timeout"`
}

BackendConfig represents configuration for the backend server (legacy, may not be used).

type Config

type Config struct {
	DefaultOrg    string                        `yaml:"default_org"`
	Organizations map[string]OrganizationConfig `yaml:"organizations"`
	Backend       BackendConfig                 `yaml:"backend"`
	Skills        SkillsConfig                  `yaml:"skills,omitempty"`
}

Config represents the main configuration structure.

func (*Config) GetOrgConfig

func (c *Config) GetOrgConfig(orgName string) (*OrganizationConfig, error)

GetOrgConfig returns the configuration for a specific organization.

func (*Config) GetOrgOrDefault

func (c *Config) GetOrgOrDefault(orgName string) string

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures the configuration is valid.

type ConfigManager

type ConfigManager struct {
	// contains filtered or unexported fields
}

ConfigManager manages configuration loading with precedence: CLI flags > env vars > config file.

func NewConfigManager

func NewConfigManager(configPath string) *ConfigManager

NewConfigManager creates a new ConfigManager.

func (*ConfigManager) AsMap

func (cm *ConfigManager) AsMap(cfg *Config) (map[string]any, error)

func (*ConfigManager) ConfigPath

func (cm *ConfigManager) ConfigPath() string

ConfigPath returns the configuration file path.

func (*ConfigManager) CreateDefaultConfig

func (cm *ConfigManager) CreateDefaultConfig() error

CreateDefaultConfig creates a default configuration file.

func (*ConfigManager) DeleteToken

func (cm *ConfigManager) DeleteToken(org string) error

func (*ConfigManager) Exists

func (cm *ConfigManager) Exists() (bool, error)

Exists returns whether the config exists or not

func (*ConfigManager) GetOrRefreshToken

func (cm *ConfigManager) GetOrRefreshToken(ctx context.Context, org string) (*auth.Token, error)

GetOrRefreshToken returns the stored token for the org, silently refreshing it when it has expired and refresh metadata is available.

func (*ConfigManager) GetToken

func (cm *ConfigManager) GetToken(org string) (*auth.Token, error)

func (*ConfigManager) Load

func (cm *ConfigManager) Load() (*Config, error)

Load loads configuration with precedence: env vars > config file > defaults.

func (*ConfigManager) LoadSkillsConfig

func (cm *ConfigManager) LoadSkillsConfig() (*SkillsConfig, error)

LoadSkillsConfig loads the skills section from the config file.

func (*ConfigManager) LoadWithDualOverrides

func (cm *ConfigManager) LoadWithDualOverrides(
	baseClientID, baseClientSecret, baseAPIURL, baseOrg string,
	targetClientID, targetClientSecret, targetAPIURL, targetOrg string,
) (*Config, *OrganizationConfig, *OrganizationConfig, error)

LoadWithDualOverrides loads configuration with dual org support. Returns config, base org config, and target org config. Precedence: CLI flags > env vars > config file > defaults.

func (*ConfigManager) LoadWithOverrides

func (cm *ConfigManager) LoadWithOverrides(clientID, clientSecret, apiURL, orgName string) (*Config, error)

LoadWithOverrides loads configuration with CLI flag overrides. Precedence: CLI flags > env vars > config file > defaults.

func (*ConfigManager) SaveSkillsConfig

func (cm *ConfigManager) SaveSkillsConfig(skills *SkillsConfig) error

SaveSkillsConfig persists the skills section into the config file, preserving all other fields.

func (*ConfigManager) StoreToken

func (cm *ConfigManager) StoreToken(org string, token *auth.Token) error

func (*ConfigManager) Write

func (cm *ConfigManager) Write(cfg *Config) error

func (*ConfigManager) WriteBytes

func (cm *ConfigManager) WriteBytes(data []byte) error

func (*ConfigManager) WriteOrgIfMissing

func (cm *ConfigManager) WriteOrgIfMissing(org string, apiUrl string) (*Config, error)

WriteOrgIfMissing adds the org to the config if its missing.

type EnvFileSource

type EnvFileSource struct {
	Path   string
	Exists bool
}

EnvFileSource describes an env file Port CLI may load.

func EnvFileSources

func EnvFileSources() []EnvFileSource

EnvFileSources returns the env files Port CLI checks, in load order.

type OrganizationConfig

type OrganizationConfig struct {
	ClientID     string `yaml:"client_id"`
	ClientSecret string `yaml:"client_secret"`
	APIURL       string `yaml:"api_url"`
}

OrganizationConfig represents configuration for a Port organization.

type SkillsConfig

type SkillsConfig struct {
	// Targets is the list of AI tool hook directories (e.g. ~/.cursor, ~/.claude).
	Targets []string `yaml:"targets"`
	// ProjectDirs is the accumulated list of project directories where
	// 'port skills init' has been run. Project-scoped skills are written
	// to every directory in this list on each sync.
	ProjectDirs        []string `yaml:"project_dirs,omitempty"`
	SelectAll          bool     `yaml:"select_all"`
	SelectAllGroups    bool     `yaml:"select_all_groups"`
	SelectAllUngrouped bool     `yaml:"select_all_ungrouped"`
	SelectedGroups     []string `yaml:"selected_groups"`
	SelectedSkills     []string `yaml:"selected_skills"`
	IncludeGroups      []string `yaml:"include_groups,omitempty"`
	ExcludeGroups      []string `yaml:"exclude_groups,omitempty"`
	TeamGroupDefaults  bool     `yaml:"team_group_defaults,omitempty"`
	LastSyncedAt       string   `yaml:"last_synced_at"`
}

SkillsConfig holds configuration for the port skills feature (hooks, selection, sync state).

func (*SkillsConfig) HasSelection

func (p *SkillsConfig) HasSelection() bool

HasSelection reports whether any skill selection has been configured.

func (*SkillsConfig) HasSkillContentSelection

func (p *SkillsConfig) HasSkillContentSelection() bool

HasSkillContentSelection reports whether group/skill sync filters are configured.

func (*SkillsConfig) UsesTeamGroupDefaults

func (p *SkillsConfig) UsesTeamGroupDefaults() bool

UsesTeamGroupDefaults reports whether grouped skills are resolved via team defaults on GET /skills.

Jump to

Keyboard shortcuts

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