dir

package
v1.2.27 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// FolderCreationFailedMsg - message raised when folder creation fails because of the existence file with identical name
	FolderCreationFailedMsg = `could not create the "%s" folder because a file exists with the same name`

	// InitLocFailedOnWorkDirMsg - message raised on getting working directory when initializing location
	InitLocFailedOnWorkDirMsg = `could not get working directory`

	// InvalidDescMsg - invalid descriptor
	InvalidDescMsg = `the "%s" descriptor is invalid; expected one of the following values: Dev, Dep`
)
View Source
const (
	//Dep - deployment descriptor
	Dep = "dep"
	//Dev - development descriptor
	Dev = "dev"
	// TempFolderSuffix - temporary folder suffix
	TempFolderSuffix = "_mta_build_tmp"
	// Mtad - deployment descriptor file name
	Mtad = "mtad.yaml"
	// MtarFolder - default archives folder
	MtarFolder = "mta_archives"
	// SBomTempFolderSuffix - sbom temporary folder suffix
	SBomTempFolderSuffix = "_mta_sbom_tmp"
)

Variables

This section is empty.

Functions

func Archive

func Archive(sourcePath, targetArchivePath string, ignore []string) (e error)

Archive module and mtar artifacts, compatible with the JAR specification to support the spec requirements Source Path to be zipped Target artifact

func CloseFile

func CloseFile(file io.Closer, err error) error

CloseFile - closes file error handling takes into account error of the calling function

func CopyByPatterns

func CopyByPatterns(source, target string, patterns []string) error

CopyByPatterns - copy files/directories according to patterns from source folder to target folder patterns are relative to source folder

func CopyDir

func CopyDir(src string, dst string, withParents bool, copyDirEntries func(entries []os.FileInfo, src, dst string) error) error

CopyDir - copy directory content

func CopyEntries

func CopyEntries(entries []os.FileInfo, src, dst string) error

CopyEntries - copies entries (files and directories) from source to destination folder

func CopyEntriesInParallel

func CopyEntriesInParallel(entries []os.FileInfo, src, dst string) (rerr error)

CopyEntriesInParallel - copies entries (files and directories) from source to destination folder in parallel

func CopyFile

func CopyFile(src, dst string) (rerr error)

CopyFile - copy file content

func CopyFileWithMode

func CopyFileWithMode(src, dst string, mode os.FileMode) (rerr error)

CopyFileWithMode - copy file content using file mode parameter

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) error

CreateDirIfNotExist - Create new dir

func CreateFile

func CreateFile(path string) (file *os.File, err error)

CreateFile - create new file

func FindFile added in v1.2.26

func FindFile(root string, filename string) (string, error)

func FindPath added in v0.3.6

func FindPath(path string) (string, error)

FindPath returns the path or its first match in case it's a pattern. If the path doesn't exist an error is returned.

func RemoveIfExist added in v1.2.26

func RemoveIfExist(dir string) error

RemoveDirIfExist - remove dir

func ValidateDeploymentDescriptor

func ValidateDeploymentDescriptor(descriptor string) error

ValidateDeploymentDescriptor validates the deployment descriptor.

func WriteFile added in v0.3.6

func WriteFile(in io.Reader, dst string) (rerr error)

WriteFile - writes file content

Types

type IDescriptor

type IDescriptor interface {
	IsDeploymentDescriptor() bool
	GetDescriptor() string
}

IDescriptor - descriptor interface

type IModule

type IModule interface {
	ISourceModule
	ITargetModule
}

IModule - module interface

type IMtaExtYaml

type IMtaExtYaml interface {
	GetMtaExtYamlPath(platform string) string
}

IMtaExtYaml - MTA Extension Yaml interface

type IMtaParser

type IMtaParser interface {
	ParseFile() (*mta.MTA, error)
}

IMtaParser - MTA Parser interface

type IMtaYaml

type IMtaYaml interface {
	GetMtaYamlFilename() string
	GetMtaYamlPath() string
}

IMtaYaml - MTA Yaml interface

type ISourceModule

type ISourceModule interface {
	GetSourceModuleDir(modulePath string) string
	GetSourceModuleArtifactRelPath(modulePath, artifactPath string) (string, error)
}

ISourceModule - source module interface

type ITargetArtifacts

type ITargetArtifacts interface {
	GetMetaPath() string
	GetMtadPath() string
	GetManifestPath() string
	GetMtarDir(targetProvided bool) string
}

ITargetArtifacts - target artifacts interface

type ITargetModule

type ITargetModule interface {
	GetTargetModuleDir(moduleName string) string
	GetTargetTmpRoot() string
}

ITargetModule - Target Module interface

type ITargetPath

type ITargetPath interface {
	GetTarget() string
	GetTargetTmpDir() string
}

ITargetPath - target path interface

type Loc

type Loc struct {
	// SourcePath - Path to MTA project
	SourcePath string
	// TargetPath - Path to results
	TargetPath string
	// MtaFilename - MTA yaml filename "mta.yaml" by default
	MtaFilename string
	// Descriptor - indicator of deployment descriptor usage (mtad.yaml)
	Descriptor string
	// ExtensionFileNames - list of MTA extension descriptors (could be empty)
	ExtensionFileNames []string
}

Loc - MTA tool file properties

func Location

func Location(source, target, descriptor string, extensions []string, wdGetter func() (string, error)) (*Loc, error)

Location - provides Location parameters of MTA

func (*Loc) GetDescriptor

func (ep *Loc) GetDescriptor() string

