config

package
v0.0.0-...-575b356 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

config

A package for initializing and manipulating connector (v2) configuration.

This package is heavily inspired by the AWS "default credential provider chain" concept, as well as Terraform's environment variable mechanism for defining variables.

Variables are sourced using a "standard variable chain", where any configuration mentioned in a configuration file is considered the "base configuration" and any variables defined in the environment override the base configuration.

Usage
c, err := config.GetConfiguration(ctx)
// ... handle error ...
// ... do something useful ...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetBorder0Token

func SetBorder0Token(token string) error

SetBorder0Token sets the connector token in the environment variable BORDER0_TOKEN

func WriteToFile

func WriteToFile(path string, config *Configuration) error

Types

type Configuration

type Configuration struct {
	Token                      string            `yaml:"token"`
	ConnectorId                string            `yaml:"connector_id,omitempty"`
	ConnectorServer            string            `yaml:"connector_server,omitempty"`
	ConnectorInsecureTransport bool              `yaml:"connector_insecure,omitempty"`
	TunnelServer               string            `yaml:"tunnel_server,omitempty"`
	Variables                  map[string]string `yaml:"variables,omitempty"`
}

Configuration represents (static) connector configuration

func GetConfiguration

func GetConfiguration(ctx context.Context, configFilePath string) (*Configuration, error)

GetConfiguration looks for credentials and variables in the standard variable chain. i.e. environment variabels take priority and override any values in config files.

Jump to

Keyboard shortcuts

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