conf

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

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

This section is empty.

Variables

This section is empty.

Functions

func GetLocation

func GetLocation() (string, error)

GetLocation gets the location and sets it to default it is unset.

func SetDefaultLocation

func SetDefaultLocation() error

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

func SetLocation

func SetLocation(file string) error

SetLocation sets the location of the config file.

func Write

func Write() error

Write writes the conf variable to disk.

func WriteNerdToken

func WriteNerdToken(token string) error

WriteNerdToken sets the nerd token and calls Write() to write to disk.

Types

type AuthConfig

type AuthConfig struct {
	APIEndpoint string `json:"api_endpoint"`
	PublicKey   string `json:"public_key"`
}

AuthConfig contains config details with respect to authentication.

type Config

type Config struct {
	Auth            AuthConfig `json:"auth"`
	EnableLogging   bool       `json:"enable_logging"`
	CurrentProject  string     `json:"current_project"`
	NerdToken       string     `json:"nerd_token"`
	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 Read

func Read() (*Config, error)

Read reads the config either from memory or from disk for the first time.

Jump to

Keyboard shortcuts

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