Documentation ¶
Index ¶
- Variables
- func IsCloudConfig(userdata string) bool
- type CloudInitPatcher
- func (c *CloudInitPatcher) Encode() string
- func (c *CloudInitPatcher) Get(key string) any
- func (c *CloudInitPatcher) GetEnv(key string) string
- func (c *CloudInitPatcher) Patch(key string, value any) *CloudInitPatcher
- func (c *CloudInitPatcher) SetEnv(key string, value string) *CloudInitPatcher
- func (c *CloudInitPatcher) String() string
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDecodeFailed is returned when base64 decoding fails ErrDecodeFailed = errors.New("failed to decode base64") // ErrNoCloudConfig is returned when no cloud-config header is found ErrNoCloudConfig = errors.New("no cloud-config header found") // ErrMalformedData is returned when the cloud-init data is malformed ErrMalformedData = errors.New("malformed cloud-init data") )
Functions ¶
func IsCloudConfig ¶
IsCloudConfig checks if the given userdata is a cloud-config
Types ¶
type CloudInitPatcher ¶
type CloudInitPatcher struct {
// contains filtered or unexported fields
}
CloudInitPatcher is a helper to patch cloud-init userdata
func NewCloudInitPatcher ¶
func NewCloudInitPatcher(rawUserData string) (*CloudInitPatcher, error)
NewCloudInitPatcher returns a new CloudInitPatcher instance from a base64 encoded string
func NewCloudInitPatcherWithSubstitutions ¶
func NewCloudInitPatcherWithSubstitutions(rawUserData string, identifier substitution.Identifier, substitutions []substitution.Substitution, globalState *substitution.GlobalState) (*CloudInitPatcher, error)
NewCloudInitPatcherWithSubstitutions returns a new CloudInitPatcher instance with a list of substitutions
func (*CloudInitPatcher) Encode ¶
func (c *CloudInitPatcher) Encode() string
Encode returns the base64 encoded cloud-init data
func (*CloudInitPatcher) Get ¶
func (c *CloudInitPatcher) Get(key string) any
Get returns the value of a key in the cloud-init data
func (*CloudInitPatcher) GetEnv ¶
func (c *CloudInitPatcher) GetEnv(key string) string
GetEnv returns the value of an environment variable in the cloud-init data
func (*CloudInitPatcher) Patch ¶
func (c *CloudInitPatcher) Patch(key string, value any) *CloudInitPatcher
Patch adds or modifies a key-value pair in the cloud-init data
func (*CloudInitPatcher) SetEnv ¶
func (c *CloudInitPatcher) SetEnv(key string, value string) *CloudInitPatcher
SetEnv sets an environment variable in the cloud-init data within the "environment" key
func (*CloudInitPatcher) String ¶
func (c *CloudInitPatcher) String() string
String returns the cloud-init data as a string