fileutils

package
v0.0.0-...-c9d1064 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

The content of this file was copied from https://stackoverflow.com/questions/51779243/copy-a-folder-in-go

Index

Constants

View Source
const (
	DefaultFileWritePermissions = 0o600
	DefaultDirWritePermissions  = 0o755
	ACMPrefix                   = "acm-"

	SourceCRsDir          = "source-crs"
	KustomizationFileName = "kustomization.yaml"
	NamespaceFileName     = "ns.yaml"
)

Variables

This section is empty.

Functions

func AddDefaultPlacementBindingsToNSFile

func AddDefaultPlacementBindingsToNSFile(namespaceFilePath, outputDir string, policiesNamespaces map[string]bool) (err error)

AddDefaultPlacementBindingsToNSFile Adds the default placement bindings for ACM Policy Generator

func AddSourceCRsInTemplateDir

func AddSourceCRsInTemplateDir(allFilesInInputPath, preRenderSourceCRList []string, inputFile, outputDir string) (err error)

AddSourceCRsInTemplateDir Adds a source-crs directory in each directory containing a template (PGT or ACM policy generator)

func CommentOutMCPLines

func CommentOutMCPLines(inputFile string) (outputFile string, patchList []map[string]interface{}, err error)

CommentOutMCPLines Comments out lines containing the "$mcp" keyword

func Copy

func Copy(src, dst string) (int64, error)

Copy function found at https://opensource.com/article/18/6/copying-files-go

func CopyAndProcessNSAndKustomizationYAML

func CopyAndProcessNSAndKustomizationYAML(nsFilePath, inputFile, outputDir string, skipUpdateNs bool, policiesNamespaces map[string]bool) (err error)

CopyAndProcessNSAndKustomizationYAML Performs post processing on ns.yaml and Kustomization.yaml files

func CopyDirectory

func CopyDirectory(scrDir, dest string) error

CopyDirectory Recursively content of a directory

func CopySourceCrs

func CopySourceCrs(outputDir string, preRenderSourceCRList []string) (err error)

CopySourceCrs Copies source CRs to the output ACMPG Directory

func CopySymLink(source, dest string) error

CopySymLink Copies a symlink

func CreateIfNotExists

func CreateIfNotExists(dir string, perm os.FileMode) error

CreateIfNotExists Creates a directory if it does not exist

func Exists

func Exists(filePath string) bool

Exists Checks if a file exists

func GetAllYAMLFilesInPath

func GetAllYAMLFilesInPath(path string) (files []string, err error)

GetAllYAMLFilesInPath Gets All Yaml files in a path

func GetTemplatePaths

func GetTemplatePaths(baseDir, pgtFilePath, outputDir string) (relativePathTemplate, acmTemplateDir string, err error)

GetTemplatePaths gets the path of - the template relative to the base ipnut directory - the output template full directory

func PrefixLastPathComponent

func PrefixLastPathComponent(originalPath, prefix string) string

PrefixLastPathComponent Prefixes the file referred to by a path with a given prefix

func RenameACMPGsInAllKustomization

func RenameACMPGsInAllKustomization(inputFile, outputDir string) (err error)

RenameACMPGsInAllKustomization Updates all the old PGT names to ACM PolicyGen format in kustomization file

func RenameACMPGsInKustomization

func RenameACMPGsInKustomization(relativeFilePath, inputDir, outputDir string) (err error)

RenameACMPGsInKustomization copy kustomization.yaml to output directory while renaming policies

func RenderMCPLines

func RenderMCPLines(inputFile, mcp string) (outputFile string, err error)

RenderMCPLines Replaces the "$mcp" keyword with the mcp string (worker or master)

Types

type AnnotationsOnly

type AnnotationsOnly struct {
	Metadata MetaData `yaml:"metadata"`
}

func GetAnnotationsOnly

func GetAnnotationsOnly(filePath string) (annotations AnnotationsOnly, err error)

GetAnnotationsOnly Gets the manifest kind from the file

type KindType

type KindType struct {
	Kind string `yaml:"kind"`
}

Type used to parse the Kind of a K8s Manifest

func GetManifestKind

func GetManifestKind(filePath string) (kindType KindType, err error)

GetManifestKind Gets the manifest kind from the file

type Kustomization

type Kustomization struct {
	Generators []string `yaml:"generators,omitempty"`
	Resources  []string `yaml:"resources,omitempty"`
	Bases      []string `yaml:"bases,omitempty"`
}

type MetaData

type MetaData struct {
	Annotations map[string]string `yaml:"annotations,omitempty"`
}

Jump to

Keyboard shortcuts

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