Documentation
¶
Index ¶
- Variables
- func ConvertFromGRPCCluster(k8s *spec.K8Scluster) ([]byte, error)
- func ConvertFromGRPCLoadBalancers(lbs *spec.LoadBalancers) ([]byte, error)
- func ConvertFromGRPCTask(t *spec.Task) ([]byte, error)
- func ConvertToGRPC(cfg *Config) (*spec.Config, error)
- func ConvertToGRPCCluster(k8s []byte) (*spec.K8Scluster, error)
- func ConvertToGRPCClusterState(cluster *ClusterState) (*spec.ClusterState, error)
- func ConvertToGRPCClusters(cluster Clusters) (*spec.Clusters, error)
- func ConvertToGRPCLoadBalancers(lbs []byte) (*spec.LoadBalancers, error)
- func ConvertToGRPCStages(stages []Stage) ([]*spec.Stage, error)
- func ConvertToGRPCTask(t []byte) (*spec.Task, error)
- func ConvertToGRPCTaskEvent(te *TaskEvent) (*spec.TaskEvent, error)
- func ConvertToGRPCWorkflow(w Workflow) *spec.Workflow
- type ClusterState
- type Clusters
- type Config
- type FinishedWorkflow
- type InMemoryStore
- func (i *InMemoryStore) Close() error
- func (i *InMemoryStore) CreateConfig(_ context.Context, config *Config) error
- func (i *InMemoryStore) DeleteConfig(_ context.Context, name string, version uint64) error
- func (i *InMemoryStore) GetConfig(_ context.Context, name string) (*Config, error)
- func (i *InMemoryStore) HealthCheck() error
- func (i *InMemoryStore) ListConfigs(_ context.Context, filter *ListFilter) ([]*Config, error)
- func (i *InMemoryStore) MarkForDeletion(_ context.Context, name string, version uint64) error
- func (i *InMemoryStore) UpdateConfig(_ context.Context, config *Config) error
- type KubernetesContext
- type ListFilter
- type Manifest
- type Mongo
- func (m *Mongo) Close() error
- func (m *Mongo) CreateConfig(ctx context.Context, config *Config) error
- func (m *Mongo) DeleteConfig(ctx context.Context, name string, version uint64) error
- func (m *Mongo) GetConfig(ctx context.Context, name string) (*Config, error)
- func (m *Mongo) HealthCheck() error
- func (m *Mongo) Init() error
- func (m *Mongo) ListConfigs(ctx context.Context, filter *ListFilter) ([]*Config, error)
- func (m *Mongo) MarkForDeletion(ctx context.Context, name string, version uint64) error
- func (m *Mongo) UpdateConfig(ctx context.Context, config *Config) error
- type Stage
- type StageDescription
- type StageKind
- type Store
- type SubPass
- type TaskEvent
- type Workflow
Constants ¶
This section is empty.
Variables ¶
var ErrNotFoundOrDirty = errors.New(
"failed to find requested document. It is possible that this operation was a Dirty Write." +
"Consider fetching the latest version of the requested document to repeat the read-write cycle",
)
ErrNotFoundOrDirty is returned when the requested document couldn't be found inside the database or a Dirty Write occurred.
Functions ¶
func ConvertFromGRPCCluster ¶ added in v0.10.0
func ConvertFromGRPCCluster(k8s *spec.K8Scluster) ([]byte, error)
ConvertFromGRPCCluster deterministically converts the grpc representation to the database representation.
func ConvertFromGRPCLoadBalancers ¶ added in v0.10.0
func ConvertFromGRPCLoadBalancers(lbs *spec.LoadBalancers) ([]byte, error)
ConvertFromGRPCLoadBalancers deterministically converts the grpc representation to the database representation.
func ConvertToGRPC ¶
ConvertToGRPC converts from database representation to GRPC representation. For clusters, it mimics the GRPC unmarshalling style where if a field was not set within a message it will be nil instead of a zero value for that type.
func ConvertToGRPCCluster ¶ added in v0.10.0
func ConvertToGRPCCluster(k8s []byte) (*spec.K8Scluster, error)
ConvertToGRPCCluster converts the database representation to the GRPC representation.
func ConvertToGRPCClusterState ¶ added in v0.10.0
func ConvertToGRPCClusterState(cluster *ClusterState) (*spec.ClusterState, error)
func ConvertToGRPCClusters ¶ added in v0.10.0
convertClusters converts the database representation to the GRPC representation. If no error is returned, the result can still be nil. This is so that the GRPC representation will have a nil (essentially mimicking what the GRPC unmarshall does if the respective value is not set) value as well when converted which simplifies checking absence of a specific state (i.e. current, desired).
func ConvertToGRPCLoadBalancers ¶ added in v0.10.0
func ConvertToGRPCLoadBalancers(lbs []byte) (*spec.LoadBalancers, error)
ConvertToGRPCLoadBalancers converts the database representation to the GRPC representation.
func ConvertToGRPCStages ¶ added in v0.10.0
func ConvertToGRPCWorkflow ¶
ConvertToGRPCWorkflow converts the database representation of the workflow state to GRPC.
Types ¶
type ClusterState ¶
type ClusterState struct {
Current Clusters `bson:"current"`
InFlight *TaskEvent `bson:"inFlight"`
State Workflow `bson:"state"`
}
func ConvertFromGRPCClusterState ¶ added in v0.10.0
func ConvertFromGRPCClusterState(cluster *spec.ClusterState) (*ClusterState, error)
func (*ClusterState) Exists ¶ added in v0.10.0
func (cs *ClusterState) Exists() bool
type Config ¶
type Config struct {
Version uint64 `bson:"version"`
Name string `bson:"name"`
K8SCtx KubernetesContext `bson:"kubernetesContext"`
Manifest Manifest `bson:"manifest"`
Clusters map[string]*ClusterState `bson:"clusters"`
}
type FinishedWorkflow ¶ added in v0.10.0
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
func (*InMemoryStore) Close ¶
func (i *InMemoryStore) Close() error
func (*InMemoryStore) CreateConfig ¶
func (i *InMemoryStore) CreateConfig(_ context.Context, config *Config) error
func (*InMemoryStore) DeleteConfig ¶
func (*InMemoryStore) HealthCheck ¶
func (i *InMemoryStore) HealthCheck() error
func (*InMemoryStore) ListConfigs ¶
func (i *InMemoryStore) ListConfigs(_ context.Context, filter *ListFilter) ([]*Config, error)
func (*InMemoryStore) MarkForDeletion ¶
func (*InMemoryStore) UpdateConfig ¶
func (i *InMemoryStore) UpdateConfig(_ context.Context, config *Config) error
type KubernetesContext ¶
type ListFilter ¶
type ListFilter struct {
ManifestState []string
}
ListFilter wraps supported filters for listing configs.
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
func (*Mongo) CreateConfig ¶
func (*Mongo) DeleteConfig ¶
func (*Mongo) HealthCheck ¶
func (*Mongo) ListConfigs ¶
func (*Mongo) MarkForDeletion ¶
type Stage ¶ added in v0.10.0
type Stage struct {
Kind StageKind `bson:"kind"`
Description StageDescription `bson:"description"`
SubPasses []SubPass `bson:"subPasses"`
}
type StageDescription ¶ added in v0.10.0
type Store ¶
type Store interface {
io.Closer
healthcheck.HealthChecker
// CreateConfig creates a new config. It is up to the application logic to determine if the
// config already exists or not. On conflict, the creation will error out. The Version field
// of the config will always be overwritten to 0 as new configs always start with a version of 0.
CreateConfig(ctx context.Context, config *Config) error
// UpdateConfig updates an existing config in the database with the new supplied data. If there is no document
// that matches the Config.Name and Config.Version the ErrNotFoundOrDirty err is returned. It is up to the application
// code to determine, if the write was Dirty (i.e. outdated Document version used) or there is no such document with the
// requested Config.Name and Config.Version combination. Before updating the document, a higher document version
// number by 1 will replace the supplied number in Config.Version (i.e. Config.Version += 1).
UpdateConfig(ctx context.Context, config *Config) error
// GetConfig queries the document with the Config.Name. If no such document is found the ErrNotFoundOrDirty err
// is returned. In this case it always will be the case that the document is absent. This can be used by the application
// code to determine an absent document or Dirty Write.
GetConfig(ctx context.Context, name string) (*Config, error)
// ListConfigs queries all documents stored that satisfy the passed in ListFilter.
ListConfigs(ctx context.Context, filter *ListFilter) ([]*Config, error)
// DeleteConfig will delete the document with the requested Config.Name and Config.Version combination.
// If No documents with the given combination were deleted the ErrNotFoundOrDirty err is returned. It is up
// to the application code to handle the case in which a Dirty Write occurred or the document does not exist.
DeleteConfig(ctx context.Context, name string, version uint64) error
// MarkForDeletion will mark the infrastructure in the document with the requested Config.Name and Config.Version for
// deletion. If No documents with the given combination were marked for deletion the ErrNotFoundOrDirty err is returned. It is up
// to the application code to handle the case in which a Dirty Write occurred or the document does not exist.
MarkForDeletion(ctx context.Context, name string, version uint64) error
}
type SubPass ¶ added in v0.10.0
type SubPass struct {
Kind string `bson:"kind"`
Description StageDescription `bson:"description"`
}
type TaskEvent ¶
type TaskEvent struct {
Id string `bson:"id"`
Timestamp string `bson:"timestamp"`
Type string `bson:"event"`
Task []byte `bson:"task"`
Description string `bson:"description"`
Pipeline []Stage `bson:"pipeline"`
CurrentStage uint32 `bson:"currentStage"`
LowerPriority *TaskEvent `bson:"lowerPriority"`
// Deprecated.
// TODO: remove in future versions.
OnError []byte `bson:"onError"`
}
type Workflow ¶
type Workflow struct {
Status string `bson:"status"`
Description string `bson:"description"`
Timestamp string `bson:"timestamp"`
Previous []FinishedWorkflow `bson:"previous"`
TicksUntilRefresh int32 `bson:"ticksUntilRefresh"`
}
func ConvertFromGRPCWorkflow ¶
ConvertFromGRPCWorkflow converts the workflow state data from GRPC to the database representation.