cloudinit

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MetaData      *MetaData
	UserData      *UserData
	NetworkConfig *NetworkConfig
}

Config represents all configurations for cloud init

func ConfigFromDir

func ConfigFromDir(dirs ...string) (*Config, error)

ConfigFromDir reads cloud-init configuration from directories. If multiple directories are passed, configurations of later directories overwrite configurations of previous directories

func NewDefaultConfig

func NewDefaultConfig(name, user, sshPubKey string) *Config

NewDefaultConfig returns a minimal default config based on name, user and ssh public key

func (*Config) ISO

func (c *Config) ISO() ([]byte, error)

ISO returns the cloud init configuration as ISO image

func (*Config) Merge

func (c *Config) Merge(c2 *Config) error

Merge merges configuration c2 into Config. Configurations in c2 overwrite configurations in Config.

func (*Config) String

func (c *Config) String() (string, error)

String returns a string representation of all cloud-init configs

func (*Config) ToDir

func (c *Config) ToDir(dir string) error

ToDir writes the cloud init configuration to a directory

type DNS

type DNS struct {
	Servers []string `json:"addresses"`
	Search  []string `json:"search,omitempty"`
}

type Ethernet

type Ethernet struct {
	Match     *Match   `json:"match,omitempty"`
	Addresses []string `json:"addresses,omitempty"`
	DHCP      *bool    `json:"dhcp4,omitempty"`
	Gateway   *string  `json:"gateway4,omitempty"`
	DNS       *DNS     `json:"nameservers,omitempty"`
}

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
}

type Match

type Match struct {
	Name *string `json:"name,omitempty"`
	MAC  *string `json:"macaddress,omitempty"`
}

type MetaData

type MetaData struct {
	Raw        map[string]any `json:"-"`
	Hostname   string         `json:"local-hostname,omitempty"`
	InstanceID string         `json:"instnace-id,omitempty"`
}

MetaData is a struct to render the meta data of the cloud init configuration

func (*MetaData) Marshal

func (md *MetaData) Marshal() ([]byte, error)

func (*MetaData) Merge

func (md *MetaData) Merge(md2 *MetaData) error

func (*MetaData) Unmarshal

func (md *MetaData) Unmarshal(data []byte) error

type NetworkConfig

type NetworkConfig struct {
	Raw       map[string]any      `json:"-"`
	Version   int                 `json:"version"`
	Ethernets map[string]Ethernet `json:"ethernets"`
}

func NewNetworkConfig

func NewNetworkConfig(nco NetworkConfigOptions) (*NetworkConfig, error)

func (*NetworkConfig) Marshal

func (nc *NetworkConfig) Marshal() ([]byte, error)

func (*NetworkConfig) Merge

func (nc *NetworkConfig) Merge(nc2 *NetworkConfig) error

func (*NetworkConfig) Unmarshal

func (nc *NetworkConfig) Unmarshal(data []byte) error

type NetworkConfigOptions

type NetworkConfigOptions struct {
	Address    string
	Gateway    string
	Nameserver []string
}

type User

type User struct {
	Name              string   `json:"name"`
	SSHAuthorizedKeys []string `json:"ssh-authorized-keys,omitempty"`
	Sudo              string   `json:"sudo,omitempty"`
	LockPasswd        *bool    `json:"lock_passwd,omitempty"`
	Passwd            string   `json:"passwd,omitempty"`
	Shell             string   `json:"shell"`
}

User definition of cloud init configuration

type UserData

type UserData struct {
	Raw map[string]any `json:"-"`
	// Hostname string
	// Password        string `yaml:"password,omitempty"`
	// SSHPasswordAuth bool   `yaml:"ssh_pwauth,omitempty"`
	Users []User `json:"users,omitempty"`
}

UserData is a struct to render the user data of the cloud init configuration

func (*UserData) Marshal

func (ud *UserData) Marshal() ([]byte, error)

func (*UserData) Merge

func (ud *UserData) Merge(ud2 *UserData) error

func (*UserData) Unmarshal

func (ud *UserData) Unmarshal(data []byte) error

Jump to

Keyboard shortcuts

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