userdata

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package userdata renders cloud-init user-data scripts for Podplane VMs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuoteEnvValue added in v0.1.2

func QuoteEnvValue(value string) string

QuoteEnvValue quotes a value using the same single-quote format as vmconfig's shell helpers use for env files.

func RenderMutableEnv added in v0.1.2

func RenderMutableEnv(vars MutableVars) string

RenderMutableEnv renders the subset of user-data env that vmconfig's update-mutable-env.sh accepts for post-boot updates.

func SourceForNstance added in v0.1.2

func SourceForNstance(manifest *deps.Manifest, depsMirrorURL string, providerKind string, awsAccountID string, googleProjectID string) (string, error)

SourceForNstance renders the canonical userdata template into the template source nstance-server renders later for each VM.

Types

type ClusterData added in v0.1.2

type ClusterData struct {
	ID     string
	CACert string
}

type InstanceData added in v0.1.2

type InstanceData struct {
	ID   string
	Type string
}

type MutableVars added in v0.1.2

type MutableVars map[string]string

MutableVars are the variables exposed to the canonical Nstance-style userdata template and rendered into mutable.env.

func (MutableVars) SetObjectStorageEndpoint added in v0.1.2

func (v MutableVars) SetObjectStorageEndpoint(endpoint string)

SetObjectStorageEndpoint sets all component object storage endpoints to the same value. Use direct field assignment when components use different stores.

func (MutableVars) SetObjectStorageRegion added in v0.1.2

func (v MutableVars) SetObjectStorageRegion(region string)

SetObjectStorageRegion sets all component object storage regions to the same value. Use direct field assignment when components use different stores.

type ProviderData added in v0.1.2

type ProviderData struct {
	Kind   string
	Region string
	Zone   string
}

type ServerData added in v0.1.2

type ServerData struct {
	RegistrationAddr string
	AgentAddr        string
}

type TemplateVars

type TemplateVars struct {
	// Manifest is the resolved vmconfig manifest for this VM.
	Manifest *deps.Manifest `validate:"required"`

	// DepsMirrorURL, when set, overrides all upstream dependency URLs with
	// mirror-relative paths (<base>/<name>/<version>/<filename>). Used for
	// local development and air-gapped installs.
	DepsMirrorURL string `validate:"omitempty,url"`

	// The following fields map to the same structure nstance-server uses
	// in production for interpolating data into production userdata
	Cluster  ClusterData
	Provider ProviderData
	Instance InstanceData
	Server   ServerData
	Vars     MutableVars

	// AWSAccountID and GoogleProjectID are dedicated fields because they are
	// tf provider inputs, not Nstance mutable env vars pushed through Vars.
	AWSAccountID    string
	GoogleProjectID string

	// Nonce is a dedicated field because it is Nstance first-boot bootstrap data,
	// not a value vmconfig should receive later through mutable.env.
	Nonce string
}

TemplateVars are the template variables consumed by user-data.sh.

func (*TemplateVars) ApplyDefaults

func (v *TemplateVars) ApplyDefaults()

ApplyDefaults populates derived values (e.g. cluster-prefixed bucket names) when the caller has not set them explicitly.

func (*TemplateVars) ManifestFilter

func (v *TemplateVars) ManifestFilter() deps.ItemFilter

ManifestFilter selects dependencies that apply to this VM's provider.

func (*TemplateVars) Render

func (v *TemplateVars) Render() (string, error)

Render produces the rendered user-data script.

func (*TemplateVars) Validate

func (v *TemplateVars) Validate() error

Validate checks the TemplateVars are populated correctly enough to render.

Jump to

Keyboard shortcuts

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