utils

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FailedToDownloadChart = errors.New("failed to download chart")
)

Functions

This section is empty.

Types

type CustomGlobber

type CustomGlobber struct{}

func (CustomGlobber) Glob

func (g CustomGlobber) Glob(pattern string) ([]string, error)

type OsFileReader

type OsFileReader struct{}

func (OsFileReader) ReadFile

func (r OsFileReader) ReadFile(file string) []byte

type RealCmdRunner

type RealCmdRunner struct{}

func (*RealCmdRunner) Run

func (r *RealCmdRunner) Run(cmd string, args ...string) (string, string, error)

type RealHelmChartProcessor

type RealHelmChartProcessor struct {
	Log *logging.Logger
}

func (RealHelmChartProcessor) DownloadHelmChart

func (g RealHelmChartProcessor) DownloadHelmChart(cmdRunner interfaces.CmdRunner, globber interfaces.Globber, cacheDir, repoUrl, chartName, targetRevision string, repoCredentials []models.RepoCredentials) error

DownloadHelmChart fetches a specified version of a Helm chart from a given repository URL and stores it in a cache directory. The function leverages the provided CmdRunner to execute the helm pull command and Globber to deal with possible non-standard chart naming. If the chart is already present in the cache, the function just logs the information and doesn't download it again. The function is designed to handle potential errors during directory creation, globbing, and Helm chart downloading. Any critical error during these operations terminates the program.

func (RealHelmChartProcessor) ExtractHelmChart

func (g RealHelmChartProcessor) ExtractHelmChart(cmdRunner interfaces.CmdRunner, globber interfaces.Globber, chartName, chartVersion, chartLocation, tmpDir, targetType string) error

ExtractHelmChart extracts a specific version of a Helm chart from a cache directory and stores it in a temporary directory. The function uses the provided CmdRunner to execute the tar command and Globber to match the chart file in the cache. If multiple files matching the pattern are found, an error is returned. The function logs any output (standard or error) from the tar command. Any critical error during these operations, like directory creation or extraction failure, terminates the program.

func (RealHelmChartProcessor) GenerateValuesFile

func (g RealHelmChartProcessor) GenerateValuesFile(chartName, tmpDir, targetType, values string, valuesObject map[string]interface{}) error

GenerateValuesFile creates a Helm values file for a given chart in a specified directory. It takes a chart name, a temporary directory for storing the file, the target type categorizing the application, and the content of the values file in string format. The function first attempts to create the file. If an error occurs, it terminates the program. Next, it writes the values string to the file. If an error occurs during this process, the program is also terminated.

func (RealHelmChartProcessor) RenderAppSource

func (g RealHelmChartProcessor) RenderAppSource(cmdRunner interfaces.CmdRunner, releaseName, chartName, chartVersion, tmpDir, targetType string) error

RenderAppSource uses the Helm CLI to render the templates of a given chart. It takes a cmdRunner to run the Helm command, a release name for the Helm release, the chart name and version, a temporary directory for storing intermediate files, and the target type which categorizes the application. The function constructs the Helm command with the provided arguments, runs it, and checks for any errors. If there are any errors, it returns them. Otherwise, it returns nil.

type RealOsFs

type RealOsFs struct{}

func (*RealOsFs) CreateTemp

func (r *RealOsFs) CreateTemp(dir, pattern string) (f *os.File, err error)

func (*RealOsFs) Remove

func (r *RealOsFs) Remove(name string) error

Jump to

Keyboard shortcuts

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