config

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Filename into which Config is serialized
	Filename = "config.yaml"

	// Repositories is the default directory for repositoires.
	Repositories = "repositories"

	// DefaultLanguage is intentionaly undefined.
	DefaultLanguage = ""

	// DefaultBuilder is statically defined by the builders package.
	DefaultBuilder = builders.Default
)

Variables

This section is empty.

Functions

func CreatePaths

func CreatePaths() (err error)

CreatePaths is a convenience function for creating the on-disk func config structure. All operations should be tolerant of nonexistant disk footprint where possible (for example listing repositories should not require an extant path, but _adding_ a repository does require that the func config structure exist. Current structure is: ~/.config/func ~/.config/func/repositories

func DefaultNamespace

func DefaultNamespace() (namespace string)

DefaultNamespace for remote operations is the currently active context namespace (if available) or the fallback "default". Subsequently the value will be populated, indicating the namespace in which the function is currently deployed. Changes to this value will issue warnings to the user.

func Dir

func Dir() (path string)

Dir is derived in the following order, from lowest to highest precedence.

  1. The default path is the zero value, indicating "no config path available", and users of this package should act accordingly.
  2. ~/.config/func if it exists (can be expanded: user has a home dir)
  3. The value of $XDG_CONFIG_PATH/func if the environment variable exists.

The path is created if it does not already exist.

func File

func File() string

File returns the full path at which to look for a config file. Use FUNC_CONFIG_FILE to override default.

func Get

func Get(c Global, name string) any

Get the named global config value from the given global config struct. Nonexistent values return nil. Implemented as a package-static function because Set is implemented as such. See the long-winded explanation above.

func List

func List() []string

List the globally configurable settings by the key which can be used in the accessors Get and Set, and in the associated disk serialized. Sorted. Implemented as a package-static function because Set is implemented as such. See the long-winded explanation above.

func RepositoriesPath

func RepositoriesPath() string

RepositoriesPath returns the full path at which to look for repositories. Use FUNC_REPOSITORIES_PATH to override default.

Types

type Global

type Global struct {
	Builder   string `yaml:"builder,omitempty"`
	Confirm   bool   `yaml:"confirm,omitempty"`
	Language  string `yaml:"language,omitempty"`
	Namespace string `yaml:"namespace,omitempty"`
	Registry  string `yaml:"registry,omitempty"`
	Verbose   bool   `yaml:"verbose,omitempty"`

	RegistryInsecure bool `yaml:"registryInsecure,omitempty"`
}

Global configuration settings.

func Load

func Load(path string) (c Global, err error)

Load the config exactly as it exists at path (no static defaults)

func New

func New() Global

New Config struct with all members set to static defaults. See NewDefaults for one which further takes into account the optional config file.

func NewDefault

func NewDefault() (cfg Global, err error)

NewDefault returns a config populated by global defaults as defined by the config file located in .Path() (the global func settings path, which is

usually ~/.config/func).

The config path is not required to be present.

func Set

func Set(c Global, name, value string) (Global, error)

Set value of a member by name and a stringified value. Fails if the passed value can not be coerced into the value expected by the member indicated by name.

func SetBool

func SetBool(c Global, name string, value bool) (Global, error)

SetBool value of a member by name, returning the updated config.

func SetString

func SetString(c Global, name, value string) (Global, error)

SetString value of a member by name, returning the updated config.

func (Global) Apply

func (c Global) Apply(f fn.Function) Global

Apply populated values from a function to the config. The resulting config is global settings overridden by a given function.

func (Global) Configure

func (c Global) Configure(f fn.Function) fn.Function

Configure a function with populated values of the config. The resulting function is the function overridden by values on config.

func (Global) RegistryDefault

func (c Global) RegistryDefault() string

RegistyDefault is a convenience method for deferred calculation of a default registry taking into account both the global config file and cluster detection.

func (Global) Write

func (c Global) Write(path string) (err error)

Write the config to the given path To use the currently configured path (used by the constructor) use File()

c := config.NewDefault()
c.Verbose = true
c.Write(config.File())

Jump to

Keyboard shortcuts

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