commons

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_ID        = "env_id"
	TEMP_KEY_NAME = "key"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddConfig

type AddConfig struct {
	Value string `json:"value,omitempty"`

	//	Allows the value to be synced as an exposable one
	//	on platforms which differentiate between decryptable and non-decryptable secrets.
	//	For example, Github and Vercel.
	Exposable bool `json:"exposable,omitempty"`
}

type CleanupSecretOptions

type CleanupSecretOptions struct {
	EnvID   string `json:"env_id"`
	Version int    `json:"version"`
}

type DecryptOptions

type DecryptOptions struct {
	Secret *Secret `json:"secret"`

	// Organisation's encryption key to decrypt the secret with.
	Key []byte `json:"key"`
}

type DeleteRequestOptions

type DeleteRequestOptions struct {
	EnvID   string `json:"env_id"`
	Key     string `json:"key"`
	Version *int   `json:"version"`
}

func (*DeleteRequestOptions) Marshal

func (r *DeleteRequestOptions) Marshal() ([]byte, error)

type DeleteSecretOptions

type DeleteSecretOptions struct {
	EnvID   string `json:"env_id"`
	Key     string `json:"key"`
	Version *int   `json:"version"`
}

type GetOptions

type GetOptions struct {
	Key     string `json:"key"`
	EnvID   string `json:"env_id"`
	Version *int   `json:"version,omitempty"`
}

type GetRequestOptions

type GetRequestOptions struct {
	EnvID   string `query:"env_id"`
	Key     string `query:"key"`
	Version *int   `query:"version"`
}

type GetResponse

type GetResponse struct {
	Secret *Secret       `json:"secret"`
	Token  *tokens.Token `json:"token,omitempty"`
}

type ListRequestOptions

type ListRequestOptions struct {
	EnvID   string `query:"env_id"`
	Version *int   `query:"version,omitempty"`
}

func (*ListRequestOptions) Marshal

func (r *ListRequestOptions) Marshal() ([]byte, error)

type MergeOptions

type MergeOptions struct {
	SourceEnvID   string `json:"source_env_id"`
	SourceVersion *int   `json:"source_version"`
	TargetEnvID   string `json:"target_env_id"`
}
 type MergeRequestOptions struct {
	SourceEnvID   string `json:"source_env_id"`
	SourceVersion *int   `json:"source_version"`
	TargetEnvID   string `json:"env_id"`
}
func (r *MergeRequestOptions) Marshal() ([]byte, error) {
	return json.Marshal(r)
}

type MergeResponse

type MergeResponse struct {
	Version *int `json:"version,omitempty"`
}

type Path

type Path struct {
	Organisation string `json:"org"`
	Project      string `json:"project"`
	Environment  string `json:"env"`
}

func (*Path) Location

func (p *Path) Location() string

type Secret

