func fetchChart(pname string) error { f, err := repo.LoadRepositoriesFile(repositoriesFile()) if err != nil { return err } // get download url u, err := mapRepoArg(pname, f.Repositories) if err != nil { return err } resp, err := http.Get(u.String()) if err != nil { return err } if resp.StatusCode != 200 { return fmt.Errorf("Failed to fetch %s : %s", u.String(), resp.Status) } defer resp.Body.Close() if untarFile { return chartutil.Expand(untarDir, resp.Body) } p := strings.Split(u.String(), "/") return saveChartFile(p[len(p)-1], resp.Body) }
func lintChart(path string) (support.Linter, error) { var chartPath string linter := support.Linter{} if strings.HasSuffix(path, ".tgz") { tempDir, err := ioutil.TempDir("", "helm-lint") if err != nil { return linter, err } defer os.RemoveAll(tempDir) file, err := os.Open(path) if err != nil { return linter, err } defer file.Close() if err = chartutil.Expand(tempDir, file); err != nil { return linter, err } base := strings.Split(filepath.Base(path), "-")[0] chartPath = filepath.Join(tempDir, base) } else { chartPath = path } // Guard: Error out of this is not a chart. if _, err := os.Stat(filepath.Join(chartPath, "Chart.yaml")); err != nil { return linter, errLintNoChart } return lint.All(chartPath), nil }
func lintChart(path string) error { if strings.HasSuffix(path, ".tgz") { tempDir, err := ioutil.TempDir("", "helm-lint") if err != nil { return err } defer os.RemoveAll(tempDir) file, err := os.Open(path) if err != nil { return err } defer file.Close() if err = chartutil.Expand(tempDir, file); err != nil { return err } base := strings.Split(filepath.Base(path), "-")[0] path = filepath.Join(tempDir, base) } // Guard: Error out of this is not a chart. if _, err := os.Stat(filepath.Join(path, "Chart.yaml")); err != nil { return errLintNoChart } linter := lint.All(path) if len(linter.Messages) == 0 { fmt.Println("Lint OK") return nil } for _, i := range linter.Messages { fmt.Printf("%s\n", i) } if linter.HighestSeverity == support.ErrorSev { return errLintFailed } return nil }