Documentation ¶
Overview ¶
Package boltdb provides an implementation of DeploymentStore that uses boltdb. It can deal with multiple versions of how deployments are serialized to disk. Only the lastest version needs to provide an interface to write a deployment.
Versions:
- v0: This version used gob to serialize most of the deployment. The dex config was serialized using protobuf.
- v1: The deployment and the config are serialized using protobuf. The deployment and config live under separate keys in the v1 bucket.
Some reasons why a new version might be created:
- Assumptions have been made that api.AutomateConfig will move in a compatible way. This means you can add fields and deprecate fields, but can never change the type or reuse a deprecated field. If this is ever needed, all of api.AutomateConfig will need to be redefined under one of the versions and a new version will likely need to be created.
- The deployment struct changes and the types no longer map well. A new version can be created to reduce some of the complexity with how things get serialized, however old versions will still need to be able to read and mapped in a sane way.
- The way the buckets and keys are organized needs to change
Index ¶
- type CurrentVersion
- type DeploymentStore
- func (s *DeploymentStore) GetDeployment() (*deployment.Deployment, error)
- func (s *DeploymentStore) Initialize() error
- func (s *DeploymentStore) TryRead() (*deployment.Deployment, UpgradeableVersion, error)
- func (s *DeploymentStore) UpdateDeployment(cb persistence.DeploymentUpdateCallback) (*deployment.Deployment, error)
- func (s *DeploymentStore) WriteTo(w io.Writer) error
- type UpgradeableVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurrentVersion ¶
type CurrentVersion interface { UpgradeableVersion Initialize(*bolt.Tx) error WriteDeployment(*bolt.Tx, *deployment.Deployment) error }
CurrentVersion represents the things the current storage version must be able to do
type DeploymentStore ¶
type DeploymentStore struct {
// contains filtered or unexported fields
}
DeploymentStore is a deployment store backed by boltdb
func NewDeploymentStore ¶
func NewDeploymentStore(db *bolt.DB) *DeploymentStore
NewDeploymentStore wraps boltdb to be able to read the deployment from boltdb. It is expected that all migrations have already run before trying to use
func (*DeploymentStore) GetDeployment ¶
func (s *DeploymentStore) GetDeployment() (*deployment.Deployment, error)
GetDeployment gets the deployment for deploymentID
func (*DeploymentStore) Initialize ¶
func (s *DeploymentStore) Initialize() error
Initialize prepares the deployment store to be used. It MUST be called after creation, otherwise all calls to UpdateDeployment and GetDeployment will fail.
func (*DeploymentStore) TryRead ¶
func (s *DeploymentStore) TryRead() (*deployment.Deployment, UpgradeableVersion, error)
TryRead attempts to read the deployment store given the currently known versions.
func (*DeploymentStore) UpdateDeployment ¶
func (s *DeploymentStore) UpdateDeployment(cb persistence.DeploymentUpdateCallback) (*deployment.Deployment, error)
UpdateDeployment receives the current version of the deployment and expects the caller to update it through the callback. This updated version will be committed to the database.
type UpgradeableVersion ¶
type UpgradeableVersion interface { Name() string ReadDeployment(tx *bolt.Tx) (*deployment.Deployment, error) Cleanup(*bolt.Tx) error }
UpgradeableVersion is a version that can be upgraded to the latest. Old versions should implement the UpgradeableVersion interface.