state

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

package state defines the structure of the Constellation state file.

Index

Constants

View Source
const (
	// Version1 is the first version of the state file.
	Version1 = "v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Azure

type Azure struct {
	ResourceGroup            string `yaml:"resourceGroup"`
	SubscriptionID           string `yaml:"subscriptionID"`
	NetworkSecurityGroupName string `yaml:"networkSecurityGroupName"`
	LoadBalancerName         string `yaml:"loadBalancerName"`
	UserAssignedIdentity     string `yaml:"userAssignedIdentity"`
	AttestationURL           string `yaml:"attestationURL"`
}

Azure describes the infra state related to Azure.

type ClusterValues

type ClusterValues struct {
	// ClusterID is the unique identifier of the cluster.
	ClusterID string `yaml:"clusterID"`
	// OwnerID is the unique identifier of the owner of the cluster.
	OwnerID string `yaml:"ownerID"`
	// MeasurementSalt is the salt generated during cluster init.
	MeasurementSalt []byte `yaml:"measurementSalt"`
}

ClusterValues describe the (Kubernetes) cluster state, set during initialization of the cluster.

type GCP

type GCP struct {
	ProjectID  string `yaml:"projectID"`
	IPCidrNode string `yaml:"ipCidrNode"`
	IPCidrPod  string `yaml:"ipCidrPod"`
}

GCP describes the infra state related to GCP.

type Infrastructure

type Infrastructure struct {
	UID               string   `yaml:"uid"`
	ClusterEndpoint   string   `yaml:"clusterEndpoint"`
	InitSecret        []byte   `yaml:"initSecret"`
	APIServerCertSANs []string `yaml:"apiServerCertSANs"`
	// Name is the name of the cluster.
	Name  string `yaml:"name"`
	Azure *Azure `yaml:"azure,omitempty"`
	GCP   *GCP   `yaml:"gcp,omitempty"`
}

Infrastructure describe the state related to the cloud resources of the cluster.

type State

type State struct {
	Version        string         `yaml:"version"`
	Infrastructure Infrastructure `yaml:"infrastructure"`
	ClusterValues  ClusterValues  `yaml:"clusterValues"`
}

State describe the entire state to describe a Constellation cluster.

func New

func New() *State

New creates a new cluster state (file).

func NewFromIDFile

func NewFromIDFile(idFile clusterid.File, cfg *config.Config) *State

NewFromIDFile creates a new cluster state file from the given ID file and config.

func ReadFromFile

func ReadFromFile(fileHandler file.Handler, path string) (*State, error)

ReadFromFile reads the state file at the given path and returns the state.

func (*State) Merge

func (s *State) Merge(other *State) (*State, error)

Merge merges the state information from other into the current state. If a field is set in both states, the value of the other state is used.

func (*State) SetClusterValues

func (s *State) SetClusterValues(clusterValues ClusterValues) *State

SetClusterValues sets the cluster values.

func (*State) SetInfrastructure

func (s *State) SetInfrastructure(infrastructure Infrastructure) *State

SetInfrastructure sets the infrastructure state.

func (*State) WriteToFile

func (s *State) WriteToFile(fileHandler file.Handler, path string) error

WriteToFile writes the state to the given path, overwriting any existing file.

Jump to

Keyboard shortcuts

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