creds

package
v0.0.0-...-e867e26 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCredsFile     = "forjj-creds.yml"
	DefaultSecretFile    = "forjj.enc"
	DefaultSecretKeyFile = ".forjj.key"
	Global               = "global"
)

DefaultCredsFile is the default credential file name, without environment information.

View Source
const (
	// Internal represents the forjj internal storage
	Internal = "internal"
	// Link represents the file link storage.
	Link = "link"
)
View Source
const (
	// CredsVersion is the latest supported version of Forjj secrets files.
	CredsVersion = "0.2"
)
View Source
const KeySize = 32

Variables

This section is empty.

Functions

This section is empty.

Types

type Secrets

type Secrets struct {
	Envs map[string]*yamlSecure `yaml:";inline"`
	// contains filtered or unexported fields
}

Secrets is internal secret structured shared with ci to run forjj jobs

func NewSecrets

func NewSecrets() (ret *Secrets)

NewSecrets creates the internal secret object to shared with CI running infra/deploy repositories.

func (*Secrets) Export

func (s *Secrets) Export() (_ []byte, err error)

Export provides an extraction of forjj secrets encrypted.

func (*Secrets) ExportEnv

func (s *Secrets) ExportEnv(env *yamlSecure) (_ []byte, err error)

ExportEnv provides an extraction of an Env given encrypted.

func (*Secrets) GenerateKey

func (s *Secrets) GenerateKey() error

GenerateKey help to create a random key for the encryption

func (*Secrets) Import

func (s *Secrets) Import(ciphertext []byte) error

Import read an encrypted data, decrypt it and save it in Secrets

func (*Secrets) ImportToEnv

func (s *Secrets) ImportToEnv(ciphertext []byte, env *yamlSecure) error

ImportToEnv read an encrypted data, decrypt it and save it in the given Env.

func (*Secrets) Key64

func (s *Secrets) Key64() string

Key64 return the base64 of the internal key

func (*Secrets) ReadKey

func (s *Secrets) ReadKey(file string) error

ReadKey read a file containing the key

func (*Secrets) SaveKey

func (s *Secrets) SaveKey(file string) error

SaveKey save the key in a file

func (*Secrets) SetKey64

func (s *Secrets) SetKey64(key64 string) (err error)

type Secure

type Secure struct {
	// contains filtered or unexported fields
}

Secure is the master object to control Forjj security information.

func (*Secure) DefineDefaultCredFileName

func (d *Secure) DefineDefaultCredFileName(aPath, env string) string

DefineDefaultCredFileName define the internal credential path file for a specific environment.

func (*Secure) DefineDefaultSecretFileName

func (d *Secure) DefineDefaultSecretFileName(aPath, env string) string

DefineDefaultSecretFileName define the internal credential path file for a specific environment.

func (*Secure) DirName

func (d *Secure) DirName(env string) (_ string)

DirName Return the directory name owning the security file

func (*Secure) EncryptAll

func (d *Secure) EncryptAll(encrypt bool) error

EncryptAll is executed to encrypt all unencrypted files if found. The process is as follow:

if one uncrypted file is found, and no encrypted found, the file will be encrypted, automatically if both unencrypted and encrrypted files are found, it removes the unencrypted file if only encrypted file is found, nothing is done

If error is found, the function exit.

func (*Secure) Get

func (d *Secure) Get(objName, instanceName, keyName string) (value *Value, found bool, source, env string)

Get value of the object instance key...

func (*Secure) GetForjValue

func (d *Secure) GetForjValue(env, key string) (_ string, _ bool)

GetForjValue get a value from the 'forj' section.

func (*Secure) GetGlobal

func (d *Secure) GetGlobal(objName, instanceName, keyName string) (value *Value, found bool, source, env string)

GetGlobal get value of the object instance key in the globql space...

func (*Secure) GetGlobalString

func (d *Secure) GetGlobalString(objName, instanceName, keyName string) (value string, found bool, source, env string)

GetGlobalString return a string representation of the value.

func (*Secure) GetObjectInstance

func (d *Secure) GetObjectInstance(objName, instanceName string) (values map[string]*Value)

GetObjectInstance return the instance data

func (*Secure) GetSecrets

func (d *Secure) GetSecrets(env string) (result *Secrets)

