clients

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator added in v0.9.0

type Authenticator interface {
	Authenticate(vc *VaultClient) error
}

Authenticator is an interface to identify which way to authenticate

func NewK8sAuthenticator added in v0.9.0

func NewK8sAuthenticator() Authenticator

NewK8sAuthenticator defines a new K8sAuthenticator struct.

func NewLocalAuthenticator added in v0.9.0

func NewLocalAuthenticator(token string) Authenticator

NewLocalAuthenticator defines a new LocalAuthenticator

type K8sAuthenticator added in v0.9.0

type K8sAuthenticator struct{}

K8sAuthenticator defines a struct for authenticating with Kubernetes.

func (*K8sAuthenticator) Authenticate added in v0.9.0

func (a *K8sAuthenticator) Authenticate(vc *VaultClient) error

Authenticate is used to authenticate using Kubernetes.

type LocalAuthenticator added in v0.9.0

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

LocalAuthenticator is used to configure the development mode

func (*LocalAuthenticator) Authenticate added in v0.9.0

func (a *LocalAuthenticator) Authenticate(vc *VaultClient) error

Authenticate is used to authenticate local (development mode).

type PrometheusClient

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

PrometheusClient represents the Prometheus client.

func NewPrometheusClient

func NewPrometheusClient(
	config PrometheusConfiguration,
	logger logging.Logger) PrometheusClient

NewPrometheusClient creates a PrometheusClient instance.

func (PrometheusClient) Query added in v0.9.1

func (c PrometheusClient) Query(ctx context.Context, query string, moment time.Time) (model.Value, error)

Query returns an instant vector, given the following parameters:

  • query: Prometheus query
  • moment: moment in time

It returns the result vector and the execution error encountered.

func (PrometheusClient) QueryRange

func (c PrometheusClient) QueryRange(ctx context.Context, query string, startAt, endAt time.Time, step time.Duration) (model.Value, error)

QueryRange returns range vectors as result type matrix, given the following parameters:

  • query: Prometheus query
  • startAt: start time
  • endAt: end time
  • step: interval duration

It returns the result matrix and the execution error encountered.

type PrometheusConfiguration

type PrometheusConfiguration struct {
	Address string `envconfig:"PROMETHEUS_ADDRESS" required:"true"`
}

PrometheusConfiguration represents the client configuration to connect to Prometheus.

func (*PrometheusConfiguration) LoadFromEnvVars

func (c *PrometheusConfiguration) LoadFromEnvVars() error

LoadFromEnvVars for PrometheusConfiguration.

type StorageClient

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

StorageClient is a structure that holds all the dependencies for the following client

func NewStorageClient

func NewStorageClient(logger logging.Logger, configuration StorageClientConfiguration) StorageClient

NewStorageClient returns an initialized struct with the required dependencies injected

func (*StorageClient) BasePath added in v0.9.2

func (sc *StorageClient) BasePath() string

BasePath returns a configured base path

func (*StorageClient) CheckIfExists

func (sc *StorageClient) CheckIfExists(relativePath string) bool

CheckIfExists attempts to check if the directory exists

func (*StorageClient) CreateDirectory

func (sc *StorageClient) CreateDirectory(relativePath string) error

CreateDirectory creates a new directory in the give path fails if the the path exists and is not a folder or other reason os related

func (*StorageClient) RemoveDirectory

func (sc *StorageClient) RemoveDirectory(relativePath string) error

RemoveDirectory attempts to remove the directory that holds requirements.txt

func (*StorageClient) Rename added in v0.9.2

func (sc *StorageClient) Rename(fromRelativePath, toAbsolutePath string) error

Rename attempts to rename a path

type StorageClientConfiguration

type StorageClientConfiguration struct {
	BasePath string `envconfig:"STORAGE_PATH" required:"true"`
}

StorageClientConfiguration is a struct that holds all the environment variables required to the Storage Client

func (*StorageClientConfiguration) LoadFromEnvVars

func (c *StorageClientConfiguration) LoadFromEnvVars() error

LoadFromEnvVars parses the required configuration variables. Throws an error if the validations aren't met

type StorageClientInterface

type StorageClientInterface interface {
	BasePath() string
	CreateDirectory(relativePath string) error
	RemoveDirectory(relativePath string) error
	CheckIfExists(relativePath string) bool
	Rename(fromRelativePath, toAbsolutePath string) error
}

StorageClientInterface defines storage client interface

type VaultClient

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

VaultClient defines the Vault client struct, holding all the required dependencies

func NewVaultClient

func NewVaultClient(logger logging.Logger, configuration VaultClientConfiguration, role string,
	authenticator Authenticator) (*VaultClient, error)

NewVaultClient returns an initialized struct with the required dependencies injected

func (*VaultClient) CheckIfEngineExists

func (vc *VaultClient) CheckIfEngineExists(path string) bool

CheckIfEngineExists attempts to call the /tune API endpoint on the Secrets Engine. Should it fail, it might be an indication that the Secrets Engine is not created, which it's useful to know whether or not to call CreateEngine

func (*VaultClient) Delete added in v0.9.0

func (vc *VaultClient) Delete(path string) error

Delete ...

func (*VaultClient) DeleteCredentials

func (vc *VaultClient) DeleteCredentials(path string) error

DeleteCredentials receives the path and attempts to delete the existing credentials on Vault. Is performs a soft delete, per docs > https://www.vaultproject.io/docs/commands/kv/delete

func (*VaultClient) Get added in v0.9.0

func (vc *VaultClient) Get(path string) (map[string]interface{}, error)

Get ...

func (*VaultClient) GetCredentials

func (vc *VaultClient) GetCredentials(path string) (*config.Credentials, error)

GetCredentials receives the path and attemps to retrieve the map of credentials present on the Vault server.

func (*VaultClient) List added in v0.9.0

func (vc *VaultClient) List(path string) (interface{}, error)

List ...

func (*VaultClient) Patch added in v0.9.0

func (vc *VaultClient) Patch(path string, data map[string]interface{}) error

Patch ...

func (*VaultClient) Put added in v0.9.0

func (vc *VaultClient) Put(path string, data map[string]interface{}) error

Put ...

func (*VaultClient) StoreCredentials

func (vc *VaultClient) StoreCredentials(path string, credentials map[string]string) error

StoreCredentials receives the path and the respective map of credentials and attempts to store them on the Vault server.

type VaultClientConfiguration

type VaultClientConfiguration struct {
	VaultURL string `envconfig:"VAULT_SERVER_URL" required:"true"`
}

VaultClientConfiguration is a struct that holds all the environment variables required to the Vault client

func (*VaultClientConfiguration) LoadFromEnvVars

func (vlc *VaultClientConfiguration) LoadFromEnvVars() error

LoadFromEnvVars parses the required configuration variables. Throws an error if the validations aren't met

Jump to

Keyboard shortcuts

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