config

package
v0.45.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package config provides access to fsoc configuration, both to obtain the current configuration and to incrementally or fully modify the configuration. The fsoc configuration has two dimension: a config file and a context within the config file. Each config file contains one or more contexts plus a setting indicating which of them is the current one.

Index

Constants

View Source
const (
	DefaultConfigFile = "~/.fsoc"
	DefaultContext    = "default"
	AppdPid           = "appd-pid"
	AppdTid           = "appd-tid"
	AppdPty           = "appd-pty"
)
View Source
const (
	// No authentication (used in local/dev environments)
	AuthMethodNone = "none"
	// OAuth using the same user credentials as in a browser
	AuthMethodOAuth = "oauth"
	// Use JWT token directly
	AuthMethodJWT = "jwt"
	// Use a service principal
	AuthMethodServicePrincipal = "service-principal"
	// Use an agent principal
	AuthMethodAgentPrincipal = "agent-principal"
	// Use Session Manager (experimental)
	AuthMethodSessionManager = "session-manager"
	// Use for local setup
	AuthMethodLocal = "local"
)

Supported authentication methods

View Source
const (
	AnnotationForConfigBypass = "config/bypass-check"
)

Variables

This section is empty.

Functions

func GetAuthMethodsStringList

func GetAuthMethodsStringList() []string

GetAuthMethodsStringList returns the list of authentication methods as strings (for join, etc.)

func GetCurrentProfileName

func GetCurrentProfileName() string

GetCurrentProfileName returns the profile name that is used to select the context. This is mostly the same as returned by GetCurrentContext().Name, except for the case when a new profile is being created.

func ListContexts added in v0.33.0

func ListContexts(prefix string) []string

ListContexts returns a list of context names which begin with `prefix`, used for the command line autocompletion

func NewSubCmd

func NewSubCmd() *cobra.Command

Package registration function for the config root command

func ReplaceCurrentContext

func ReplaceCurrentContext(ctx *Context)

ReplaceCurrentContext updates the all values within the current context. It accepts a Context structure, which may or may not be returned by GetCurrentContext(). Note that the Context.Name must match the current context.

func SetSelectedProfile

func SetSelectedProfile(name string)

SetSelectedProfile sets the name of the profile that should be used instead of the config file's current profile value. This function should not be used outside of the fsoc root pre-command.

Types

type Context

type Context struct {
	Name             string           `json:"name" yaml:"name"`
	AuthMethod       string           `json:"auth_method,omitempty" yaml:"auth_method,omitempty" mapstructure:"auth_method"`
	Server           string           `json:"server,omitempty" yaml:"server,omitempty"` // deprecated
	URL              string           `json:"url,omitempty" yaml:"url,omitempty"`
	Tenant           string           `json:"tenant,omitempty" yaml:"tenant,omitempty"`
	User             string           `json:"user,omitempty" yaml:"user,omitempty"`
	Token            string           `json:"token,omitempty" yaml:"token,omitempty"` // access token
	RefreshToken     string           `json:"refresh_token,omitempty" yaml:"refresh_token,omitempty" mapstructure:"refresh_token"`
	CsvFile          string           `json:"csv_file,omitempty" yaml:"csv_file,omitempty"`
	SecretFile       string           `json:"secret_file,omitempty" yaml:"secret_file,omitempty" mapstructure:"secret_file"`
	LocalAuthOptions LocalAuthOptions `json:"auth-options,omitempty" yaml:"auth-options,omitempty" mapstructure:"auth-options"`
}

Struct Context defines a full configuration context (aka access profile). The Name field contains the name of the context (which is unique within the config file); the remaining fields define the access profile.

func GetCurrentContext

func GetCurrentContext() *Context

GetCurrentContext returns the context (access profile) selected by the user for the particular invocation of the fsoc utility. Returns nil if no current context is defined (and the only command allowed in this state is `config set`, which will create the context). Note that GetCurrentContext returns a pointer into the config file's overall configuration; it can be modified and then updated using ReplaceCurrentContext().

type LocalAuthOptions added in v0.29.0

type LocalAuthOptions struct {
	AppdPty string `json:"appd-pty" yaml:"appd-pty" mapstructure:"appd-pty"`
	AppdTid string `json:"appd-tid" yaml:"appd-tid" mapstructure:"appd-tid"`
	AppdPid string `json:"appd-pid" yaml:"appd-pid" mapstructure:"appd-pid"`
}

func (*LocalAuthOptions) AddHeaders added in v0.29.0

func (opt *LocalAuthOptions) AddHeaders(req *http.Request)

Jump to

Keyboard shortcuts

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