GetSecrets Clone the secrets which is returned.

func (*Secure) GetString

func (d *Secure) GetString(objName, instanceName, keyName string) (value string, found bool, source, env string)

GetString return a string representation of the value whatever resource is providing the data (forjj data, files, ...)

func (*Secure) InitEnvDefaults

func (d *Secure) InitEnvDefaults(aPath, env string)

InitEnvDefaults initialize the internal cred module with file path. the file is prefixed by the deployment environment name.

func (*Secure) IsLoaded

func (d *Secure) IsLoaded(env string) (_ bool)

IsLoaded return true if the env file were loaded. successfully.

func (*Secure) Load

func (d *Secure) Load() error

Load security files (global + deployment one)

func (*Secure) Save

func (d *Secure) Save() error

Save security files (global + deployment one)

func (*Secure) SaveEnv

func (d *Secure) SaveEnv(env string) error

SaveEnv security file.

If env == global, it will save the global file.

func (*Secure) SetDefaultFile

func (d *Secure) SetDefaultFile(env string)

SetDefaultFile creates the file information.

func (*Secure) SetFile

func (d *Secure) SetFile(filePath, env string)

SetFile load a single file for the env given. if env is 'global', so data is considered as valid for all environment.

func (*Secure) SetForjValue

func (d *Secure) SetForjValue(env, source, key string, value *Value) (_ bool, _ error)

SetForjValue set a value in Forj section.

func (*Secure) SetGetterHandler

func (d *Secure) SetGetterHandler(key string, getter func(v *YamlValue) (string, error))

SetGetterHandler set getter types like 'link'

func (*Secure) SetObjectValue

func (d *Secure) SetObjectValue(env, source, obj_name, instance_name, key_name string, value *Value) (_ bool)

SetObjectValue set object value

func (*Secure) SetSetterHandler

func (d *Secure) SetSetterHandler(key string, setter func(v *Value, value *goforjj.ValueStruct) error)

SetSetterHandler set setter types like 'link'

func (*Secure) UnsetObjectValue

func (d *Secure) UnsetObjectValue(env, objName, instanceName, keyName string) (_ bool)

UnsetObjectValue remove the object value

func (*Secure) Upgrade

func (d *Secure) Upgrade(v0Func func(*Secure, string) error) (_ error)

Upgrade detects a need to upgrade current credentials data to new version

func (*Secure) Version

func (d *Secure) Version(env string) (_ string)

Version return the version of creds loaded. If a file is loaded, at least version = V0 if no file were loaded, verison is empty.

type Value

type Value struct {
	// contains filtered or unexported fields
}

ObjectValue describe the Objects keys value

func NewValue

func NewValue(source string, value *goforjj.ValueStruct) (ret *Value)

NewValue creates a new Value object, initialized with a ValueStruct if needed.

func (*Value) AddResource

func (v *Value) AddResource(key, value string)

AddResource adds resources information to the data given

func (Value) Clone

func (v Value) Clone() (ret *YamlValue)

Clone create a YamlValue struct duplicating Value.

func (*Value) GetResource

func (v *Value) GetResource(key string) (value string, found bool)

GetResource return the resource value

func (*Value) GetSource

func (v *Value) GetSource() string

GetSource get the source information of a Value instance

func (*Value) GetString

func (v *Value) GetString() (_ string, err error)

GetString source and value of a ForjValue instance

func (Value) MarshalYAML

func (v Value) MarshalYAML() (interface{}, error)

MarshalYAML encode the object in ValueStruct output

func (*Value) Set

func (v *Value) Set(source string, value *goforjj.ValueStruct) (err error)

Set source andvalue of a Value instance

func (*Value) SetSource

func (v *Value) SetSource(source string)

SetSource set the source information of a Value instance

func (*Value) SetValue

func (v *Value) SetValue(value interface{})

SetValue set the value of a Value instance

func (*Value) UnmarshalYAML

func (v *Value) UnmarshalYAML(unmarchal func(interface{}) error) (err error)

UnmarshalYAML decode the flow as a ValueStruct

type YamlValue

type YamlValue struct {
	Value    *goforjj.ValueStruct
	Resource map[string]string
	Source   string
}

Jump to

Keyboard shortcuts

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