dependency

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VaultAgentTokenSleepTime is the amount of time to sleep between queries, since
	// the fsnotify library is not compatible with solaris and other OSes yet.
	VaultAgentTokenSleepTime = 15 * time.Second
)

Variables

View Source
var (
	// VaultDefaultLeaseDuration is the default lease duration in seconds.
	VaultDefaultLeaseDuration time.Duration

	VaultLeaseRenewalThreshold float64
)
View Source
var ErrContinue = errors.New("dependency continue")

ErrContinue is a special error which says to continue (retry) on error.

View Source
var ErrLeaseExpired = errors.New("lease expired or is not renewable")
View Source
var ErrStopped = errors.New("dependency stopped")

ErrStopped is a special error that is returned when a dependency is prematurely stopped, usually due to a configuration reload or a process interrupt.

View Source
var (

	// FileQuerySleepTime is the amount of time to sleep between queries, since
	// the fsnotify library is not compatible with solaris and other OSes yet.
	FileQuerySleepTime = 2 * time.Second
)

Functions

func SetVaultDefaultLeaseDuration added in v1.0.0

func SetVaultDefaultLeaseDuration(t time.Duration)

Make sure to only set VaultDefaultLeaseDuration once

func SetVaultLeaseRenewalThreshold added in v1.0.0

func SetVaultLeaseRenewalThreshold(f float64)

Make sure to only set VaultLeaseRenewalThreshold once

Types

type ClientSet added in v0.9.0

type ClientSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ClientSet is a collection of clients that dependencies use to communicate with remote services like Consul or Vault.

func NewClientSet added in v0.9.0

func NewClientSet() *ClientSet

NewClientSet creates a new client set that is ready to accept clients.

func (*ClientSet) CreateVaultClient added in v0.15.0

func (c *ClientSet) CreateVaultClient(i *CreateVaultClientInput) error

func (*ClientSet) Stop added in v0.15.0

func (c *ClientSet) Stop()

Stop closes all idle connections for any attached clients.

func (*ClientSet) Vault added in v0.9.0

func (c *ClientSet) Vault() *vaultapi.Client

Vault returns the Vault client for this set.

type CreateVaultClientInput added in v0.15.0

type CreateVaultClientInput struct {
	Address         string
	Namespace       string
	Token           string
	UnwrapToken     bool
	SSLEnabled      bool
	SSLVerify       bool
	SSLCert         string
	SSLKey          string
	SSLCACert       string
	SSLCACertBytes  string
	SSLCAPath       string
	ServerName      string
	ClientUserAgent string

	K8SAuthRoleName            string
	K8SServiceAccountTokenPath string
	K8SServiceAccountToken     string
	K8SServiceMountPath        string

	TransportCustomDialer        TransportDialer
	TransportDialKeepAlive       time.Duration
	TransportDialTimeout         time.Duration
	TransportDisableKeepAlives   bool
	TransportIdleConnTimeout     time.Duration
	TransportMaxIdleConns        int
	TransportMaxIdleConnsPerHost int
	TransportTLSHandshakeTimeout time.Duration
}

CreateVaultClientInput is used as input to the CreateVaultClient function.

type Dependency

type Dependency interface {
	Fetch(*ClientSet, *QueryOptions) (interface{}, *ResponseMetadata, error)
	CanShare() bool
	String() string
	Stop()
	Type() Type
}

Dependency is an interface for a dependency that Consul Template is capable of watching.

type FileQuery added in v0.18.0

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

FileQuery represents a local file dependency.

func NewFileQuery added in v0.18.0

func NewFileQuery(s string) (*FileQuery, error)

NewFileQuery creates a file dependency from the given path.

func (*FileQuery) CanShare added in v0.18.0

func (d *FileQuery) CanShare() bool

CanShare returns a boolean if this dependency is shareable.

func (*FileQuery) Fetch added in v0.18.0

func (d *FileQuery) Fetch(clients *ClientSet, opts *QueryOptions) (interface{}, *ResponseMetadata, error)

Fetch retrieves this dependency and returns the result or any errors that occur in the process.

func (*FileQuery) Stop added in v0.18.0

func (d *FileQuery) Stop()

Stop halts the dependency's fetch function.

func (*FileQuery) String added in v0.18.0

func (d *FileQuery) String() string

String returns the human-friendly version of this dependency.

func (*FileQuery) Type added in v0.18.0

func (d *FileQuery) Type() Type

Type returns the type of this dependency.

type PemEncoded added in v1.0.0

type PemEncoded struct{ Cert, Key, CA string }

Return type containing PEMs as strings

func (PemEncoded) Data added in v1.0.0

func (p PemEncoded) Data() PemEncoded

a wrapper to mimic v2 secrets Data wrapper

type QueryOptions added in v0.9.0

type QueryOptions struct {
	AllowStale        bool
	Datacenter        string
	Region            string
	Near              string
	Choose            string
	RequireConsistent bool
	VaultGrace        time.Duration
	WaitIndex         uint64
	WaitTime          time.Duration
}

QueryOptions is a list of options to send with the query. These options are client-agnostic, and the dependency determines which, if any, of the options to use.

