stack

package
v3.0.0-...-a5432f4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package stack manages the serialized and configurable state associated with a stack (i.e., deployment target).

Index

Constants

View Source
const (
	// DeploymentSchemaVersionOldestSupported is the oldest deployment schema that we
	// still support, i.e. we can produce a `deploy.Snapshot` from. This will generally
	// need to be at least one less than the current schema version so that old deployments can
	// be migrated to the current schema.
	DeploymentSchemaVersionOldestSupported = 1
)

Variables

View Source
var (
	// ErrDeploymentSchemaVersionTooOld is returned from `DeserializeDeployment` if the
	// untyped deployment being deserialized is too old to understand.
	ErrDeploymentSchemaVersionTooOld = errors.New("this stack's deployment is too old")

	// ErrDeploymentSchemaVersionTooNew is returned from `DeserializeDeployment` if the
	// untyped deployment being deserialized is too new to understand.
	ErrDeploymentSchemaVersionTooNew = errors.New("this stack's deployment version is too new")
)
View Source
var DefaultSecretsProvider secrets.Provider = &defaultSecretsProvider{}

DefaultSecretsProvider is the default SecretsProvider to use when deserializing deployments.

Functions

func CreateRootStackResource

func CreateRootStackResource(stackName tokens.QName, projectName tokens.PackageName) *resource.State

CreateRootStackResource creates a new root stack resource with the given name

func DeserializeCheckpoint

func DeserializeCheckpoint(
	ctx context.Context,
	secretsProvider secrets.Provider,
	chkpoint *apitype.CheckpointV3,
) (*deploy.Snapshot, error)

DeserializeCheckpoint takes a serialized deployment record and returns its associated snapshot. Returns nil if there have been no deployments performed on this checkpoint.

func DeserializeDeploymentV3

func DeserializeDeploymentV3(
	ctx context.Context,
	deployment apitype.DeploymentV3,
	secretsProv secrets.Provider,
) (*deploy.Snapshot, error)

DeserializeDeploymentV3 deserializes a typed DeploymentV3 into a `deploy.Snapshot`.

func DeserializeOperation

func DeserializeOperation(op apitype.OperationV2, dec config.Decrypter,
	enc config.Encrypter,
) (resource.Operation, error)

DeserializeOperation hydrates a pending resource/operation pair.

func DeserializePlan

func DeserializePlan(plan apitype.DeploymentPlanV1, dec config.Decrypter, enc config.Encrypter) (*deploy.Plan, error)

func DeserializePlanDiff

func DeserializePlanDiff(
	diff apitype.PlanDiffV1,
	dec config.Decrypter,
	enc config.Encrypter,
) (deploy.PlanDiff, error)

func DeserializeProperties

func DeserializeProperties(props map[string]interface{}, dec config.Decrypter,
	enc config.Encrypter,
) (resource.PropertyMap, error)

DeserializeProperties deserializes an entire map of deploy properties into a resource property map.

func DeserializePropertyValue

func DeserializePropertyValue(v interface{}, dec config.Decrypter,
	enc config.Encrypter,
) (resource.PropertyValue, error)

DeserializePropertyValue deserializes a single deploy property into a resource property value.

func DeserializeResource

func DeserializeResource(res apitype.ResourceV3, dec config.Decrypter, enc config.Encrypter) (*resource.State, error)

DeserializeResource turns a serialized resource back into its usual form.

func DeserializeResourcePlan

func DeserializeResourcePlan(
	plan apitype.ResourcePlanV1,
	dec config.Decrypter,
	enc config.Encrypter,
) (*deploy.ResourcePlan, error)

func DeserializeUntypedDeployment

func DeserializeUntypedDeployment(
	ctx context.Context,
	deployment *apitype.UntypedDeployment,
	secretsProv secrets.Provider,
) (*deploy.Snapshot, error)

DeserializeUntypedDeployment deserializes an untyped deployment and produces a `deploy.Snapshot` from it. DeserializeDeployment will return an error if the untyped deployment's version is not within the range `DeploymentSchemaVersionCurrent` and `DeploymentSchemaVersionOldestSupported`.

