Documentation
¶
Overview ¶
Package conf gives the CLI access to the nerd config file. By default this config file is ~/.nerd/config.json, but the location can be changed using SetLocation().
All read and write operation to the config file should go through the Read() and Write() functions. This way we can keep an in-memory representation of the config (in the global conf variable) for fast read.
Index ¶
Constants ¶
const (
//DefaultAWSRegion can be used to set the project region
DefaultAWSRegion = "eu-west-1"
)
Variables ¶
This section is empty.
Functions ¶
func GetDefaultConfigLocation ¶ added in v0.4.12
GetDefaultConfigLocation sets the location to ~/.nerd/config.json
func GetDefaultSessionLocation ¶ added in v0.4.12
GetDefaultSessionLocation sets the location to ~/.nerd/session.json
Types ¶
type AuthConfig ¶
type AuthConfig struct { APIEndpoint string `json:"api_endpoint"` PublicKey string `json:"public_key"` ClientID string `json:"client_id"` OAuthSuccessURL string `json:"oauth_success_url"` OAuthLocalServer string `json:"oauth_localserver"` }
AuthConfig contains config details with respect to the authentication server.
type Config ¶
type Config struct { Auth AuthConfig `json:"auth"` Logging LoggingConfig `json:"logging"` NerdAPIEndpoint string `json:"nerd_api_endpoint"` }
Config is the structure that describes how the config file looks.
func Defaults ¶
func Defaults() *Config
Defaults provides the default for when the config file misses certain fields.
type JWT ¶ added in v0.4.12
type JWT struct { Token string `json:"token,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` }
JWT contains JWT credentials
type LoggingConfig ¶ added in v0.5.0
type LoggingConfig struct { Enabled bool `json:"enabled"` FileLocation string `json:"file_location"` }
LoggingConfig contains config details about local logging of command output
type OAuth ¶ added in v0.4.12
type OAuth struct { AccessToken string `json:"access_token,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` Expiration time.Time `json:"expiration,omitempty"` Scope string `json:"scope,omitempty"` TokenType string `json:"token_type,omitempty"` }
OAuth contains oauth credentials
type Project ¶ added in v0.4.12
type Project struct { Name string `json:"name,omitempty"` AWSRegion string `json:"aws_region,omitempty"` }
Project contains details of the current working project.
type Session ¶ added in v0.4.12
type Session struct {
// contains filtered or unexported fields
}
Session is an object capable of reading and writing the session file
func NewSession ¶ added in v0.4.12
NewSession creates a new Session
func (*Session) Read ¶ added in v0.4.12
func (s *Session) Read() (*SessionSnapshot, error)
Read returns a snapshot of the session file
func (*Session) WriteOAuth ¶ added in v0.4.12
func (s *Session) WriteOAuth(accessToken, refreshToken string, expiration time.Time, scope, tokenType string) error
WriteOAuth writes the oauth object to the session file
func (*Session) WriteProject ¶ added in v0.4.12
WriteProject writes the project object to the session file
type SessionInterface ¶ added in v0.4.12
type SessionInterface interface { Read() (*SessionSnapshot, error) WriteJWT(jwt, refreshToken string) error WriteOAuth(accessToken, refreshToken string, expiration time.Time, scope, tokenType string) error WriteProject(project, awsRegion string) error }
SessionInterface is the interface of Session
type SessionSnapshot ¶ added in v0.4.12
type SessionSnapshot struct { OAuth OAuth `json:"oauth,omitempty"` JWT JWT `json:"jwt,omitempty"` Project Project `json:"project,omitempty"` }
SessionSnapshot is a snapshot of the session file
func (*SessionSnapshot) RequireProjectID ¶ added in v0.5.2
func (ss *SessionSnapshot) RequireProjectID() (name string, err error)
RequireProjectID returns the current project name from the session snapshot or error with ErrProjectIDNotSet