func (*QueryOptions) Merge added in v0.18.0

func (q *QueryOptions) Merge(o *QueryOptions) *QueryOptions

func (*QueryOptions) String added in v0.18.0

func (q *QueryOptions) String() string

type ResponseMetadata added in v0.9.0

type ResponseMetadata struct {
	LastIndex   uint64
	LastContact time.Duration
	BlockOnNil  bool // keep blocking on `nil` data returns
}

ResponseMetadata is a struct that contains metadata about the response. This is returned from a Fetch function call.

type Secret added in v0.9.0

type Secret struct {
	// The request ID that generated this response
	RequestID string

	LeaseID       string
	LeaseDuration int
	Renewable     bool

	// Data is the actual contents of the secret. The format of the data
	// is arbitrary and up to the secret backend.
	Data map[string]interface{}

	// Warnings contains any warnings related to the operation. These
	// are not issues that caused the command to fail, but that the
	// client should be aware of.
	Warnings []string

	// Auth, if non-nil, means that there was authentication information
	// attached to this response.
	Auth *SecretAuth

	// WrapInfo, if non-nil, means that the initial response was wrapped in the
	// cubbyhole of the given token (which has a TTL of the given number of
	// seconds)
	WrapInfo *SecretWrapInfo
}

Secret is the structure returned for every secret within Vault.

type SecretAuth added in v0.19.1

type SecretAuth struct {
	ClientToken string
	Accessor    string
	Policies    []string
	Metadata    map[string]string

	LeaseDuration int
	Renewable     bool
}

SecretAuth is the structure containing auth information if we have it.

type SecretWrapInfo added in v0.19.1

type SecretWrapInfo struct {
	Token           string
	TTL             int
	CreationTime    time.Time
	WrappedAccessor string
}

SecretWrapInfo contains wrapping information if we have it. If what is contained is an authentication token, the accessor for the token will be available in WrappedAccessor.

type ServiceTags

type ServiceTags []string

ServiceTags is a slice of tags assigned to a Service

type Set added in v0.18.0

type Set struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Set is a dependency-specific set implementation. Relative ordering is preserved.

func (*Set) Add added in v0.18.0

func (s *Set) Add(d Dependency) bool

Add adds a new element to the set if it does not already exist.

func (*Set) Get added in v0.18.0

func (s *Set) Get(v string) Dependency

Get retrieves a single element from the set by name.

func (*Set) Len added in v0.18.0

func (s *Set) Len() int

Len is the size of the set.

func (*Set) List added in v0.18.0

func (s *Set) List() []Dependency

List returns the insertion-ordered list of dependencies.

func (*Set) String added in v0.18.0

func (s *Set) String() string

String is a string representation of the set.

type TransportDialer added in v1.0.0

