Help us shape the future of Go! Take the 2026 Go Developer Survey

profile

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package profile manages named, reusable sets of ndx CLI flag defaults (identity provider issuer, client ID, scopes, callback port, Portal Backend URL, TLS verification) cached at ~/.openndx/config.json. Profiles let an operator switch between environments (local dev, staging, a partner's deployment) without retyping every flag on every command; any flag passed explicitly on the command line still overrides the active profile.

Index

Constants

View Source
const (
	ThunderIDCLIClientID  = "NDX_CLI"
	ThunderIDCallbackPort = 8765
)

ThunderIDCLIClientID and ThunderIDCallbackPort are the ndx CLI's OAuth2 client ID and redirect callback port as registered with this repo's local ThunderID instance (thunderid/bootstrap/application.yaml). ThunderID rejects any redirect URI other than the exact one registered there (http://127.0.0.1:8765/callback) - a wildcard/wrong port fails login - so `ondx login` must reject any other --callback-port when logging in as this client, rather than silently trying (and failing) against ThunderID.

View Source
const DefaultName = "local"

DefaultName is the profile ondx falls back to when no config file exists yet and none is named explicitly, pre-populated with this repo's docker-compose local-dev stack (ThunderID as IDP, Portal Backend on :8083) so `ondx login` works with zero flags out of the box.

View Source
const LocalPBResource = "http://pb.openndx.local"

LocalPBResource is the Portal Backend resource server identifier registered with this repo's local ThunderID (thunderid/bootstrap/resource.yaml). ThunderID sets an access token's `aud` to the resource requested at login, and Portal Backend only accepts tokens for this audience.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the default location for the profile config file.

func Save

func Save(path string, cfg *Config) error

Save writes cfg to path, creating parent directories as needed.

Types

type Config

type Config struct {
	CurrentProfile string             `json:"current_profile"`
	Profiles       map[string]Profile `json:"profiles"`
}

Config is the on-disk shape of ~/.openndx/config.json.

func Load

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

Load reads the config file at path. A missing file is not an error - it yields a config with just the built-in default profile, so a first-time user gets working defaults without ever running `ondx profile set`. The default profile is likewise injected whenever the file exists but doesn't define one of its own under DefaultName.

func (*Config) Get

func (c *Config) Get(name string) (Profile, error)

Get returns the named profile, or an error if it isn't defined.

type Profile

type Profile struct {
	Issuer       string `json:"issuer,omitempty"`
	AuthURL      string `json:"auth_url,omitempty"`
	TokenURL     string `json:"token_url,omitempty"`
	ClientID     string `json:"client_id,omitempty"`
	Scopes       string `json:"scopes,omitempty"`
	CallbackPort int    `json:"callback_port,omitempty"`
	// Resource is sent as `resource=` at login, so the identity provider
	// issues the token for Portal Backend's audience.
	Resource string `json:"resource,omitempty"`
	PBURL    string `json:"pb_url,omitempty"`
	Insecure bool   `json:"insecure,omitempty"`
}

Profile is one named set of flag defaults. Every field is optional - callers use it purely to seed a flag's default value, so a zero value simply falls through to whatever the caller does when a flag is unset.

Jump to

Keyboard shortcuts

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