func GetRootStackResource

func GetRootStackResource(snap *deploy.Snapshot) (*resource.State, error)

GetRootStackResource returns the root stack resource from a given snapshot, or nil if not found.

func MarshalUntypedDeploymentToVersionedCheckpoint

func MarshalUntypedDeploymentToVersionedCheckpoint(
	stack tokens.QName, deployment *apitype.UntypedDeployment,
) (*apitype.VersionedCheckpoint, error)

func NewCachingSecretsManager

func NewCachingSecretsManager(manager secrets.Manager) secrets.Manager

NewCachingSecretsManager returns a new secrets.Manager that caches the ciphertext for secret property values. A secrets.Manager that will be used to encrypt and decrypt values stored in a serialized deployment can be wrapped in a caching secrets manager in order to avoid re-encrypting secrets each time the deployment is serialized.

func SerializeCheckpoint

func SerializeCheckpoint(stack tokens.QName, snap *deploy.Snapshot,
	showSecrets bool,
) (*apitype.VersionedCheckpoint, error)

SerializeCheckpoint turns a snapshot into a data structure suitable for serialization.

func SerializeDeployment

func SerializeDeployment(ctx context.Context, snap *deploy.Snapshot, showSecrets bool) (*apitype.DeploymentV3, error)

SerializeDeployment serializes an entire snapshot as a deploy record.

func SerializeOperation

func SerializeOperation(
	ctx context.Context, op resource.Operation, enc config.Encrypter, showSecrets bool,
) (apitype.OperationV2, error)

SerializeOperation serializes a resource in a pending state.

func SerializePlan

func SerializePlan(plan *deploy.Plan, enc config.Encrypter, showSecrets bool) (apitype.DeploymentPlanV1, error)

func SerializePlanDiff

func SerializePlanDiff(
	diff deploy.PlanDiff,
	enc config.Encrypter,
	showSecrets bool,
) (apitype.PlanDiffV1, error)

func SerializeProperties

func SerializeProperties(ctx context.Context, props resource.PropertyMap, enc config.Encrypter,
	showSecrets bool,
) (map[string]interface{}, error)

SerializeProperties serializes a resource property bag so that it's suitable for serialization.

func SerializePropertyValue

func SerializePropertyValue(ctx context.Context, prop resource.PropertyValue, enc config.Encrypter,
	showSecrets bool,
) (interface{}, error)

SerializePropertyValue serializes a resource property value so that it's suitable for serialization.

func SerializeResource

func SerializeResource(
	ctx context.Context, res *resource.State, enc config.Encrypter, showSecrets bool,
) (apitype.ResourceV3, error)

SerializeResource turns a resource into a structure suitable for serialization.

func SerializeResourcePlan

func SerializeResourcePlan(
	plan *deploy.ResourcePlan,
	enc config.Encrypter,
	showSecrets bool,
) (apitype.ResourcePlanV1, error)

func UnmarshalUntypedDeployment

func UnmarshalUntypedDeployment(
	ctx context.Context,
	deployment *apitype.UntypedDeployment,
) (*apitype.DeploymentV3, error)

UnmarshalUntypedDeployment unmarshals a raw untyped deployment into an up to date deployment object.

func UnmarshalVersionedCheckpointToLatestCheckpoint

func UnmarshalVersionedCheckpointToLatestCheckpoint(m encoding.Marshaler, bytes []byte) (*apitype.CheckpointV3, error)

func ValidateUntypedDeployment

func ValidateUntypedDeployment(deployment *apitype.UntypedDeployment) error

ValidateUntypedDeployment validates a deployment against the Deployment JSON schema.

Types

type NamedStackSecretsProvider

type NamedStackSecretsProvider struct {
	StackName string
}

NamedStackSecretsProvider is the same as the default secrets provider, but is aware of the stack name for which it is used. Currently this is only used for prompting passphrase secrets managers to show the stackname in the prompt for the passphrase.

func (NamedStackSecretsProvider) OfType

OfType returns a secrets manager for the given secrets type. Returns an error if the type is unknown or the state is invalid.

Jump to

Keyboard shortcuts

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