fs

package
v0.0.0-...-d9bc4c4 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fs exports functionality related to all of the cos-customizer state stored on the file system.

Index

Constants

View Source
const (
	// ScratchDir is used for temp files and the like.
	ScratchDir = "/tmp"
)

Variables

This section is empty.

Functions

func AppendStateFile

func AppendStateFile(stateFile string, buildContext BuildContext, script string, env string) error

AppendStateFile appends an entry to the state file. The state file encodes a sequence of scripts to run on the preload instance.

func ArchiveHasObject

func ArchiveHasObject(archive string, path string) (bool, error)

ArchiveHasObject determines if the given tar archive contains the given object.

func CopyRecursive

func CopyRecursive(src string, dst string) error

CopyRecursive calls 'cp -r <src> <dst>'.

func CreateBuildContextArchive

func CreateBuildContextArchive(src, dst string) error

CreateBuildContextArchive creates a tar archive of the given build context.

func CreatePersistentBuiltinContext

func CreatePersistentBuiltinContext(files *Files) error

CreatePersistentBuiltinContext copies the contents of the builtin build context to a persistent location.

func CreateStateFile

func CreateStateFile(files *Files) error

CreateStateFile creates the state file.

func StateFileContains

func StateFileContains(stateFile string, buildContext BuildContext, script string) (bool, error)

StateFileContains checks if an entry exists in the state file with the given build context and the given script name.

Types

type BuildContext

type BuildContext string

BuildContext represents the different types of build contexts that are understood by the system.

const (
	// User represents the user build context.
	User BuildContext = "user"
	// Builtin represents the builtin build context.
	Builtin BuildContext = "builtin"
)

type Files

type Files struct {

	// UserBuildContextArchive points to the tar archive of the user build context.
	// The user build context contains user provided scripts and files that users can use during preloading.
	UserBuildContextArchive string
	// BuiltinBuildContextArchive points to the tar archive of the builtin build context.
	// The builtin build context contains scripts and files used by cos-customizer build steps.
	BuiltinBuildContextArchive string
	// PersistBuiltinBuildContext points to the directory containing the persistent builtin build context.
	// The persistent builtin build context persists across build steps.
	PersistBuiltinBuildContext string
	// StateFile points to the state file. This file encodes the sequence of instructions that need
	// to be executed on the preload VM.
	StateFile string
	// SourceImageConfig points to the source image configuration.
	SourceImageConfig string
	// BuildConfig points to the image build process configuration.
	BuildConfig string
	// DaisyWorkflow points to the Daisy workflow to template and use for preloading.
	DaisyWorkflow string
	// StartupScript points to the startup script that needs to run on the preload VM.
	StartupScript string
	// SystemdService points to the systemd service that needs to invoke the startup script on the preload VM.
	SystemdService string
	// VolatileBuiltinBuildContext points to the directory containing the volatile builtin build context.
	// The volatile builtin build context does not persist across build steps; changes made by one
	// build step are not seen by other build steps.
	VolatileBuiltinBuildContext string
	// DaisyBin points to the Daisy binary.
	DaisyBin string
	// contains filtered or unexported fields
}

Files stores important file paths.

func DefaultFiles

func DefaultFiles(persistentDir string) *Files

DefaultFiles builds a Files struct with a default file layout.

func (*Files) CleanupAllPersistent

func (f *Files) CleanupAllPersistent() error

CleanupAllPersistent deletes everything in the persistent directory.

Jump to

Keyboard shortcuts

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