Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAndCopyCustomizations(customizationsPath string)
- func CleanAndFindCommonDirectory(paths []string) string
- func ConvertInterfaceToSliceOfStrings(xI interface{}) ([]string, error)
- func CopyCustomizationsAssetsData(customizationsPath string) (err error)
- func CopyEmbedFSToDir(embedFS embed.FS, source, dest string, permissions map[string]int) (err error)
- func CopyFile(dst, src string) error
- func CreateAssetsData(assetsFS embed.FS, permissions map[string]int) (assetsPath string, tempPath string, err error)
- func FindCommonDirectory(paths []string) string
- func GatherGitInfo(path string) (repoName, repoDir, repoHostName, repoURL, repoBranch string, err error)
- func GetClosestMatchingString(options []string, searchstring string) string
- func GetFilesByExt(inputPath string, exts []string) ([]string, error)
- func GetFilesByName(inputPath string, names []string, nameRegexes []string) ([]string, error)
- func GetFilesInCurrentDirectory(path string, fileNames, fileNameRegexes []string) (files []string, err error)
- func GetImageNameAndTag(image string) (string, string)
- func GetMapInterfaceFromObj(obj interface{}) (mapobj interface{}, err error)
- func GetObjFromInterface(obj interface{}, loadinto interface{}) error
- func GetRuntimeObjectMetadata(obj runtime.Object) metav1.ObjectMeta
- func GetSHA256Hash(s string) string
- func GetStringFromTemplate(tpl string, config interface{}) (string, error)
- func GetUnixPath(path string) string
- func GetWindowsPath(path string) string
- func Interrupt() error
- func IsInt32Present(list []int32, value int32) bool
- func IsIntPresent(list []int, value int) bool
- func IsParent(child, parent string) bool
- func IsSameRuntimeObject(obj1, obj2 runtime.Object) bool
- func IsStringPresent(list []string, value string) bool
- func MakeFileNameCompliant(name string) string
- func MakeStringContainerImageNameCompliant(s string) string
- func MakeStringDNSLabelNameCompliant(s string) string
- func MakeStringDNSNameCompliant(s string) string
- func MakeStringDNSSubdomainNameCompliant(s string) string
- func MakeStringEnvNameCompliant(s string) string
- func MarshalObjToYaml(obj runtime.Object) ([]byte, error)
- func MergeInt32Slices(slice1 []int32, slice2 []int32) []int32
- func MergeIntSlices(slice1 []int, slice2 []int) []int
- func MergeStringMaps(map1 map[string]string, map2 map[string]string) map[string]string
- func MergeStringSliceMaps(map1 map[string][]string, map2 map[string][]string) map[string][]string
- func MergeStringSlices(slice1 []string, slice2 ...string) []string
- func NormalizeForFilename(name string) string
- func NormalizeForServiceName(svcName string) string
- func ObjectToYamlBytes(data interface{}) ([]byte, error)
- func ReadJSON(file string, data interface{}) error
- func ReadMove2KubeYaml(path string, out interface{}) error
- func ReadMove2KubeYamlStrict(path string, out interface{}, kind string) error
- func ReadXML(file string, data interface{}) error
- func ReadYaml(file string, data interface{}) error
- func ReverseInPlace(xs []string)
- func SplitOnDotExpectInsideQuotes(s string) []string
- func SplitYAML(rawYAML []byte) ([][]byte, error)
- func StripQuotes(s string) string
- func UniqueStrings(xs []string) []string
- func WriteJSON(outputPath string, data interface{}) error
- func WriteYaml(outputPath string, data interface{}) error
- func YamlAttrPresent(path string, attr string) (bool, interface{})
- type CleanupHook
Constants ¶
const ( // DefaultProjectName represents the short app name DefaultProjectName = "myproject" // VolumePrefix defines the prefix to be used for volumes VolumePrefix = "vol" // DefaultStorageClassName defines the default storage class to be used DefaultStorageClassName = "default" // DefaultDirectoryPermission defines the default permission used when a directory is created DefaultDirectoryPermission os.FileMode = 0755 // DefaultExecutablePermission defines the default permission used when an executable file is created DefaultExecutablePermission os.FileMode = 0744 // DefaultFilePermission defines the default permission used when a non-executable file is created DefaultFilePermission os.FileMode = 0644 // DefaultRegistryURL points to the default registry url that will be used DefaultRegistryURL = "quay.io" // ImagePullSecretPrefix is the prefix that will be prepended to pull secret name ImagePullSecretPrefix = "imagepullsecret" // QACacheFile defines the location of the QA cache file QACacheFile = types.AppNameShort + "qacache.yaml" // ConfigFile defines the location of the config file ConfigFile = types.AppNameShort + "config.yaml" // DefaultClusterType defines the default cluster type chosen by plan DefaultClusterType = "Kubernetes" // IgnoreFilename is the name of the file containing the ignore rules and exceptions IgnoreFilename = "." + types.AppNameShort + "ignore" // ExposeSelector tag is used to annotate services that are externally exposed ExposeSelector = types.GroupName + "/service.expose" // WindowsAnnotation tag is used tag a service to run on windows nodes WindowsAnnotation = types.GroupName + "/containertype.windows" // AnnotationLabelValue represents the value when an annotation is valid AnnotationLabelValue = "true" // DefaultServicePort is the default port that will be added to a service. DefaultServicePort int32 = 8080 // TODOAnnotation is used to annotate with TODO tasks TODOAnnotation = types.GroupName + "/todo." )
const ( // Delim is the delimiter used to separate key segments Delim = "." // Special is the special case indicator of the multi-select problems Special = "[]" // MatchAll is used to set the default for a set of keys. Example: move2kube.services.*.ports=[8080] MatchAll = "*" // BaseKey is the prefix for every key BaseKey = types.AppName //ConfigServicesKey represents Services Key ConfigServicesKey = BaseKey + d + "services" //ConfigStoragesKey represents Storages Key ConfigStoragesKey = BaseKey + d + "storages" //ConfigMinReplicasKey represents Ingress host Key ConfigMinReplicasKey = BaseKey + d + "minreplicas" //ConfigPortsForServiceKeySegment represents the ports used for service ConfigPortsForServiceKeySegment = "ports" //ConfigPortForServiceKeySegment represents the port used for service ConfigPortForServiceKeySegment = "port" //ConfigAdditionalPortsForServiceKeySegment represents the ports used for service ConfigAdditionalPortsForServiceKeySegment = "additionalports" //ConfigAdditionalPortForServiceKeySegment represents the port used for service ConfigAdditionalPortForServiceKeySegment = "additionalport" //ConfigApacheConfFileForServiceKeySegment represents the conf file used for service ConfigApacheConfFileForServiceKeySegment = "apacheconfig" //ConfigModesKey represents modes Key ConfigModesKey = BaseKey + d + "modes" //ConfigSpawnContainersKey represents modes Key ConfigSpawnContainersKey = BaseKey + d + "spawncontainers" //ConfigTransformersKey represents transformers Key ConfigTransformersKey = BaseKey + d + "transformers" //ConfigTargetKey represents Target Key ConfigTargetKey = BaseKey + d + "target" //ConfigRepoKey represents Repo Key ConfigRepoKey = BaseKey + d + "repo" //ConfigContainerizationKeySegment represents Containerization Key segment ConfigContainerizationKeySegment = BaseKey + d + "containerization" //ConfigRepoKeysKey represents Repo Key ConfigRepoKeysKey = ConfigRepoKey + d + "keys" //ConfigRepoPubKey represents allow load of public key of repos Key ConfigRepoPubKey = ConfigRepoKeysKey + d + "pub" //ConfigRepoLoadPubDomainsKey represents allow load of public key per domain of repos Key ConfigRepoLoadPubDomainsKey = ConfigRepoPubKey + d + "domain" //ConfigRepoLoadPubKey represents allow load of public key of repos Key ConfigRepoLoadPubKey = ConfigRepoPubKey + d + "load" //ConfigRepoPrivKey represents allow load of private key of repos Key ConfigRepoPrivKey = ConfigRepoKeysKey + d + "priv" //ConfigRepoLoadPrivKey represents allow load of private key of repos Key ConfigRepoLoadPrivKey = ConfigRepoKeysKey + d + "load" //ConfigRepoKeyPathsKey represents paths of keyfiles ConfigRepoKeyPathsKey = ConfigRepoKeysKey + d + "paths" //ConfigTransformerTypesKey represents Transformers type Key ConfigTransformerTypesKey = ConfigTransformersKey + d + "types" //ConfigIngressKey represents Ingress Key ConfigIngressKey = ConfigTargetKey + d + "ingress" //ConfigIngressHostKey represents Ingress host Key ConfigIngressHostKey = ConfigIngressKey + d + "host" //ConfigIngressTLSKey represents ingress tls Key ConfigIngressTLSKey = ConfigIngressKey + d + "tls" //ConfigTargetClusterTypeKey represents target cluster type key ConfigTargetClusterTypeKey = ConfigTargetKey + d + "clustertype" //ConfigImageRegistryKey represents image registry Key ConfigImageRegistryKey = ConfigTargetKey + d + "imageregistry" //ConfigTargetExistingVersionUpdate represents key which how to update versions ConfigTargetExistingVersionUpdate = ConfigTargetKey + d + "existingversionupdate" //ConfigImageRegistryURLKey represents image registry url Key ConfigImageRegistryURLKey = ConfigImageRegistryKey + d + "url" //ConfigImageRegistryNamespaceKey represents image registry namespace Key ConfigImageRegistryNamespaceKey = ConfigImageRegistryKey + d + "namespace" //ConfigImageRegistryLoginTypeKey represents image registry login type Key ConfigImageRegistryLoginTypeKey = ConfigImageRegistryKey + d + "logintype" //ConfigImageRegistryPullSecretKey represents image registry pull secret Key ConfigImageRegistryPullSecretKey = ConfigImageRegistryKey + d + "pullsecret" //ConfigImageRegistryUserNameKey represents image registry login Username Key ConfigImageRegistryUserNameKey = ConfigImageRegistryKey + d + "username" //ConfigImageRegistryPasswordKey represents image registry login Password Key ConfigImageRegistryPasswordKey = ConfigImageRegistryKey + d + "password" //ConfigStoragesPVCForHostPathKey represents key for PVC for Host Path ConfigStoragesPVCForHostPathKey = ConfigStoragesKey + d + "pvcforhostpath" //ConfigStoragesPerClaimStorageClassKey represents key for having different storage class for claim ConfigStoragesPerClaimStorageClassKey = ConfigStoragesKey + d + "perclaimstorageclass" //ConfigServicesNamesKey represents Storages Key ConfigServicesNamesKey = ConfigServicesKey + d + Special + d + "enable" //ConfigContainerizationTypesKey represents source type Key ConfigContainerizationTypesKey = ConfigContainerizationKeySegment + d + "types" //ConfigServicesExposeKey represents Services Expose Key ConfigServicesExposeKey = ConfigServicesKey + d + Special + d + "expose" )
const ( // ServiceKind defines Service Kind ServiceKind = "Service" // DeploymentKind defines Deployment Kind DeploymentKind = "Deployment" // IngressKind defines Ingress Kind IngressKind = "Ingress" )
const ( // DefaultPlanFile defines default name for plan file DefaultPlanFile = types.AppNameShort + ".plan" // TempDirPrefix defines the prefix of the temp directory TempDirPrefix = types.AppNameShort + "-" // AssetsDir defines the dir of the assets temp directory AssetsDir = types.AppNameShort + "assets" // TransformDir defines the dir of the assets temp directory TransformDir = "transform" // ScriptsDir defines the directory where the output scripts are placed ScriptsDir = "scripts" // DefaultSourceDir defines the directory where the source files and folders are placed along with build scripts for each individual image DefaultSourceDir = "source" // DeployDir defines the directory where the deployment artifacts are placed DeployDir = "deploy" // CICDDir defines the directory where the deployment artifacts are placed CICDDir = "cicd" // HelmDir defines the directory where the helm charts are placed HelmDir = "helm-charts" // OCTemplatesDir defines the directory where the openshift templates are placed OCTemplatesDir = "openshift-templates" )
const (
// DefaultDockerfileName refers to the default Dockerfile name
DefaultDockerfileName = "Dockerfile"
)
Variables ¶
var (
// DefaultPVCSize stores the default PVC size
DefaultPVCSize, _ = resource.ParseQuantity("100Mi")
// IgnoreEnvironment indicates whether to ignore the current environment or not
IgnoreEnvironment = false
// DefaultIgnoreDirRegexps specifies directory name regexes that would be ignored
DefaultIgnoreDirRegexps = []*regexp.Regexp{regexp.MustCompile("[.].*")}
)
var ( // TempPath defines where all app data get stored during execution TempPath = TempDirPrefix + "temp" // AssetsPath defines where all assets get stored during execution AssetsPath = filepath.Join(TempPath, AssetsDir) )
var PlanProgressNumBaseDetectTransformers = 0
PlanProgressNumBaseDetectTransformers keeps track of the number of transformers that finished base directory detect during planning
var PlanProgressNumDirectories = 0
PlanProgressNumDirectories keeps track of the number of files/folders analyzed during planning
Functions ¶
func CheckAndCopyCustomizations ¶
func CheckAndCopyCustomizations(customizationsPath string)
CheckAndCopyCustomizations checks if the customizations path is an existing directory and copies to assets
func CleanAndFindCommonDirectory ¶
CleanAndFindCommonDirectory finds the common ancestor directory among a list of absolute paths. Cleans the paths you give it before finding the directory. Also see FindCommonDirectory
func ConvertInterfaceToSliceOfStrings ¶ added in v0.2.0
ConvertInterfaceToSliceOfStrings converts an interface{} to a []string type. It can handle []interface{} as long as all the values are strings.
func CopyCustomizationsAssetsData ¶
CopyCustomizationsAssetsData copies an customizations to the assets directory
func CopyEmbedFSToDir ¶
func CopyEmbedFSToDir(embedFS embed.FS, source, dest string, permissions map[string]int) (err error)
CopyEmbedFSToDir converts a string into a directory
func CopyFile ¶
CopyFile copies a file from src to dst. The dst file will be truncated if it exists. Returns an error if it failed to copy all the bytes.
func CreateAssetsData ¶
func CreateAssetsData(assetsFS embed.FS, permissions map[string]int) (assetsPath string, tempPath string, err error)
CreateAssetsData creates an assets directory and dumps the assets data into it
func FindCommonDirectory ¶
FindCommonDirectory finds the common ancestor directory among a list of cleaned absolute paths. Will not clean the paths you give it before trying to find the directory. Also see CleanAndFindCommonDirectory
func GatherGitInfo ¶
func GatherGitInfo(path string) (repoName, repoDir, repoHostName, repoURL, repoBranch string, err error)
GatherGitInfo tries to find the git repo for the path if one exists.
func GetClosestMatchingString ¶
GetClosestMatchingString returns the closest matching string for a given search string
func GetFilesByExt ¶
GetFilesByExt returns files by extension
func GetFilesByName ¶
GetFilesByName returns files by name
func GetFilesInCurrentDirectory ¶
func GetFilesInCurrentDirectory(path string, fileNames, fileNameRegexes []string) (files []string, err error)
GetFilesInCurrentDirectory returns the name of the file present in the current directory which matches the pattern
func GetImageNameAndTag ¶
GetImageNameAndTag splits an image full name and returns the image name and tag
func GetMapInterfaceFromObj ¶
func GetMapInterfaceFromObj(obj interface{}) (mapobj interface{}, err error)
GetMapInterfaceFromObj converts a struct to map[string]interface{} using yaml marshaller
func GetObjFromInterface ¶
func GetObjFromInterface(obj interface{}, loadinto interface{}) error
GetObjFromInterface loads from map[string]interface{} to struct
func GetRuntimeObjectMetadata ¶ added in v0.2.0
func GetRuntimeObjectMetadata(obj runtime.Object) metav1.ObjectMeta
GetRuntimeObjectMetadata returns the metadata field from a k8s object.
func GetSHA256Hash ¶
GetSHA256Hash returns the SHA256 hash of the string. The hash is 256 bits/32 bytes and encoded as a 64 char hexadecimal string.
func GetStringFromTemplate ¶
GetStringFromTemplate returns string for a template
func GetWindowsPath ¶
GetWindowsPath return Windows Path for any path
func IsInt32Present ¶
IsInt32Present checks if a value is present in a slice
func IsIntPresent ¶
IsIntPresent checks if a value is present in a slice
func IsParent ¶ added in v0.2.0
IsParent can be used to check if a path is one of the parent directories of another path. Also returns true if the paths are the same.
func IsSameRuntimeObject ¶ added in v0.2.0
IsSameRuntimeObject returns true if the 2 k8s resources are same. 2 resources are the same if they have the same group, version, kind, namespace and name. Also prints an error if the 2 objects have the same kind, namespace and name but different group versions.
func IsStringPresent ¶
IsStringPresent checks if a value is present in a slice
func MakeFileNameCompliant ¶
MakeFileNameCompliant returns a DNS-1123 standard string Motivated by https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set Also see page 1 "ASSUMPTIONS" heading of https://tools.ietf.org/html/rfc952 Also see page 13 of https://tools.ietf.org/html/rfc1123#page-13
func MakeStringContainerImageNameCompliant ¶
MakeStringContainerImageNameCompliant makes the string into a valid image name.
func MakeStringDNSLabelNameCompliant ¶
MakeStringDNSLabelNameCompliant makes the string a valid DNS label name. See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names 1. contain at most 63 characters 2. contain only lowercase alphanumeric characters or '-' 3. start with an alphanumeric character 4. end with an alphanumeric character
func MakeStringDNSNameCompliant ¶
MakeStringDNSNameCompliant makes the string into a valid DNS name.
func MakeStringDNSSubdomainNameCompliant ¶
MakeStringDNSSubdomainNameCompliant makes the string a valid DNS subdomain name. See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names 1. contain no more than 253 characters 2. contain only lowercase alphanumeric characters, '-' or '.' 3. start with an alphanumeric character 4. end with an alphanumeric character
func MakeStringEnvNameCompliant ¶
MakeStringEnvNameCompliant makes the string into a valid Environment variable name.
func MarshalObjToYaml ¶ added in v0.2.0
MarshalObjToYaml marshals an object to yaml
func MergeInt32Slices ¶
MergeInt32Slices merges two int slices
func MergeIntSlices ¶
MergeIntSlices merges two int slices
func MergeStringMaps ¶
MergeStringMaps merges two string maps
func MergeStringSliceMaps ¶
MergeStringSliceMaps merges two string slice maps
func MergeStringSlices ¶
MergeStringSlices merges two string slices
func NormalizeForFilename ¶
NormalizeForFilename normalizes a string to only filename valid characters
func NormalizeForServiceName ¶
NormalizeForServiceName converts the string to be compatible for service name
func ObjectToYamlBytes ¶ added in v0.2.0
ObjectToYamlBytes encodes an object to yaml
func ReadMove2KubeYaml ¶
ReadMove2KubeYaml reads move2kube specific yaml files (like m2k.plan) into an struct. It checks if apiVersion to see if the group is move2kube and also reports if the version is different from the expected version.
func ReadMove2KubeYamlStrict ¶
ReadMove2KubeYamlStrict is like ReadMove2KubeYaml but returns an error when it finds unknown fields in the yaml
func ReverseInPlace ¶ added in v0.2.0
func ReverseInPlace(xs []string)
ReverseInPlace reverses a slice of strings in place.
func SplitOnDotExpectInsideQuotes ¶ added in v0.2.0
SplitOnDotExpectInsideQuotes splits a string on dot. Stuff inside double or single quotes will not be split.
func StripQuotes ¶ added in v0.2.0
StripQuotes strips a single layer of double or single quotes from the left and right ends Example: "github.com" -> github.com Example: 'github.com' -> github.com Example: "'github.com'" -> 'github.com'
func UniqueStrings ¶
UniqueStrings returns a new slice with only the unique strings from the input slice.
func YamlAttrPresent ¶
YamlAttrPresent returns YAML attributes
Types ¶
type CleanupHook ¶
type CleanupHook struct {
// contains filtered or unexported fields
}
CleanupHook calls the cleanup functions on fatal and panic errors
func NewCleanupHook ¶
func NewCleanupHook(ctxContextFn context.CancelFunc) *CleanupHook
NewCleanupHook creates a cleanup hook
func (*CleanupHook) Fire ¶
func (hook *CleanupHook) Fire(entry *logrus.Entry) error
Fire calls the clean up
func (*CleanupHook) Levels ¶
func (hook *CleanupHook) Levels() []logrus.Level
Levels returns the levels on which the cleanup hook gets called