dto

package
v1.1.15 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {

	// Primary identifier of an object of this structure.
	//
	// required: true
	ID string `json:"id,omitempty"`

	// The “normalised” UTC timestamp with time zone at which this object was created.
	//
	// In postgreSQL, this is a "Timestamptz" type field.
	//
	// For example, if your input string is: 2018-08-28T12:30:00+05:30 , when this timestamp is stored in the database, it will be stored as 2018-08-28T07:00:00.
	//
	// required: true
	CreatedAt time.Time `json:"created_at,omitempty"`

	// The “normalised” UTC timestamp with time zone at which this object was last updated.
	//
	// In postgreSQL, this is a "Timestamptz" type field.
	//
	// For example, if your input string is: 2018-08-28T12:30:00+05:30 , when this timestamp is stored in the database, it will be stored as 2018-08-28T07:00:00.
	//
	// required: true
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

The base structure embeded in every structure that represents a table in our database. This structure shouldn't be of much use to those who only intend to use the secrets structure for data transformations.

type KPMap

type KPMap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Key-Payload Map

func (*KPMap) ChangeKey

func (m *KPMap) ChangeKey(old, new string)

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

func (*KPMap) Decode

func (m *KPMap) Decode() error

Base64 decodes all the pairs in the map.

func (*KPMap) Decrypt

func (m *KPMap) Decrypt(key [32]byte) error

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

func (*KPMap) Decrypted

func (m *KPMap) Decrypted(key [32]byte) (*KPMap, error)

Decrypts all the key=value pairs with the provided key and returns a new deep copy of the map.

func (*KPMap) Delete

func (m *KPMap) Delete(key string)

Deletes a key=value pair from the map.

func (*KPMap) DeleteValues

func (m *KPMap) DeleteValues()

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

func (*KPMap) Encode

func (m *KPMap) Encode()

Base64 encodes all the pairs in the map.

func (*KPMap) Encrypt

func (m *KPMap) Encrypt(key [32]byte) error

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

func (*KPMap) Encrypted

func (m *KPMap) Encrypted(key [32]byte) (*KPMap, error)

Encrypts all the key=value pairs with the provided key and returns a new deep copy of the map.

func (*KPMap) FmtString

func (m *KPMap) FmtString(key string) string

Returns string representation in the form of "key=value"

func (*KPMap) FmtStrings

func (m *KPMap) FmtStrings() []string

Returns an array of string representations in the form of "key=value"

func (*KPMap) Get

func (m *KPMap) Get(key string) *Payload

Fetches the payload for a specific key from the map.

func (*KPMap) GetMapping

func (m *KPMap) GetMapping() map[string]*Payload

Returns the mapping.

func (*KPMap) GetValue

func (m *KPMap) GetValue(key string) string

Fetches the value from the payload for a specific key in the map.

func (*KPMap) IsEmpty

func (m *KPMap) IsEmpty() bool

Returns a boolean validating whether the length of the map is 0.

func (*KPMap) Keys

func (m *KPMap) Keys() []string

Returns an array of all the keys in the mapping.

func (*KPMap) Load

func (m *KPMap) Load(mapping *KPMap)

func (*KPMap) MarkAllDecoded

func (m *KPMap) MarkAllDecoded()

Marks all payload values as Base64 decoded.

func (*KPMap) MarkAllEncoded

func (m *KPMap) MarkAllEncoded()

Marks all payload values as Base64 encoded.

func (*KPMap) MarkDecoded

func (m *KPMap) MarkDecoded(key string)

Marks payload value for specified key as Base64 decoded.

func (*KPMap) MarkEncoded

func (m *KPMap) MarkEncoded(key string)

Marks payload value for specified key as Base64 encoded.

func (*KPMap) MarkExposable

func (m *KPMap) 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 (*KPMap) MarkNotExposable

func (m *KPMap) MarkNotExposable(key string)

func (*KPMap) MarshalJSON

func (m *KPMap) MarshalJSON() ([]byte, error)

Custom Marshaller.

func (*KPMap) Overwrite

func (m *KPMap) Overwrite(source *KPMap)

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

func (*KPMap) Set

func (m *KPMap) Set(key string, value *Payload)

Sets a key=payload pair to the map.

func (*KPMap) SetValue

func (m *KPMap) SetValue(key, value string)

Sets the value for the payload belong the the specified key in the map.

func (*KPMap) ToKVMap

func (m *KPMap) ToKVMap() *KVMap

Returns a new key=value mapping.

func (*KPMap) UnmarshalJSON

func (m *KPMap) UnmarshalJSON(data []byte) error

Custom Unmarshaler.

type KVMap

type KVMap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Map representing key=value pairs.

func (*KVMap) Delete

func (m *KVMap) Delete(key string)

Deletes a key=value pair from the map.

func (*KVMap) Get

func (m *KVMap) Get(key string) string

Fetches the value for a specific key from the map.

func (*KVMap) GetMapping

func (m *KVMap) GetMapping() map[string]string

Returns the mapping from the KVMap.

func (*KVMap) MarshalJSON

func (m *KVMap) MarshalJSON() ([]byte, error)

Custom Marshaller.

func (*KVMap) MarshalYAML

func (m *KVMap) MarshalYAML() ([]byte, error)

Custom Marshaller.

func (*KVMap) Set

func (m *KVMap) Set(key, value string)

Sets a key=value pair to the map.

func (*KVMap) String

func (m *KVMap) String(key string) string

Returns string representation in the form of "key=value"

func (*KVMap) UnmarshalIn

func (m *KVMap) UnmarshalIn(i interface{}) error

Unmarshalls the json in provided interface.

func (*KVMap) UnmarshalJSON

func (m *KVMap) UnmarshalJSON(data []byte) error

Custom Unmarshaler.

func (*KVMap) UnmarshalYAML

func (m *KVMap) UnmarshalYAML(data []byte) error

Custom Unmarshaler.

type Payload

type Payload struct {
	sync.Mutex
	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"`
	// contains filtered or unexported fields
}

func (*Payload) Decode

func (p *Payload) Decode() error

Base64 decodes the value of the payload.

func (*Payload) Decrypt

func (p *Payload) Decrypt(key [32]byte) error

Decrypts the value of the payload with the supplied key.

func (*Payload) Decrypted

func (p *Payload) Decrypted(key [32]byte) (*Payload, error)

Decrypts the value of the payload and returns a new deep copy of the payload.

func (*Payload) DeleteValue

func (p *Payload) DeleteValue()

Empties the values from the payload.

func (*Payload) Encode

func (p *Payload) Encode()

Base64 encodes the value of the payload.

func (*Payload) Encrypt

func (p *Payload) Encrypt(key [32]byte) error

func (*Payload) Encrypted

func (p *Payload) Encrypted(key [32]byte) (*Payload, error)

Encrypts the value of the payload with the supplied key and returns a new deep copy of the payload.

func (*Payload) GetValue

func (p *Payload) GetValue() string

Returns the value of the payload.

func (*Payload) IsEmpty

func (p *Payload) IsEmpty() bool

Returns boolean indicating whether the value of the payload is empty or not.

func (*Payload) IsEncoded

func (p *Payload) IsEncoded() bool

Returns boolean whether the payload is already encoded or not.

func (*Payload) IsExposable

func (p *Payload) IsExposable() bool

Returns a boolean validating whether a value is exposable or not.

func (*Payload) MarkDecoded

func (p *Payload) MarkDecoded()

Marks the payload as "base64 decoded"

func (*Payload) MarkEncoded

func (p *Payload) MarkEncoded()

Marks the payload as "base64 encoded"

func (*Payload) MarkExposable

func (p *Payload) MarkExposable()

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 (*Payload) MarkNotExposable

func (p *Payload) MarkNotExposable()

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

Read the documentation of "MarkExposable" function.

func (*Payload) Set

func (p *Payload) Set(value string)

Sets the value of the payload.

func (*Payload) ToMap

func (p *Payload) ToMap() (result map[string]interface{}, err error)

Converts the payload to a map.

type Secret

type Secret struct {
	Base

	//	The UUID of the user in our database who created this secret.
	//
	//	reference: https://en.wikipedia.org/wiki/Universally_unique_identifier
	//	required: true
	UserID string `json:"user_id,omitempty"`

	//	The UUID of the project environment in our database this secret belongs to.
	//
	//	reference: https://en.wikipedia.org/wiki/Universally_unique_identifier
	//	required: true
	EnvID string `json:"env_id,omitempty"`

	//	The version of this secret.
	//	When the secret is created, the default version is 1.
	//	While fetching the secret, sometimes the version may not be fetched, therefore, it is a pointer which can be nil.
	//
	//	required: false
	//	default: 0
	Version *int `json:"version,omitempty"`

	//	The mapping of all the key-value pairs this secret contains.
	//
	//	format: dto.KPMap
	//	required: true
	Data *KPMap `json:"data,omitempty"`
}

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() KPMap

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

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 *KPMap)

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

func (*Secret) Set

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

Sets a key=value pair to the map.

func (*Secret) ToKVMap

func (s *Secret) ToKVMap() *KVMap

Converts all the key=value pairs to a map.

func (*Secret) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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