func (v *Vault) Add(key string, value []byte) {
	v.Lock()
	defer v.Unlock()
	v.data[key] = value
}
Add adds a value to the vault. This operation is safe to use concurrently.
Add will overwrite if the key already exists and not warn.
package security
import (
	"bytes"
	"crypto/aes"
	"crypto/cipher"
	"crypto/sha256"
	"encoding/binary"
	"encoding/hex"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"github.com/gaia-pipeline/gaia"
)
const (
	vaultName = ".gaia_vault"
	keySize   = 32
)
type GaiaVault interface {
	LoadSecrets() error
	GetAll() []string
	SaveSecrets() error
	Add(key string, value []byte)
	Remove(key string)
	Get(key string) ([]byte, error)
}
type VaultStorer interface {
	Init() error
	Read() (data []byte, err error)
	Write(data []byte) error
}
type FileVaultStorer struct {
	path string
}
type Vault struct {
	storer VaultStorer
	cert   []byte
	data   map[string][]byte
	sync.RWMutex
	counter uint64
	key     []byte
}
func NewVault(ca CAAPI, storer VaultStorer) (*Vault, error) {
	v := new(Vault)
	if storer == nil {
		return nil, errors.New("vault must be created with a valid VaultStore")
	}
	err := storer.Init()
	if err != nil {
		return nil, err
	}
	_, certKey := ca.GetCACertPath()
	data, err := ioutil.ReadFile(certKey)
	if err != nil {
		return nil, err
	}
	if len(data) < keySize {
		return nil, errors.New("key lenght should be longer than 32")
	}
	h := sha256.New()
	_, _ = h.Write(data)
	sum := h.Sum(nil)
	v.storer = storer
	v.cert = data
	v.key = sum[:keySize]
	v.data = make(map[string][]byte)
	return v, nil
}
func (v *Vault) LoadSecrets() error {
	r, err := v.storer.Read()
	if err != nil {
		return err
	}
	data, err := v.decrypt(r)
	if err != nil {
		return err
	}
	return v.parseToMap(data)
}
func (v *Vault) SaveSecrets() error {
	data := v.parseFromMap()
	encryptedData, err := v.encrypt(data)
	if err != nil {
		return err
	}
	v.data = make(map[string][]byte)
	return v.storer.Write([]byte(encryptedData))
}
func (v *Vault) GetAll() []string {
	v.RLock()
	defer v.RUnlock()
	m := make([]string, 0)
	for k := range v.data {
		m = append(m, k)
	}
	return m
}