cloudinit

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cloudinit implements write_files and runcmd directives of cloudinit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdRunner

type CmdRunner struct {
}

CmdRunner default implementer of ICmdRunner TODO reevaluate empty interface/struct

func (CmdRunner) RunCmd

func (r CmdRunner) RunCmd(ctx context.Context, cmd string) error

RunCmd executes the command string

type FileWriter

type FileWriter struct {
}

FileWriter default implementation of IFileWriter

func (FileWriter) MkdirIfNotExists

func (w FileWriter) MkdirIfNotExists(dirName string) error

MkdirIfNotExists creates the directory if it does not exist already

func (FileWriter) WriteToFile

func (w FileWriter) WriteToFile(file *Files) error

WriteToFile writes contents to file with appropriate permissions as provided in the write_files directive of cloud-config file

type Files

type Files struct {
	Path        string `json:"path,"`
	Encoding    string `json:"encoding,omitempty"`
	Owner       string `json:"owner,omitempty"`
	Permissions string `json:"permissions,omitempty"`
	Content     string `json:"content"`
	Append      bool   `json:"append,omitempty"`
}

Files details required for files written by bootstrap script

type ICmdRunner

type ICmdRunner interface {
	RunCmd(context.Context, string) error
}

type IFileWriter

type IFileWriter interface {
	MkdirIfNotExists(string) error
	WriteToFile(*Files) error
}

type ITemplateParser

type ITemplateParser interface {
	ParseTemplate(string) (string, error)
}

type ScriptExecutor

type ScriptExecutor struct {
	WriteFilesExecutor    IFileWriter
	RunCmdExecutor        ICmdRunner
	ParseTemplateExecutor ITemplateParser
}

ScriptExecutor bootstrap script executor

func (ScriptExecutor) Execute

func (se ScriptExecutor) Execute(bootstrapScript string) error

Execute performs the following operations on the bootstrap script

  • parse the script to get the cloudinit data
  • execute the write_files directive
  • execute the run_cmd directive

type TemplateParser

type TemplateParser struct {
	Template interface{}
}

TemplateParser cloudinit templates parsing using ITemplateParser

func (TemplateParser) ParseTemplate

func (tp TemplateParser) ParseTemplate(templateContent string) (string, error)

ParseTemplate parses and returns the parsed template content

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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