files

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error code
	ErrUnsupportedExtensionCode                = "replace_me"
	ErrUnsupportedExtensionForOperationCode    = "replace_me"
	ErrFailedToIdentifyFileCode                = "replace_me"
	ErrSanitizingFileCode                      = "replace_me"
	ErrInvalidYamlCode                         = "replace_me"
	ErrInvalidJsonCode                         = "replace_me"
	ErrFailedToExtractTarCode                  = "replace_me"
	ErrUnsupportedFileTypeCode                 = "replace_me"
	ErrInvalidKubernetesManifestCode           = "replace_me"
	ErrInvalidMesheryDesignCode                = "replace_me"
	ErrInvalidHelmChartCode                    = "replace_me"
	ErrInvalidDockerComposeCode                = "replace_me"
	ErrInvalidKustomizationCode                = "replace_me"
	ErrFileTypeNotSupportedForDesignConversion = "replace_me"
)
View Source
var (
	ErrNoTarInsideOCICode        = "replace_me"
	ErrEmptyOCIImageCode         = "replace_me"
	ErrUnCompressOCIArtifactCode = "replace_me"
	ErrWaklingLocalDirectoryCode = "replace_me"
	ErrDecodePatternCode         = "replace_me"
)
View Source
var ValidHelmChartFileExtensions = map[string]bool{
	".tar":    true,
	".tgz":    true,
	".gz":     true,
	".tar.gz": true,
	".zip":    true,
}
View Source
var ValidIacExtensions = map[string]bool{
	".yml":     true,
	".yaml":    true,
	".json":    true,
	".tar":     true,
	".tar.gz":  true,
	".tar.tgz": true,
	".zip":     true,
	".gz":      true,
}
View Source
var ValidKustomizeFileExtensions = map[string]bool{
	".yml":    true,
	".yaml":   true,
	".tar":    true,
	".tgz":    true,
	".gz":     true,
	".tar.gz": true,
	".zip":    true,
}

Functions

func ConvertDockerComposeToKubernetesManifest

func ConvertDockerComposeToKubernetesManifest(file IdentifiedFile) (string, error)

func ConvertHelmChartToKubernetesManifest

func ConvertHelmChartToKubernetesManifest(file IdentifiedFile) (string, error)

func ConvertKustomizeToKubernetesManifest added in v0.8.11

func ConvertKustomizeToKubernetesManifest(file IdentifiedFile) (string, error)

func ErrDecodePattern

func ErrDecodePattern(err error) error

func ErrEmptyOCIImage

func ErrEmptyOCIImage(err error) error

func ErrFailedToExtractArchive

func ErrFailedToExtractArchive(fileName string, err error) error

func ErrFailedToIdentifyFile

func ErrFailedToIdentifyFile(fileName string, fileExt string, identificationTrace map[string]error) error

func ErrInvalidDockerCompose

func ErrInvalidDockerCompose(fileName string, err error) error

func ErrInvalidHelmChart

func ErrInvalidHelmChart(fileName string, err error) error

func ErrInvalidJson

func ErrInvalidJson(fileName string, err error) error

func ErrInvalidKubernetesManifest

func ErrInvalidKubernetesManifest(fileName string, err error) error

func ErrInvalidKustomization

func ErrInvalidKustomization(fileName string, err error) error

func ErrInvalidYaml

func ErrInvalidYaml(fileName string, err error) error

func ErrNoTarInsideOCi

func ErrNoTarInsideOCi() error

func ErrUnCompressOCIArtifact

func ErrUnCompressOCIArtifact(err error) error

func ErrUnsupportedExtension

func ErrUnsupportedExtension(fileName string, fileExt string, supportedExtensionsMap map[string]bool) error

func ErrUnsupportedExtensionForOperation

func ErrUnsupportedExtensionForOperation(operation string, fileName string, fileExt string, supportedExtensions []string) error

func ErrUnsupportedFileTypeForConversionToDesign

func ErrUnsupportedFileTypeForConversionToDesign(fileName string, fileType string) error

func ErrWaklingLocalDirectory

func ErrWaklingLocalDirectory(err error) error

func ExtractTar

func ExtractTar(reader io.Reader, archiveFile string, outputDir string) error

ExtractTar extracts a .tar, .tar.gz, or .tgz file into a temporary directory and returns the directory.

func ExtractZipFromBytes

func ExtractZipFromBytes(data []byte, outputDir string) error

ExtractZipFromBytes takes a []byte representing a ZIP file and extracts it to the specified output directory.

func FindChartDir

func FindChartDir(root string) (string, error)

findChartDir uses filepath.Glob to locate Chart.yaml in nested directories

func GetFirstTopLevelDir

func GetFirstTopLevelDir(extractedPath string) (string, error)

get the root dir from the extractedPath if multiple entries are found in the extractedPath then treat extractedPath as root

func IsValidJson

func IsValidJson(data []byte) error

func IsValidYaml

func IsValidYaml(data []byte) error

func ParseCompressedOCIArtifactIntoDesign

func ParseCompressedOCIArtifactIntoDesign(artifact []byte) (*pattern.PatternFile, error)

func ParseFileAsDockerComposeStrict

func ParseFileAsDockerComposeStrict(file SanitizedFile) (*dockerTypes.Config, error)

ParseFileAsDockerCompose parses a Docker Compose file into a types.Config struct.

func ParseFileAsHelmChart

func ParseFileAsHelmChart(file SanitizedFile) (*chart.Chart, error)

ParseFileAsHelmChart loads a Helm chart from the extracted directory.

func ParseFileAsKubernetesManifest

func ParseFileAsKubernetesManifest(file SanitizedFile) ([]runtime.Object, error)

func ParseFileAsKustomization

func ParseFileAsKustomization(file SanitizedFile) (resmap.ResMap, error)

ParseFileAsKustomization processes a sanitized file and returns a Kustomize ResMap

func ParseFileAsMesheryDesign

func ParseFileAsMesheryDesign(file SanitizedFile) (pattern.PatternFile, error)

Types

type IdentifiedFile

type IdentifiedFile struct {
	Type string

	// pattern.PatternFile (meshery-design),
	// []runtime.Object (k8s manifest) ,
	// *chart.Chart (helm-chart),
	// resmap.ResMap (kustomize),
	// dockerTypes.Config (docker-compose) etc
	ParsedFile interface{}
}

func IdentifyFile

func IdentifyFile(sanitizedFile SanitizedFile) (IdentifiedFile, error)

type ParsedCompose

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

func ParseFileAsDockerCompose

func ParseFileAsDockerCompose(file SanitizedFile) (ParsedCompose, error)

ParseFileAsDockerCompose parses a Docker Compose file into a types.Config struct.

type SanitizedFile

type SanitizedFile struct {
	FileExt  string
	FileName string
	RawData  []byte
	// incase of bundle like tar
	ExtractedContentPath string
}

func SanitizeBundle

func SanitizeBundle(data []byte, fileName string, ext string, tempDir string) (SanitizedFile, error)

func SanitizeFile

func SanitizeFile(data []byte, fileName string, tempDir string, validExts map[string]bool) (SanitizedFile, error)

Jump to

Keyboard shortcuts

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