type TransportDialer interface {
	// Dial is intended to match https://pkg.go.dev/net#Dialer.Dial
	Dial(network, address string) (net.Conn, error)

	// DialContext is intended to match https://pkg.go.dev/net#Dialer.DialContext
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

TransportDialer is an interface that allows passing a custom dialer function to an HTTP client's transport config

type Type added in v0.18.0

type Type int
const (
	TypeVault Type = iota
	TypeLocal
)

type VaultAgentTokenQuery added in v0.20.0

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

VaultAgentTokenQuery is the dependency to Vault Agent token

func NewVaultAgentTokenQuery added in v0.20.0

func NewVaultAgentTokenQuery(path string) (*VaultAgentTokenQuery, error)

NewVaultAgentTokenQuery creates a new dependency.

func (*VaultAgentTokenQuery) CanShare added in v0.20.0

func (d *VaultAgentTokenQuery) CanShare() bool

CanShare returns if this dependency is sharable.

func (*VaultAgentTokenQuery) Fetch added in v0.20.0

func (d *VaultAgentTokenQuery) Fetch(clients *ClientSet, opts *QueryOptions) (interface{}, *ResponseMetadata, error)

Fetch retrieves this dependency and returns the result or any errors that occur in the process.

func (*VaultAgentTokenQuery) Stop added in v0.20.0

func (d *VaultAgentTokenQuery) Stop()

Stop halts the dependency's fetch function.

func (*VaultAgentTokenQuery) String added in v0.20.0

func (d *VaultAgentTokenQuery) String() string

String returns the human-friendly version of this dependency.

func (*VaultAgentTokenQuery) Type added in v0.20.0

func (d *VaultAgentTokenQuery) Type() Type

Type returns the type of this dependency.

type VaultListQuery added in v0.18.0

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

VaultListQuery is the dependency to Vault for a secret

func NewVaultListQuery added in v0.18.0

func NewVaultListQuery(s string) (*VaultListQuery, error)

NewVaultListQuery creates a new datacenter dependency.

func (*VaultListQuery) CanShare added in v0.18.0

func (d *VaultListQuery) CanShare() bool

CanShare returns if this dependency is shareable.

func (*VaultListQuery) Fetch added in v0.18.0

func (d *VaultListQuery) Fetch(clients *ClientSet, opts *QueryOptions) (interface{}, *ResponseMetadata, error)

Fetch queries the Vault API

func (*VaultListQuery) Stop added in v0.18.0

func (d *VaultListQuery) Stop()

Stop halts the given dependency's fetch.

func (*VaultListQuery) String added in v0.18.0

func (d *VaultListQuery) String() string

String returns the human-friendly version of this dependency.

func (*VaultListQuery) Type added in v0.18.0

func (d *VaultListQuery) Type() Type

Type returns the type of this dependency.

type VaultPKIQuery added in v1.0.0

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

VaultPKIQuery is the dependency to Vault for a secret

func NewVaultPKIQuery added in v1.0.0

func NewVaultPKIQuery(urlpath, filepath string, data map[string]interface{}) (*VaultPKIQuery, error)

NewVaultReadQuery creates a new datacenter dependency.

func (*VaultPKIQuery) CanShare added in v1.0.0

func (d *VaultPKIQuery) CanShare() bool

CanShare returns if this dependency is shareable.

func (*VaultPKIQuery) Fetch added in v1.0.0

func (d *VaultPKIQuery) Fetch(clients *ClientSet, opts *QueryOptions) (interface{}, *ResponseMetadata, error)

Fetch queries the Vault API

func (*VaultPKIQuery) Stop added in v1.0.0

func (d *VaultPKIQuery) Stop()

Stop halts the given dependency's fetch.

func (*VaultPKIQuery) String added in v1.0.0

func (d *VaultPKIQuery) String() string

String returns the human-friendly version of this dependency.

func (*VaultPKIQuery) Type added in v1.0.0

func (d *VaultPKIQuery) Type() Type

Type returns the type of this dependency.

type VaultReadQuery added in v0.18.0

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

VaultReadQuery is the dependency to Vault for a secret

func NewVaultReadQuery added in v0.18.0

func NewVaultReadQuery(s string) (*VaultReadQuery, error)

NewVaultReadQuery creates a new datacenter dependency.

func (*VaultReadQuery) CanShare added in v0.18.0

func (d *VaultReadQuery) CanShare() bool

CanShare returns if this dependency is shareable.

func (*VaultReadQuery) Fetch added in v0.18.0

func (d *VaultReadQuery) Fetch(clients *ClientSet, opts *QueryOptions,
) (interface{}, *ResponseMetadata, error)

Fetch queries the Vault API

func (*VaultReadQuery) Stop added in v0.18.0

func (d *VaultReadQuery) Stop()

Stop halts the given dependency's fetch.

func (*VaultReadQuery) String added in v0.18.0

func (d *VaultReadQuery) String() string

String returns the human-friendly version of this dependency.

func (*VaultReadQuery) Type added in v0.18.0

func (d *VaultReadQuery) Type() Type

Type returns the type of this dependency.

type VaultTokenQuery added in v0.18.0

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

VaultTokenQuery is the dependency to Vault for a secret

func NewVaultTokenQuery added in v0.18.0

func NewVaultTokenQuery(token string) (*VaultTokenQuery, error)

NewVaultTokenQuery creates a new dependency.

func (*VaultTokenQuery) CanShare added in v0.18.0

func (d *VaultTokenQuery) CanShare() bool

CanShare returns if this dependency is shareable.

func (*VaultTokenQuery) Fetch added in v0.18.0

func (d *VaultTokenQuery) Fetch(clients *ClientSet, opts *QueryOptions,
) (interface{}, *ResponseMetadata, error)

Fetch queries the Vault API

func (*VaultTokenQuery) Stop added in v0.18.0

func (d *VaultTokenQuery) Stop()

Stop halts the dependency's fetch function.

func (*VaultTokenQuery) String added in v0.18.0

func (d *VaultTokenQuery) String() string

String returns the human-friendly version of this dependency.

func (*VaultTokenQuery) Type added in v0.18.0

func (d *VaultTokenQuery) Type() Type

Type returns the type of this dependency.

type VaultWriteQuery added in v0.18.0

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

VaultWriteQuery is the dependency to Vault for a secret

func NewVaultWriteQuery added in v0.18.0

func NewVaultWriteQuery(s string, d map[string]interface{}) (*VaultWriteQuery, error)

NewVaultWriteQuery creates a new datacenter dependency.

func (*VaultWriteQuery) CanShare added in v0.18.0

func (d *VaultWriteQuery) CanShare() bool

CanShare returns if this dependency is shareable.

func (*VaultWriteQuery) Fetch added in v0.18.0

func (d *VaultWriteQuery) Fetch(clients *ClientSet, opts *QueryOptions,
) (interface{}, *ResponseMetadata, error)

Fetch queries the Vault API

func (*VaultWriteQuery) Stop added in v0.18.0

func (d *VaultWriteQuery) Stop()

Stop halts the given dependency's fetch.

func (*VaultWriteQuery) String added in v0.18.0

func (d *VaultWriteQuery) String() string

String returns the human-friendly version of this dependency.

func (*VaultWriteQuery) Type added in v0.18.0

func (d *VaultWriteQuery) Type() Type

Type returns the type of this dependency.

Jump to

Keyboard shortcuts

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