config

package
v0.0.0-...-f761163 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package config allows a struct-loading approach to configuration. This is a modified version of the ucpconfig package

Index

Constants

This section is empty.

Variables

View Source
var APIKeysConfigEnum = struct {
	Disabled  APIKeysConfigValue
	AdminOnly APIKeysConfigValue
	AllUsers  APIKeysConfigValue
}{
	Disabled:  "disabled",
	AdminOnly: "admin_only",
	AllUsers:  "all_users",
}

APIKeysConfigEnum - defines possible configuration values for Stratos API keys feature

Functions

func Load

func Load(intf interface{}, envLookup env.Lookup) error

Load the given pointer to struct with values from the environment and the /etc/secrets/ directory.

In order to make the struct load correctly, use struct tags to define the configuration name, if the configName struct tag is ommitted it will not attempt to look anything up. This is contrary to most serialization libraries like JSON which require a "-" struct tag to bypass deserialization.

type A struct {
  Port   uint    `configName:"PORT"`
  Name   string  `configName:"SERVICE_NAME"`
  Struct *myType
}

The name will be given as defined to Getenv, and if that fails a lookup it's name is then munged to conform to the /etc/secrets filename structure and the file is attempted to be read.

func NewConfigFileLookup

func NewConfigFileLookup(path string) env.Lookup

NewConfigFileLookup - Load the configuration values in the specified config file if it exists

func NewSecretsDirLookup

func NewSecretsDirLookup(secretsDir string) env.Lookup

NewSecretsDirLookup - create a secret dir lookup reads a variable in the form HELLO_THERE from a file in /etc/secrets/hello-there

func SetStructFieldValue

func SetStructFieldValue(value reflect.Value, field reflect.Value, val string) error

Types

type APIKeysConfigValue

type APIKeysConfigValue string

APIKeysConfigValue - special type for configuring whether API keys feature is enabled

Jump to

Keyboard shortcuts

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