userdata

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(manifestJSON []byte, opts Options) (string, error)

Render renders userdata from an explicitly pinned vmconfig manifest JSON document. It performs no network or file access.

Types

type ClusterData

type ClusterData struct {
	ID     string
	CACert string
}

type InstanceData

type InstanceData struct {
	ID   string
	Type string
}

type LocalData

type LocalData struct {
	VMForwardPortToLocalServerHTTPS int
	LocalServerHostFromVM           string
	LocalServerHTTPSPort            string
}

LocalData contains values only rendered for local VMs.

type Options

type Options struct {
	DepsMirrorURL              string
	ProviderKind               string
	AWSAccountID               string
	GoogleProjectID            string
	ImmutableSSHAuthorizedKeys string
	EnableSSM                  bool
}

Options contains values used to render Podplane userdata.

type ProviderData

type ProviderData struct {
	Kind   string
	Region string
	Zone   string
}

type ServerData

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

	// ImmutableSSHAuthorizedKeys is written only by user-data and changing it
	// changes the Nstance instance configuration hash.
	ImmutableSSHAuthorizedKeys string

	// EnableSSM controls whether user-data installs and starts AWS SSM Agent.
	EnableSSM bool

	// AWSAccountID and GoogleProjectID are dedicated fields because they are
	// provider inputs, not Nstance mutable env 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

	// The following fields are only used for local VMs and is not used
	// when rendering user-data for real clusters
	Local LocalData
}

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

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 validates the template variables and renders the 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