config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONFIG_DIR_NAME = "mi"
	CREDS_FILE      = "creds.json"
)
View Source
const (
	CONFIG_FILE = ".miconfig.yaml"
)

Variables

This section is empty.

Functions

func GetServiceURL

func GetServiceURL() string

GetServiceURL returns the right service url based on the running environment. For percise control, change the env APP_ENV.

func SaveCredentials

func SaveCredentials(c *Credentials) error

SaveCredentials saves the given token Credentials in the config folder "$HOME/.config/mi" If APP_ENV is "dev", then it will be in the "$CWD/tmp/.config/mi".

Types

type Configuration

type Configuration struct {
	BentoId        string `mapstructure:"bento_id" yaml:"bento_id"`
	PrivateKeyPath string `mapstructure:"private_key_path" yaml:"private_key_path"`
}

Configuration represents the bento configuration that is used to perform any bento related services, except preparing a new bento. When preparing a new bento, a new configuration will be written to the cwd.

func LoadConfiguration

func LoadConfiguration() (*Configuration, error)

LoadConfiguration loads the app configuration in the cwd.

func NewConfiguration

func NewConfiguration(bentoId, pkPath string) Configuration

NewConfiguration creates a new Configuration.

func (*Configuration) Save

func (c *Configuration) Save(path string) error

Save the current Configuration to a file.

type Credentials

type Credentials struct {
	Email         string `json:"email,omitempty"`
	AccessToken   string `json:"access_token"`
	RefreshToken  string `json:"refresh_token"`
	LocalFilePath string
}

Credentials represent the json that is saved in the config folder for tokens.

func LoadCredentials

func LoadCredentials() (*Credentials, error)

LoadCredentials loads up the Credentials file in the config folder if exists, otherwise it returns an error.

func (*Credentials) Remove

func (c *Credentials) Remove() error

/ Remove a credential file from the default path.

Jump to

Keyboard shortcuts

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