config

package
Version: v0.0.0-...-854ad97 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: BSD-3-Clause Imports: 11 Imported by: 3

Documentation

Overview

Package config handles reading of the user configuration for the client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddServerConf

func AddServerConf(alias string, newcfg ServerCfg) error

AddServerConf writes a new server configuration into the user config file.

func Path

func Path(create bool) (string, error)

Path returns the configuration path where configuration files should be stored. If the GIN_CONFIG_DIR environment variable is set, its value is returned, otherwise the platform default is used. If create is true and the directory does not exist, the full path is created.

func RmServerConf

func RmServerConf(alias string)

RmServerConf removes a server configuration from the user config file.

func SetConfig

func SetConfig(key string, value interface{}) error

SetConfig appends a key-value to the configuration file. A useful utility function that loads the configuration only from the file, adds the new key-value pair, and saves it back, without loading the built-in defaults. On successful write, the read cache is invalidated.

func SetDefaultServer

func SetDefaultServer(alias string)

SetDefaultServer writes the given name to the config file to server as the default server for web calls. An error is returned if the name doesn't exist in the current configuration.

Types

type AnnexCfg

type AnnexCfg struct {
	Exclude []string
	MinSize string
}

AnnexCfg holds the configuration options for Git Annex (filtering rules).

type BinCfg

type BinCfg struct {
	Git          string
	GitAnnex     string
	GitAnnexPath string
	SSH          string
}

BinCfg holds the paths to the external binaries that the client depends on.

type GinCliCfg

type GinCliCfg struct {
	Servers       map[string]ServerCfg
	DefaultServer string
	Bin           BinCfg
	Annex         AnnexCfg
}

GinCliCfg holds the client configuration values.

func Read

func Read() GinCliCfg

Read loads in the configuration from the config file(s), merges any defined values into the default configuration, and returns a populated GinConfiguration struct. The configuration is cached. Subsequent reads reuse the already loaded configuration.

type GitCfg

type GitCfg struct {
	User    string
	Host    string
	Port    uint16
	HostKey string
}

GitCfg is the configuration for the git server.

func ParseGitString

func ParseGitString(gitstring string) (GitCfg, error)

ParseGitString takes a string which contains all information about a server's git configuration (e.g., git@gin.g-node.org:22) and returns a GitCfg struct.

func (GitCfg) AddressStr

func (c GitCfg) AddressStr() string

AddressStr constructs a full address string from the configuration. The string has the format ssh://User@Host:Port (e.g., ssh://git@gin.g-node.org:22)

type ServerCfg

type ServerCfg struct {
	Web WebCfg
	Git GitCfg
}

ServerCfg holds the information required for GIN servers (web and git).

type WebCfg

type WebCfg struct {
	Protocol string
	Host     string
	Port     uint16
}

WebCfg is the configuration for the web server.

func ParseWebString

func ParseWebString(webstring string) (WebCfg, error)

ParseWebString takes a string which contains all information about a server's web configuration (e.g., https://gin.g-node.org:443) and returns a WebCfg struct.

func (WebCfg) AddressStr

func (c WebCfg) AddressStr() string

AddressStr constructs a full address string from the configuration. The string has the format Scheme://Host:Port (e.g., https://gin.g-node.org:443)

Source Files

Jump to

Keyboard shortcuts

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