generate

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	InputDirTemplateFile  = "input_dir"
	OutputDirTemplateFile = "output_dir"
)
View Source
const (
	// DeployKFOutputMarker is the name of the marker file that is created by deployKF in output directories,
	// the presence of this file indicates that the directory is safe to clean.
	DeployKFOutputMarker = ".deploykf_output"
)

Variables

This section is empty.

Functions

func CleanOutputDirectory

func CleanOutputDirectory(outputDir string) error

CleanOutputDirectory cleans the output directory if it's safe to do so.

func CopyFolder

func CopyFolder(src, dest string) error

CopyFolder recursively copies the contents of the source folder to the destination folder

func CreateMarkerFile

func CreateMarkerFile(outputDir string, sourceVersion string, sourcePath string, sourceHash string, cliVersion string) error

CreateMarkerFile creates a marker file with RunInfo JSON in the output directory.

func DirectoryExists

func DirectoryExists(dir string) (bool, error)

func FileExists

func FileExists(file string) (bool, error)

func GetGeneratorSchemaVersion

func GetGeneratorSchemaVersion(markerPath string) (string, error)

GetGeneratorSchemaVersion returns the `generator_schema` version from the specified marker file.

func HashPath

func HashPath(path string, ignoreNames []string) (string, error)

HashPath takes a path as input and returns the SHA-256 hash of the path. If the path is a file, it computes the hash of the file. If the path is a folder, it computes the hash of all files within the folder. It accepts an additional argument 'ignoreNames' which is a slice of file names to ignore.

func PathExists

func PathExists(path string) (isDir bool, isFile bool, err error)

func UnzipFile

func UnzipFile(zipFilePath string, targetDir string, extractPath string) error

UnzipFile extracts the contents of a .zip file to a destination directory extractPath is the relative path inside the zip archive that should be extracted If extractPath does not match any files or directories in the zip archive, an error is returned

func VerifyGeneratorSource

func VerifyGeneratorSource(templatesPath string, helpersPath string, defaultValuesPath string, markerPath string) error

VerifyGeneratorSource verifies that the specified paths make a valid generator source, and that this version of the CLI supports the generator schema version.

func WriteRuntimeTemplates

func WriteRuntimeTemplates(runtimeTemplatePath string, inputDirConfig string, outputDirConfig string) error

WriteRuntimeTemplates writes the runtime templates to the specified directory

Types

type GeneratorMarker

type GeneratorMarker struct {
	GeneratorSchema string `json:"generator_schema"`
}

type RunInfo

type RunInfo struct {
	GeneratedAt   string `json:"generated_at"`
	SourceVersion string `json:"source_version,omitempty"`
	SourcePath    string `json:"source_path,omitempty"`
	SourceHash    string `json:"source_hash,omitempty"`
	CLIVersion    string `json:"cli_version"`
}

type SourceHelper

type SourceHelper struct {
	GithubOwner             string // the owner of the generator source GitHub repository
	GithubRepo              string // the name of the generator source GitHub repository
	GeneratorArtifactPrefix string // the file-prefix of the generator source zip artifact
	GeneratorArtifactSuffix string // the file-suffix of the generator source zip artifact
	AssetsCacheDir          string // the sub-path under `os.UserHomeDir()` where zip artifacts will be cached
}

func NewSourceHelper

func NewSourceHelper(opts ...SourceHelperOptions) *SourceHelper

func (*SourceHelper) DownloadAndUnpackSource

func (h *SourceHelper) DownloadAndUnpackSource(version string, unpackTargetDir string, out io.Writer) (string, error)

DownloadAndUnpackSource downloads the generator source artifact for the specified version (if it's not already cached), unpacks it to the provided folder, then returns the local path of the artifact .zip file.

type SourceHelperOptions

type SourceHelperOptions func(*SourceHelper)

func WithGithubOwner

func WithGithubOwner(owner string) SourceHelperOptions

func WithGithubRepo

func WithGithubRepo(repo string) SourceHelperOptions

Jump to

Keyboard shortcuts

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