cloudinit

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 14 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 {
}

func (CmdRunner) RunCmd

func (r CmdRunner) RunCmd(cmd string) error

RunCmd executes the command string

type FileWriter

type FileWriter struct {
}

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"`
}

type ICmdRunner

type ICmdRunner interface {
	RunCmd(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
}

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{}
}

func (TemplateParser) ParseTemplate

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

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