config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDir  = ".up"
	ConfigFile = "config.json"
)

Location of up config file.

Variables

This section is empty.

Functions

func Extract added in v0.5.0

func Extract() (*Config, Source, error)

Extract performs extraction of configuration from the default source, which is the ~/.up/config.json file on the local filesystem.

Types

type Config

type Config struct {
	Upbound Upbound `json:"upbound"`
}

Config is format for the up configuration file.

func (*Config) AddOrUpdateUpboundProfile added in v0.5.0

func (c *Config) AddOrUpdateUpboundProfile(name string, new Profile) error

AddOrUpdateUpboundProfile adds or updates an Upbound profile to the Config.

func (*Config) GetDefaultUpboundProfile added in v0.5.0

func (c *Config) GetDefaultUpboundProfile() (string, Profile, error)

GetDefaultUpboundProfile gets the default Upbound profile or returns an error if default is not set or default profile does not exist.

func (*Config) GetUpboundProfile added in v0.5.0

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

GetUpboundProfile gets a profile with a given identifier. If a profile does not exist for the given identifier an error will be returned. Multiple profiles should never exist for the same identifier, but in the case that they do, the first will be returned.

func (*Config) SetDefaultUpboundProfile added in v0.5.0

func (c *Config) SetDefaultUpboundProfile(name string) error

SetDefaultUpboundProfile sets the default profile for communicating with Upbound. Setting a default profile that does not exist will return an error.

type FSSource

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

FSSource provides a filesystem source for interacting with a Config.

func NewFSSource

func NewFSSource(modifiers ...FSSourceModifier) (*FSSource, error)

NewFSSource constructs a new FSSource.

func (*FSSource) GetConfig

func (src *FSSource) GetConfig() (*Config, error)

GetConfig fetches the config from a filesystem.

func (*FSSource) UpdateConfig

func (src *FSSource) UpdateConfig(c *Config) error

UpdateConfig updates the Config in the filesystem.

type FSSourceModifier

type FSSourceModifier func(*FSSource)

FSSourceModifier modifies an FSSource.

type HomeDirFn

type HomeDirFn func() (string, error)

HomeDirFn indicates the location of a user's home directory.

type Profile

type Profile struct {
	// ID is either a username, email, or token.
	ID string `json:"id"`

	// Type is the type of the profile.
	Type ProfileType `json:"type"`

	// Session is a session token used to authenticate to Upbound.
	Session string `json:"session,omitempty"`

	// Account is the default account to use when this profile is selected.
	Account string `json:"account,omitempty"`
}

A Profile is a set of credentials

type ProfileType

type ProfileType string

ProfileType is a type of Upbound profile.

const (
	UserProfileType  ProfileType = "user"
	TokenProfileType ProfileType = "token"
)

Types of profiles.

type Source

type Source interface {
	GetConfig() (*Config, error)
	UpdateConfig(*Config) error
}

Source is a source for interacting with a Config.

type Upbound added in v0.5.0

type Upbound struct {
	// Default indicates the default profile.
	Default string `json:"default"`

	// Profiles contain sets of credentials for communicating with Upbound. Key
	// is name of the profile.
	Profiles map[string]Profile `json:"profiles,omitempty"`
}

Upbound contains configuration information for Upbound.

Jump to

Keyboard shortcuts

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