type Secret struct {

	//	To allows mutually exclusive locking
	sync.Mutex

	ID        string    `json:"id,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	UserID    string    `json:"user_id,omitempty"`
	EnvID     string    `json:"env_id,omitempty"`

	//	Version of the secrets, if available.
	Version *int `json:"version,omitempty"`

	// Contains the secret mapping.
	Data keypayload.KPMap `json:"data,omitempty"`
}

func (*Secret) Add

func (s *Secret) Add(key string, config *AddConfig)

Sets a new key=value pair to the map.

func (*Secret) ChangeKey

func (s *Secret) ChangeKey(old, new string)

Updates a key name in the map from "old" to "new."

func (*Secret) DataCopy

func (s *Secret) DataCopy() map[string]*payload.Payload

Returns a shallow copy of the secret's key=value mapping.

func (*Secret) Decode

func (s *Secret) Decode() error

Base64 decodes all the pairs in the map.

func (*Secret) Decrypt

func (s *Secret) Decrypt(key [32]byte) error

Decrypts all the key=value pairs with provided decryption key.

func (*Secret) Decrypted

func (s *Secret) Decrypted(key [32]byte) (result *Secret, err error)

Decrypts all the key=value pairs with provided key and returns a new deep copy of the secret data without mutating the existing one.

func (*Secret) Delete

func (s *Secret) Delete(key string)

Deletes a key=value pair from the map.

func (*Secret) DeleteValues

func (s *Secret) DeleteValues()

Empties the values from the payloads of all key=value pairs.

func (*Secret) Encode

func (s *Secret) Encode()

Base64 encodes all the pairs in the map.

func (*Secret) Encrypt

func (s *Secret) Encrypt(key [32]byte) error

Encrypts all the key=value pairs with provided encryption key.

func (*Secret) Encrypted

func (s *Secret) Encrypted(key [32]byte) (*Secret, error)

Encrypts all the key=value pairs with provided key and returns a new deep copy of the secret data without mutating the existing one.

func (*Secret) Get

func (s *Secret) Get(key string) *payload.Payload

Fetches the value for a specific key from the map.

func (*Secret) GetFmtString

func (s *Secret) GetFmtString(key string) string
Get formatted string.

Fetches key=value representation for a specific key and value from the map.

func (*Secret) GetValue

func (s *Secret) GetValue(key string) string

Fetches the value for a specific key from the map.

func (*Secret) IncrementVersion

func (s *Secret) IncrementVersion()

Increases the version of the secret by 1.

func (*Secret) IsEmpty

func (s *Secret) IsEmpty() bool

Checks whether the secret contains even a single key=value mapping.

func (*Secret) MarkEncoded

func (s *Secret) MarkEncoded()

Marks all payload values as Base64 encoded.

func (*Secret) MarkExposable

func (s *Secret) MarkExposable(key string)

Marks the "exposable" value of the payload as "true."

Exposability allows the value to be synced as an exposable one
on platforms which differentiate between decryptable and non-decryptable secrets.
For example, Github and Vercel.
In Github actions, this value will be synced as a "variable" and NOT a secret, once it is marked "exposable" over here.

func (*Secret) MarkNotExposable

func (s *Secret) MarkNotExposable(key string)

func (*Secret) Overwrite

func (s *Secret) Overwrite(source map[string]*payload.Payload)

Ovewrites or replaces values in the map for respective keys from supplied map.

func (*Secret) Set

func (s *Secret) Set(key string, value *payload.Payload)

Sets a key=value pair to the map.

func (*Secret) ToMap

func (s *Secret) ToMap() *keyvalue.KVMap

Converts all the key=value pairs to a map.

func (*Secret) UnmarshalJSON

func (s *Secret) UnmarshalJSON(data []byte) error

type SetOptions

type SetOptions struct {
	EnvID string                      `json:"env_id"`
	Data  map[string]*payload.Payload `json:"data"`
}

func (*SetOptions) Marshal

func (r *SetOptions) Marshal() ([]byte, error)

type SetRequestOptions

type SetRequestOptions struct {
	EnvID string                      `json:"env_id"`
	Data  map[string]*payload.Payload `json:"data"`
}

func (*SetRequestOptions) Marshal

func (r *SetRequestOptions) Marshal() ([]byte, error)

type SyncOptions

type SyncOptions struct {
	EnvID           string            `json:"env_id"`
	IntegrationType string            `json:"integration_type"`
	Version         *int              `json:"version"`
	Data            *keypayload.KPMap `json:"data"`
}

func (*SyncOptions) Marshal

func (r *SyncOptions) Marshal() ([]byte, error)

type VaultResponse

type VaultResponse struct {
	Errors        []interface{} `json:"errors"`
	RequestID     string        `json:"request_id,omitempty"`
	LeaseID       string        `json:"lease_id,omitempty"`
	Renewable     bool          `json:"renewable,omitempty"`
	LeaseDuration int           `json:"lease_duration,omitempty"`
	Data          struct {
		Ciphertext string `json:"ciphertext,omitempty"`
		Plaintext  string `json:"plaintext,omitempty"`
		KeyVersion int    `json:"key_version,omitempty"`
		Backup     string `json:"backup,omitempty"`
	} `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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