config

package
v0.2.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 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

This section is empty.

Types

type Cloud

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

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

Cloud contains configuration information for Upbound Cloud.

type Config

type Config struct {
	Cloud Cloud `json:"cloud"`
}

Config is format for the up configuration file.

func (*Config) AddOrUpdateCloudProfile

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

AddOrUpdateCloudProfile adds or updates a cloud profile to the Config.

func (*Config) GetCloudProfile

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

GetCloudProfile 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) GetDefaultCloudProfile

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

GetDefaultCloudProfile gets the default cloud profile or returns an error if default is not set or default profile does not exist.

func (*Config) SetDefaultCloudProfile

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

SetDefaultCloudProfile sets the default profile for communicating with Upbound Cloud. 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 Cloud.
	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 Cloud 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.

Jump to

Keyboard shortcuts

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