GetDescriptor - gets descriptor type of Location

func (*Loc) GetExtensionFilePaths added in v0.3.0

func (ep *Loc) GetExtensionFilePaths() []string

GetExtensionFilePaths returns the MTA extension descriptor full paths

func (*Loc) GetManifestPath

func (ep *Loc) GetManifestPath() string

GetManifestPath gets the path to the generated manifest file.

func (*Loc) GetMetaPath

func (ep *Loc) GetMetaPath() string

GetMetaPath gets the path to the generated META-INF directory.

func (*Loc) GetMtaExtYamlPath

func (ep *Loc) GetMtaExtYamlPath(extFileName string) string

GetMtaExtYamlPath gets the full MTA extension file path by file name or path. If the file name is an absolute path it's returned as is. Otherwise the returned path is relative to the source folder.

func (*Loc) GetMtaYamlFilename

func (ep *Loc) GetMtaYamlFilename() string

GetMtaYamlFilename - Gets the MTA .yaml file name.

func (*Loc) GetMtaYamlPath

func (ep *Loc) GetMtaYamlPath() string

GetMtaYamlPath gets the MTA .yaml file path.

func (*Loc) GetMtadPath

func (ep *Loc) GetMtadPath() string

GetMtadPath gets the path to the generated MTAD file.

func (*Loc) GetMtarDir

func (ep *Loc) GetMtarDir(targetProvided bool) string

GetMtarDir - gets archive folder if the target folder provided archive will be saved in the target folder otherwise archives folder - "mta_archives" subfolder in the project folder

func (*Loc) GetSBomFileTmpDir added in v1.2.26

func (ep *Loc) GetSBomFileTmpDir(mtaObj *mta.MTA) string

GetSBomFileTmpDir - sbomFileTmpDir is a temp folder under project root

func (*Loc) GetSource

func (ep *Loc) GetSource() string

GetSource gets the processed project path; if it is not provided, use the current directory.

func (*Loc) GetSourceModuleArtifactRelPath added in v1.0.10

func (ep *Loc) GetSourceModuleArtifactRelPath(moduleRelPath, artifactAbsPath string) (string, error)

GetSourceModuleArtifactRelPath gets the relative path to the module's artifact

func (*Loc) GetSourceModuleDir

func (ep *Loc) GetSourceModuleDir(modulePath string) string

GetSourceModuleDir gets the path to the module to be packed. The subdirectory is in the source.

func (*Loc) GetTarget

func (ep *Loc) GetTarget() string

GetTarget gets the target path; if it is not provided, use the path of the processed project.

func (*Loc) GetTargetModuleDir

func (ep *Loc) GetTargetModuleDir(moduleName string) string

GetTargetModuleDir gets the path to the packed module directory. The subdirectory in the temporary target directory is named by the module name.

func (*Loc) GetTargetTmpDir

func (ep *Loc) GetTargetTmpDir() string

GetTargetTmpDir gets the temporary target directory path. The subdirectory in the target folder is named as the source project folder suffixed with "_mta_build_tmp". Subdirectory name is prefixed with "." as a hidden folder

func (*Loc) GetTargetTmpRoot added in v1.2.3

func (ep *Loc) GetTargetTmpRoot() string

GetTargetTmpRoot gets the build results directory root path.

func (*Loc) IsDeploymentDescriptor

func (ep *Loc) IsDeploymentDescriptor() bool

IsDeploymentDescriptor checks whether the flag is related to the deployment descriptor.

func (*Loc) ParseFile

func (ep *Loc) ParseFile() (*mta.MTA, error)

ParseFile returns a reference to the MTA object resulting from the given mta.yaml file merged with the extension descriptors.

type ModuleLoc added in v1.0.10

type ModuleLoc struct {
	// contains filtered or unexported fields
}

ModuleLoc - module location type that provides services for stand alone module build command

func ModuleLocation added in v1.0.10

func ModuleLocation(loc *Loc, targetPathDefined bool) *ModuleLoc

ModuleLocation - provides target location of stand alone MTA module build result

func (*ModuleLoc) GetSourceModuleArtifactRelPath added in v1.0.10

func (ep *ModuleLoc) GetSourceModuleArtifactRelPath(modulePath, artifactPath string) (string, error)

GetSourceModuleArtifactRelPath - gets the relative path to the module artifact The ModuleLoc type is used in context of stand alone module build command and as opposed to the module build command in the context of Makefile saves its build result directly under the target (temporary or specific) without considering the original artifact path in the source folder

func (*ModuleLoc) GetSourceModuleDir added in v1.0.10

func (ep *ModuleLoc) GetSourceModuleDir(modulePath string) string

GetSourceModuleDir - gets the absolute path to the module

func (*ModuleLoc) GetTarget added in v1.0.10

func (ep *ModuleLoc) GetTarget() string

GetTarget - gets the target path

func (*ModuleLoc) GetTargetModuleDir added in v1.0.10

func (ep *ModuleLoc) GetTargetModuleDir(moduleName string) string

GetTargetModuleDir - gets the to module build results

func (*ModuleLoc) GetTargetTmpRoot added in v1.2.3

func (ep *ModuleLoc) GetTargetTmpRoot() string

GetTargetTmpRoot - gets the target root path

func (*ModuleLoc) ParseFile added in v1.0.12

func (ep *ModuleLoc) ParseFile() (*mta.MTA, error)

ParseFile returns a reference to the MTA object resulting from the given mta.yaml file merged with the extension descriptors.

Jump to

Keyboard shortcuts

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