Help us shape the future of Go! Take the 2026 Go Developer Survey

charthelper

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailableIcons = func(chart *models.ChartPackage, prefix string) []*IconOutput {
	var res []*IconOutput
	for _, format := range availableFormats {
		exist, err := iconExist(chart, format.Name)
		if err != nil {
			log.WithFields(log.Fields{
				"error":  err,
				"chart":  *chart.Name,
				"format": format.Name,
			}).Error("Error on IconExists")
			continue
		}
		if !exist {
			continue
		}
		path, _ := iconPath(chart, format.Name)
		res = append(res, &IconOutput{
			Name: format.Name,
			Path: staticUrl(path, prefix),
		})
	}
	return res
}

AvailableIcons returns the list of supported icons and existing in the FS

View Source
var ChartDataExists = func(chart *models.ChartPackage) (bool, error) {
	_, err := os.Stat(chartDataDir(chart))
	if err == nil {
		return true, nil
	} else if os.IsNotExist(err) {
		return false, nil
	}
	return false, err
}

ChartDataExists checks if the chart cache directory is present

View Source
var DataDirBase = func() string {
	return filepath.Join(config.BaseDir(), "repo-data")
}

DataDirBase is the directory used to store cached data like readme files Variable so it can be mocked

View Source
var DownloadAndExtractChartTarball = func(chart *models.ChartPackage) (err error) {
	if err := ensureChartDataDir(chart); err != nil {
		return err
	}

	defer func() {
		if err != nil {
			cleanChartDataDir(chart)
		}
	}()

	if !tarballExists(chart) {
		if err := downloadTarball(chart); err != nil {
			return err
		}
	}

	if err := extractFilesFromTarball(chart); err != nil {
		return err
	}

	return nil
}

DownloadAndExtractChartTarball the chart tar file linked by metadata.Urls and store the wanted files (i.e README.md) under chartDataDir

View Source
var DownloadAndProcessChartIcon = func(chart *models.ChartPackage) error {

	if chart.Icon == "" {
		return nil
	}

	if err := ensureChartDataDir(chart); err != nil {
		return err
	}

	if err := downloadIcon(chart); err != nil {
		return err
	}

	if err := processIcon(chart); err != nil {
		return err
	}

	return nil
}

DownloadAndProcessChartIcon the chart icon and process it

View Source
var ReadFromCache = func(chart *models.ChartPackage, filename string) (string, error) {
	fileToLoad := filepath.Join(chartDataDir(chart), filename)
	dat, err := ioutil.ReadFile(fileToLoad)

	if err != nil {
		return "", fmt.Errorf("Can't find local file %s", fileToLoad)
	}

	return string(dat), nil
}

ReadFromCache reads a file from the local cache based on the chart and filename provided

View Source
var TarballPath = func(chart *models.ChartPackage) string {
	return filepath.Join(chartDataDir(chart), "chart.tgz")
}

TarballPath returns the location of the chart package in the local cache

Functions

func ReadmeStaticUrl

func ReadmeStaticUrl(chart *models.ChartPackage, prefix string) string

ReadmeStaticUrl returns the static path for the README.md file

Types

type IconOutput

type IconOutput struct {
	Name string
	Path string
}

IconOutput defines the output used by the consumer

Jump to

Keyboard shortcuts

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