config

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package config implements the config file logic.

Index

Constants

View Source
const (
	// OmniConfigEnvVar is the environment variable to override the default config path.
	OmniConfigEnvVar = "OMNICONFIG"
)
View Source
const PlaceholderURL = "<placeholder_url>"

PlaceholderURL is a placeholder url.

Variables

View Source
var (
	// DefaultContext is the context with the default values.
	DefaultContext = Context{
		URL: "grpc://127.0.0.1:8080",
	}
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Basic    string   `yaml:"basic,omitempty"`
	SideroV1 SideroV1 `yaml:"siderov1,omitempty"`
}

Auth contains the authentication configuration for a context.

type Config

type Config struct {
	Contexts map[string]*Context `yaml:"contexts"`
	Context  string              `yaml:"context"`
	Path     string              `yaml:"-"`
}

Config represents the omni configuration.

func Current

func Current() (*Config, error)

Current returns the currently targeted config.

func Init

func Init(path string, create bool) (*Config, error)

Init initializes the Current config and returns it.

func (*Config) GetContext

func (c *Config) GetContext(name string) (*Context, error)

GetContext returns the context with the given name. If empty, it will return the selected context in the config file.

func (*Config) Merge

func (c *Config) Merge(additionalConfigPath string) ([]Rename, error)

Merge in additional contexts from another Config.

Current context is overridden from passed in config.

func (*Config) Save

func (c *Config) Save() error

Save saves the config to the path it is configured to, or defaults to the known default config paths. It modifies the Path to point to the saved file.

type Context

type Context struct {
	URL  string `yaml:"url"`
	Auth Auth   `yaml:"auth,omitempty"`
}

Context represents a context in the config.

type Rename

type Rename struct {
	From string
	To   string
}

Rename describes context rename during merge.

func (*Rename) String

func (r *Rename) String() string

String converts to "from" -> "to".

type SideroV1

type SideroV1 struct {
	Identity string `yaml:"identity,omitempty"`
}

SideroV1 is the auth configuration v1.

Jump to

Keyboard shortcuts

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