updates

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DatastoreMetadataKey = "datastore"

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// Name is the user-facing identifier for a graph of updates.
	Name string `json:"name"`

	// Metadata contains any additional properties about the channel.
	// For example, the applicable datastore is stored as metadata.
	Metadata map[string]string `json:"metadata,omitempty"`

	// Edges are the transitions between states in the update graph.
	Edges EdgeSet `json:"edges,omitempty"`

	// Nodes are the possible states in an update graph.
	Nodes []State `json:"nodes,omitempty"`
}

Channel is a named series of updates in which we expect to have a path to the "head" of the channel from every node.

func (Channel) Clone added in v1.8.0

func (c Channel) Clone() Channel

Clone makes a copy of a channel

func (Channel) EqualIdentity added in v1.2.0

func (c Channel) EqualIdentity(other Channel) bool

EqualIdentity determines if two channels represent the same stream of updates by comparing their metadata.

func (Channel) RemoveNodes added in v1.8.0

func (c Channel) RemoveNodes(nodes []State) Channel

RemoveNodes nodes removes the specified nodes and any edges to or from those nodes.

type EdgeSet

type EdgeSet map[string][]string

EdgeSet maps a node id to a list of node ids that it can update to

type MemorySource

type MemorySource struct {
	// OrderedNodes is an ordered list of all nodes. Lower index == newer currentVersion.
	OrderedNodes []State
	// Nodes is a helper to lookup a node by id
	Nodes NodeSet
	// Edges contains the edgeset for this source.
	Edges EdgeSet
}

MemorySource is an in-memory implementation of Source. It's an oracle to answer update questions for an installed currentVersion.

func (*MemorySource) LatestVersion

func (m *MemorySource) LatestVersion(id string) string

func (*MemorySource) NextVersion

func (m *MemorySource) NextVersion(from string) string

func (*MemorySource) NextVersionWithoutMigrations

func (m *MemorySource) NextVersionWithoutMigrations(from string) (found string)

func (*MemorySource) State

func (m *MemorySource) State(id string) State

func (*MemorySource) Subgraph

func (m *MemorySource) Subgraph(head string) (Source, error)

type NodeSet

type NodeSet map[string]int

NodeSet maps a node id to an index in the OrderedNodes array

type Source

type Source interface {
	// NextVersionWithoutMigrations returns the newest currentVersion that has an edge that
	// does not require any migrations.
	NextVersionWithoutMigrations(from string) string

	// NextVersion returns the newest currentVersion that has an edge.
	// This currentVersion might include migrations.
	NextVersion(from string) string

	// LatestVersion returns the newest currentVersion that has some path through the
	// graph.
	//
	// If no path exists, returns the empty string.
	//
	// If different from `NextVersion`, that means multiple steps are
	// required (i.e. a multi-phase migration, or a required stopping point
	// in a series of updates).
	LatestVersion(from string) string

	// State returns the information that is required to update to the provided
	// node.
	State(id string) State

	// Subgraph returns a new Source that is a subgraph of the current source,
	// but where `head` is set to the provided node.
	Subgraph(head string) (Source, error)
}

Source models a single stream of updates for an installed currentVersion.

func NewMemorySource

func NewMemorySource(nodes []State, edges EdgeSet) (Source, error)

type State

type State struct {
	ID        string `json:"id"`
	Tag       string `json:"tag,omitempty"`
	Migration string `json:"migration,omitempty"`
	Phase     string `json:"phase,omitempty"`
	Digest    string `json:"digest,omitempty"`

	// Deprecated releases can be updated from, but not to
	Deprecated bool `json:"-"`
}

State is a "node" in the channel graph, indicating how to run at that release.

type UpdateGraph

type UpdateGraph struct {
	Channels []Channel `json:"channels,omitempty"`
}

UpdateGraph holds a graph of required update edges

func (*UpdateGraph) AvailableVersions

func (g *UpdateGraph) AvailableVersions(engine string, v v1alpha1.SpiceDBVersion) ([]v1alpha1.SpiceDBVersion, error)

AvailableVersions traverses an UpdateGraph and collects a list of the safe versions for updating from the provided currentVersion.

func (*UpdateGraph) ComputeTarget

func (g *UpdateGraph) ComputeTarget(defaultBaseImage, image, version, channel, engine string, currentVersion *v1alpha1.SpiceDBVersion, rolling bool) (baseImage string, target *v1alpha1.SpiceDBVersion, state State, err error)

ComputeTarget determines the target update version and state given an update graph and the proper context.

func (*UpdateGraph) Copy

func (g *UpdateGraph) Copy() UpdateGraph

Copy returns a copy of the graph. The controller gets a copy so that the graph doesn't change during a single reconciliation.

func (*UpdateGraph) DefaultChannelForDatastore

func (g *UpdateGraph) DefaultChannelForDatastore(datastore string) (string, error)

DefaultChannelForDatastore returns the first channel for a specific datastore. This makes it possible to pick a channel even if a channel name is not provided. In the future we may want to explicitly define default channels.

func (*UpdateGraph) Difference added in v1.2.0

func (g *UpdateGraph) Difference(other *UpdateGraph) *UpdateGraph

Difference returns a graph that contains just edges in g that are not in the second update graph, plus the nodes/channels associated with them This is primarily used for diffing update graphs to know what edges require testing.

func (*UpdateGraph) SourceForChannel

func (g *UpdateGraph) SourceForChannel(engine, channel string) (Source, error)

SourceForChannel returns a channel represented as a Source for querying

Jump to

Keyboard shortcuts

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