conf

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 10 Imported by: 4

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

View Source
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

func GetDefaultConfigLocation() (string, error)

GetDefaultConfigLocation sets the location to ~/.nerd/config.json

func GetDefaultSessionLocation added in v0.4.12

func GetDefaultSessionLocation() (string, error)

GetDefaultSessionLocation sets the location to ~/.nerd/session.json

Types

type AuthConfig

type AuthConfig struct {
	APIEndpoint    string `json:"api_endpoint"`
	PublicKey      string `json:"public_key"`
	SecureClientID string `json:"secure_client_id"`
	// to remove
	SecureClientSecret string `json:"secure_client_secret"`
	OAuthSuccessURL    string `json:"oauth_success_url"`
	OAuthLocalServer   string `json:"oauth_localserver"`
	IDPIssuerURL       string `json:"idp_issuer_url"`
}

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.

func DevDefaults added in v1.0.0

func DevDefaults(endpoint string) *Config

DevDefaults provides the default for the dev environment when the config file misses certain fields.

func FromJSON added in v0.4.12

func FromJSON(in string) (*Config, error)

FromJSON returns a Config object from a JSON string

func Read

func Read(location string) (*Config, error)

Read reads the config file

func StagingDefaults added in v1.0.0

func StagingDefaults() *Config

StagingDefaults provides the default for the staging environment 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"`
	IDToken      string    `json:"id_token"`
	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

func NewSession(loc string) *Session

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) WriteJWT added in v0.4.12

func (s *Session) WriteJWT(jwt, refreshToken string) error

WriteJWT writes the jwt object to the session file

func (*Session) WriteOAuth added in v0.4.12

func (s *Session) WriteOAuth(accessToken, refreshToken, idToken string, expiration time.Time, scope, tokenType string) error

WriteOAuth writes the oauth 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, idToken string, expiration time.Time, scope, tokenType 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

Jump to

Keyboard shortcuts

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