spring

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func LoadDefault

func LoadDefault(propNames []string) (map[string]interface{}, error)

LoadDefault will use the following defaults:

Check for the following config locations:

  1. /opt/spinnaker/config
  2. /home/spinnaker/config
  3. /root/config
  4. HOME_DIR/.spinnaker

Profiles:

  • armory
  • local

Env:

Pulls os.Environ()

Specify propNames in the same way as LoadProperties().

func LoadDefaultDynamic

func LoadDefaultDynamic(ctx context.Context, propNames []string, updateFn func(map[string]interface{}, error)) (map[string]interface{}, error)

Similar to LoadDefault but provides a callback function that will be invoked when a configuration change is detected. Parsing errors are also provided to the callback, so check for these as well. This works by keeping track of files parsed during the initial parsing, it means that files will only be tracked if they contain something. e.g. you cannot dynamically add a profile. Environment variables are frozen on the initial run. This is by design

func LoadDefaultDynamicWithEnv added in v0.0.3

func LoadDefaultDynamicWithEnv(env SpringEnv, ctx context.Context, propNames []string, updateFn func(map[string]interface{}, error)) (map[string]interface{}, error)

func LoadDefaultWithEnv added in v0.0.3

func LoadDefaultWithEnv(env SpringEnv, propNames []string) (map[string]interface{}, error)

func LoadProperties

func LoadProperties(propNames []string, configDir string, envKeyPairs []string) (map[string]interface{}, error)

LoadProperties tries to do what spring properties manages by loading files using the right precedence and returning a merged map that contains all the keys and their values have been substituted for the correct value

Usage:

If you want to load the following files:
  - spinnaker.yml/yaml
  - spinnaker-local.yml/yaml
  - gate-local.yml/yaml
  - gate-armory.yml/yaml

Then For propNames you would give:

["spinnaker", "gate"]

and you'll need to make sure your envKeyPairs has the following key pair as one of it's variables

SPRING_PROFILES_ACTIVE="armory,local"

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type SpringEnv added in v0.0.4

type SpringEnv struct {
	DefaultConfigDirs []string
	DefaultProfiles   []string
	ConfigDir         string
	EnvMap            map[string]string
}

Jump to

Keyboard shortcuts

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