Merge branch 'dev-v3' of https://github.com/kubernetes/helm into dev-v3-fix-wrapf

Signed-off-by: tariqibrahim <tariq.ibrahim@microsoft.com>
pull/4881/head
tariqibrahim 7 years ago
commit 8983ebd90e

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors All rights reserved. # Copyright The Helm Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors All rights reserved. # Copyright The Helm Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors All rights reserved. # Copyright The Helm Authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

549
Gopkg.lock generated

File diff suppressed because it is too large Load Diff

@ -27,25 +27,41 @@
name = "github.com/gosuri/uitable" name = "github.com/gosuri/uitable"
branch = "master" branch = "master"
[[constraint]]
name = "github.com/technosophos/moniker"
branch = "master"
[[constraint]] [[constraint]]
name = "k8s.io/api" name = "k8s.io/api"
branch = "release-1.10" branch = "release-1.12"
[[constraint]] [[constraint]]
name = "k8s.io/apimachinery" name = "k8s.io/apimachinery"
branch = "release-1.10" branch = "release-1.12"
[[constraint]] [[constraint]]
version = "kubernetes-1.10.0" version = "kubernetes-1.12.1"
name = "k8s.io/client-go" name = "k8s.io/client-go"
[[constraint]] [[constraint]]
name = "k8s.io/kubernetes" name = "k8s.io/kubernetes"
branch = "release-1.10" branch = "release-1.12"
[[override]]
name = "k8s.io/apiserver"
branch = "release-1.12"
[[override]]
name = "github.com/json-iterator/go"
revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682"
[[override]]
name = "github.com/Azure/go-autorest"
revision = "1ff28809256a84bb6966640ff3d0371af82ccba4"
[[override]]
name = "github.com/imdario/mergo"
version = "v0.3.5"
[[override]]
name = "gopkg.in/square/go-jose.v2"
revision = "89060dee6a84df9a4dae49f676f0c755037834f1"
[prune] [prune]
go-tests = true go-tests = true

@ -1,6 +1,7 @@
BINDIR := $(CURDIR)/bin BINDIR := $(CURDIR)/bin
DIST_DIRS := find * -type d -exec DIST_DIRS := find * -type d -exec
TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64
BINNAME ?= helm
# go option # go option
GO ?= go GO ?= go
@ -41,12 +42,12 @@ all: build
.PHONY: build .PHONY: build
build: build:
$(GO) build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BINDIR)/helm k8s.io/helm/cmd/helm $(GO) build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(BINNAME) k8s.io/helm/cmd/helm
.PHONY: build-cross .PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static" build-cross: LDFLAGS += -extldflags "-static"
build-cross: build-cross:
CGO_ENABLED=0 gox -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' k8s.io/helm/cmd/helm CGO_ENABLED=0 gox -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' k8s.io/helm/cmd/helm
.PHONY: dist .PHONY: dist
dist: dist:

@ -20,9 +20,8 @@ Use Helm to:
Helm is a tool that streamlines installing and managing Kubernetes applications. Helm is a tool that streamlines installing and managing Kubernetes applications.
Think of it like apt/yum/homebrew for Kubernetes. Think of it like apt/yum/homebrew for Kubernetes.
- Helm has two parts: a client (`helm`) and a server (`tiller`) - Helm has two parts: a client (`helm`) and a library
- Tiller runs inside of your Kubernetes cluster, and manages releases (installations) - The library renders your templates and communicates with the Kubernetes API
of your charts.
- Helm runs on your laptop, CI/CD, or wherever you want it to run. - Helm runs on your laptop, CI/CD, or wherever you want it to run.
- Charts are Helm packages that contain at least two things: - Charts are Helm packages that contain at least two things:
- A description of the package (`Chart.yaml`) - A description of the package (`Chart.yaml`)

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require" "k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
) )
const createDesc = ` const createDesc = `
@ -80,7 +80,7 @@ func (o *createOptions) run(out io.Writer) error {
Description: "A Helm chart for Kubernetes", Description: "A Helm chart for Kubernetes",
Version: "0.1.0", Version: "0.1.0",
AppVersion: "1.0", AppVersion: "1.0",
APIVersion: chartutil.APIVersionv1, APIVersion: chart.APIVersionv1,
} }
if o.starter != "" { if o.starter != "" {

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -23,8 +23,9 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
) )
func TestCreateCmd(t *testing.T) { func TestCreateCmd(t *testing.T) {
@ -46,15 +47,15 @@ func TestCreateCmd(t *testing.T) {
t.Fatalf("chart is not directory") t.Fatalf("chart is not directory")
} }
c, err := chartutil.LoadDir(cname) c, err := loader.LoadDir(cname)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if c.Metadata.Name != cname { if c.Name() != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name) t.Errorf("Expected %q name, got %q", cname, c.Name())
} }
if c.Metadata.APIVersion != chartutil.APIVersionv1 { if c.Metadata.APIVersion != chart.APIVersionv1 {
t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
} }
} }
@ -97,15 +98,15 @@ func TestCreateStarterCmd(t *testing.T) {
t.Fatalf("chart is not directory") t.Fatalf("chart is not directory")
} }
c, err := chartutil.LoadDir(cname) c, err := loader.LoadDir(cname)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if c.Metadata.Name != cname { if c.Name() != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name) t.Errorf("Expected %q name, got %q", cname, c.Name())
} }
if c.Metadata.APIVersion != chartutil.APIVersionv1 { if c.Metadata.APIVersion != chart.APIVersionv1 {
t.Errorf("Wrong API version: %q", c.Metadata.APIVersion) t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
} }

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -26,7 +26,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require" "k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
) )
const dependencyDesc = ` const dependencyDesc = `
@ -130,27 +131,23 @@ func newDependencyListCmd(out io.Writer) *cobra.Command {
} }
func (o *dependencyLisOptions) run(out io.Writer) error { func (o *dependencyLisOptions) run(out io.Writer) error {
c, err := chartutil.Load(o.chartpath) c, err := loader.Load(o.chartpath)
if err != nil { if err != nil {
return err return err
} }
r, err := chartutil.LoadRequirements(c) if c.Metadata.Requirements == nil {
if err != nil { fmt.Fprintf(out, "WARNING: no requirements at %s/charts\n", o.chartpath)
if err == chartutil.ErrRequirementsNotFound { return nil
fmt.Fprintf(out, "WARNING: no requirements at %s/charts\n", o.chartpath)
return nil
}
return err
} }
o.printRequirements(out, r) o.printRequirements(out, c.Metadata.Requirements)
fmt.Fprintln(out) fmt.Fprintln(out)
o.printMissing(out, r) o.printMissing(out, c.Metadata.Requirements)
return nil return nil
} }
func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) string { func (o *dependencyLisOptions) dependencyStatus(dep *chart.Dependency) string {
filename := fmt.Sprintf("%s-%s.tgz", dep.Name, "*") filename := fmt.Sprintf("%s-%s.tgz", dep.Name, "*")
archives, err := filepath.Glob(filepath.Join(o.chartpath, "charts", filename)) archives, err := filepath.Glob(filepath.Join(o.chartpath, "charts", filename))
if err != nil { if err != nil {
@ -160,11 +157,11 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) strin
} else if len(archives) == 1 { } else if len(archives) == 1 {
archive := archives[0] archive := archives[0]
if _, err := os.Stat(archive); err == nil { if _, err := os.Stat(archive); err == nil {
c, err := chartutil.Load(archive) c, err := loader.Load(archive)
if err != nil { if err != nil {
return "corrupt" return "corrupt"
} }
if c.Metadata.Name != dep.Name { if c.Name() != dep.Name {
return "misnamed" return "misnamed"
} }
@ -195,12 +192,12 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) strin
return "mispackaged" return "mispackaged"
} }
c, err := chartutil.Load(folder) c, err := loader.Load(folder)
if err != nil { if err != nil {
return "corrupt" return "corrupt"
} }
if c.Metadata.Name != dep.Name { if c.Name() != dep.Name {
return "misnamed" return "misnamed"
} }
@ -225,18 +222,18 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) strin
} }
// printRequirements prints all of the requirements in the yaml file. // printRequirements prints all of the requirements in the yaml file.
func (o *dependencyLisOptions) printRequirements(out io.Writer, reqs *chartutil.Requirements) { func (o *dependencyLisOptions) printRequirements(out io.Writer, reqs []*chart.Dependency) {
table := uitable.New() table := uitable.New()
table.MaxColWidth = 80 table.MaxColWidth = 80
table.AddRow("NAME", "VERSION", "REPOSITORY", "STATUS") table.AddRow("NAME", "VERSION", "REPOSITORY", "STATUS")
for _, row := range reqs.Dependencies { for _, row := range reqs {
table.AddRow(row.Name, row.Version, row.Repository, o.dependencyStatus(row)) table.AddRow(row.Name, row.Version, row.Repository, o.dependencyStatus(row))
} }
fmt.Fprintln(out, table) fmt.Fprintln(out, table)
} }
// printMissing prints warnings about charts that are present on disk, but are not in the requirements. // printMissing prints warnings about charts that are present on disk, but are not in the requirements.
func (o *dependencyLisOptions) printMissing(out io.Writer, reqs *chartutil.Requirements) { func (o *dependencyLisOptions) printMissing(out io.Writer, reqs []*chart.Dependency) {
folder := filepath.Join(o.chartpath, "charts/*") folder := filepath.Join(o.chartpath, "charts/*")
files, err := filepath.Glob(folder) files, err := filepath.Glob(folder)
if err != nil { if err != nil {
@ -253,20 +250,20 @@ func (o *dependencyLisOptions) printMissing(out io.Writer, reqs *chartutil.Requi
if !fi.IsDir() && filepath.Ext(f) != ".tgz" { if !fi.IsDir() && filepath.Ext(f) != ".tgz" {
continue continue
} }
c, err := chartutil.Load(f) c, err := loader.Load(f)
if err != nil { if err != nil {
fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f) fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f)
continue continue
} }
found := false found := false
for _, d := range reqs.Dependencies { for _, d := range reqs {
if d.Name == c.Metadata.Name { if d.Name == c.Name() {
found = true found = true
break break
} }
} }
if !found { if !found {
fmt.Fprintf(out, "WARNING: %q is not in requirements.yaml.\n", f) fmt.Fprintf(out, "WARNING: %q is not in Chart.yaml.\n", f)
} }
} }

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -26,7 +26,7 @@ import (
) )
const dependencyBuildDesc = ` const dependencyBuildDesc = `
Build out the charts/ directory from the requirements.lock file. Build out the charts/ directory from the Chart.lock file.
Build is used to reconstruct a chart's dependencies to the state specified in Build is used to reconstruct a chart's dependencies to the state specified in
the lock file. This will not re-negotiate dependencies, as 'helm dependency update' the lock file. This will not re-negotiate dependencies, as 'helm dependency update'
@ -50,7 +50,7 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "build CHART", Use: "build CHART",
Short: "rebuild the charts/ directory based on the requirements.lock file", Short: "rebuild the charts/ directory based on the Chart.lock file",
Long: dependencyBuildDesc, Long: dependencyBuildDesc,
Args: require.MaximumNArgs(1), Args: require.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -64,7 +64,7 @@ func TestDependencyBuildCmd(t *testing.T) {
// In the second pass, we want to remove the chart's request dependency, // In the second pass, we want to remove the chart's request dependency,
// then see if it restores from the lock. // then see if it restores from the lock.
lockfile := hh.Path(chartname, "requirements.lock") lockfile := hh.Path(chartname, "Chart.lock")
if _, err := os.Stat(lockfile); err != nil { if _, err := os.Stat(lockfile); err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -28,18 +28,18 @@ import (
) )
const dependencyUpDesc = ` const dependencyUpDesc = `
Update the on-disk dependencies to mirror the requirements.yaml file. Update the on-disk dependencies to mirror Chart.yaml.
This command verifies that the required charts, as expressed in 'requirements.yaml', This command verifies that the required charts, as expressed in 'Chart.yaml',
are present in 'charts/' and are at an acceptable version. It will pull down are present in 'charts/' and are at an acceptable version. It will pull down
the latest charts that satisfy the dependencies, and clean up old dependencies. the latest charts that satisfy the dependencies, and clean up old dependencies.
On successful update, this will generate a lock file that can be used to On successful update, this will generate a lock file that can be used to
rebuild the requirements to an exact version. rebuild the requirements to an exact version.
Dependencies are not required to be represented in 'requirements.yaml'. For that Dependencies are not required to be represented in 'Chart.yaml'. For that
reason, an update command will not remove charts unless they are (a) present reason, an update command will not remove charts unless they are (a) present
in the requirements.yaml file, but (b) at the wrong version. in the Chart.yaml file, but (b) at the wrong version.
` `
// dependencyUpdateOptions describes a 'helm dependency update' // dependencyUpdateOptions describes a 'helm dependency update'
@ -63,7 +63,7 @@ func newDependencyUpdateCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "update CHART", Use: "update CHART",
Aliases: []string{"up"}, Aliases: []string{"up"},
Short: "update charts/ based on the contents of requirements.yaml", Short: "update charts/ based on the contents of Chart.yaml",
Long: dependencyUpDesc, Long: dependencyUpDesc,
Args: require.MaximumNArgs(1), Args: require.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -24,11 +24,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/ghodss/yaml" "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/provenance" "k8s.io/helm/pkg/provenance"
"k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/repo/repotest" "k8s.io/helm/pkg/repo/repotest"
@ -50,7 +47,8 @@ func TestDependencyUpdateCmd(t *testing.T) {
t.Logf("Listening on directory %s", srv.Root()) t.Logf("Listening on directory %s", srv.Root())
chartname := "depup" chartname := "depup"
if err := createTestingChart(hh.String(), chartname, srv.URL()); err != nil { md := createTestingMetadata(chartname, srv.URL())
if _, err := chartutil.Create(md, hh.String()); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -88,14 +86,12 @@ func TestDependencyUpdateCmd(t *testing.T) {
// Now change the dependencies and update. This verifies that on update, // Now change the dependencies and update. This verifies that on update,
// old dependencies are cleansed and new dependencies are added. // old dependencies are cleansed and new dependencies are added.
reqfile := &chartutil.Requirements{ md.Requirements = []*chart.Dependency{
Dependencies: []*chartutil.Dependency{ {Name: "reqtest", Version: "0.1.0", Repository: srv.URL()},
{Name: "reqtest", Version: "0.1.0", Repository: srv.URL()}, {Name: "compressedchart", Version: "0.3.0", Repository: srv.URL()},
{Name: "compressedchart", Version: "0.3.0", Repository: srv.URL()},
},
} }
dir := hh.Path(chartname) dir := hh.Path(chartname, "Chart.yaml")
if err := writeRequirements(dir, reqfile); err != nil { if err := chartutil.SaveChartfile(dir, md); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -170,7 +166,7 @@ func TestDependencyUpdateCmd_DontDeleteOldChartsOnError(t *testing.T) {
out := bytes.NewBuffer(nil) out := bytes.NewBuffer(nil)
o := &dependencyUpdateOptions{} o := &dependencyUpdateOptions{}
o.helmhome = helmpath.Home(hh) o.helmhome = hh
o.chartpath = hh.Path(chartname) o.chartpath = hh.Path(chartname)
if err := o.run(out); err != nil { if err := o.run(out); err != nil {
@ -210,33 +206,25 @@ func TestDependencyUpdateCmd_DontDeleteOldChartsOnError(t *testing.T) {
} }
} }
// createTestingChart creates a basic chart that depends on reqtest-0.1.0 // createTestingMetadata creates a basic chart that depends on reqtest-0.1.0
// //
// The baseURL can be used to point to a particular repository server. // The baseURL can be used to point to a particular repository server.
func createTestingChart(dest, name, baseURL string) error { func createTestingMetadata(name, baseURL string) *chart.Metadata {
cfile := &chart.Metadata{ return &chart.Metadata{
Name: name, Name: name,
Version: "1.2.3", Version: "1.2.3",
} Requirements: []*chart.Dependency{
dir := filepath.Join(dest, name)
_, err := chartutil.Create(cfile, dest)
if err != nil {
return err
}
req := &chartutil.Requirements{
Dependencies: []*chartutil.Dependency{
{Name: "reqtest", Version: "0.1.0", Repository: baseURL}, {Name: "reqtest", Version: "0.1.0", Repository: baseURL},
{Name: "compressedchart", Version: "0.1.0", Repository: baseURL}, {Name: "compressedchart", Version: "0.1.0", Repository: baseURL},
}, },
} }
return writeRequirements(dir, req)
} }
func writeRequirements(dir string, req *chartutil.Requirements) error { // createTestingChart creates a basic chart that depends on reqtest-0.1.0
data, err := yaml.Marshal(req) //
if err != nil { // The baseURL can be used to point to a particular repository server.
return err func createTestingChart(dest, name, baseURL string) error {
} cfile := createTestingMetadata(name, baseURL)
_, err := chartutil.Create(cfile, dest)
return ioutil.WriteFile(filepath.Join(dir, "requirements.yaml"), data, 0655) return err
} }

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -23,8 +23,8 @@ import (
"sync" "sync"
// Import to initialize client auth plugins. // Import to initialize client auth plugins.
"k8s.io/cli-runtime/pkg/genericclioptions"
_ "k8s.io/client-go/plugin/pkg/client/auth" _ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/helm/pkg/helm" "k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm/environment" "k8s.io/helm/pkg/helm/environment"
@ -34,7 +34,7 @@ import (
var ( var (
settings environment.EnvSettings settings environment.EnvSettings
config clientcmd.ClientConfig config genericclioptions.RESTClientGetter
configOnce sync.Once configOnce sync.Once
) )
@ -89,7 +89,7 @@ func newClient(allNamespaces bool) helm.Interface {
) )
} }
func kubeConfig() clientcmd.ClientConfig { func kubeConfig() genericclioptions.RESTClientGetter {
configOnce.Do(func() { configOnce.Do(func() {
config = kube.GetConfig(settings.KubeConfig, settings.KubeContext, settings.Namespace) config = kube.GetConfig(settings.KubeConfig, settings.KubeContext, settings.Namespace)
}) })
@ -97,7 +97,7 @@ func kubeConfig() clientcmd.ClientConfig {
} }
func getNamespace() string { func getNamespace() string {
if ns, _, err := kubeConfig().Namespace(); err == nil { if ns, _, err := kubeConfig().ToRawKubeConfigLoader().Namespace(); err == nil {
return ns return ns
} }
return "default" return "default"

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -141,12 +141,10 @@ func ensureTestHome(t *testing.T, home helmpath.Home) {
} }
} }
if r, err := repo.LoadRepositoriesFile(repoFile); err == repo.ErrRepoOutOfDate { if r, err := repo.LoadRepositoriesFile(repoFile); err == repo.ErrRepoOutOfDate {
t.Log("Updating repository file format...")
if err := r.WriteFile(repoFile, 0644); err != nil { if err := r.WriteFile(repoFile, 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
t.Logf("$HELM_HOME has been configured at %s.\n", home)
} }
// testHelmHome sets up a Helm Home in a temp dir. // testHelmHome sets up a Helm Home in a temp dir.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require" "k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/hapi/chart" "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/hapi/release" "k8s.io/helm/pkg/hapi/release"
"k8s.io/helm/pkg/helm" "k8s.io/helm/pkg/helm"
) )
@ -167,5 +167,5 @@ func formatChartname(c *chart.Chart) string {
// know how: https://github.com/kubernetes/helm/issues/1347 // know how: https://github.com/kubernetes/helm/issues/1347
return "MISSING" return "MISSING"
} }
return fmt.Sprintf("%s-%s", c.Metadata.Name, c.Metadata.Version) return fmt.Sprintf("%s-%s", c.Name(), c.Metadata.Version)
} }

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require" "k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/hapi/chart" "k8s.io/helm/pkg/chart/loader"
) )
const inspectDesc = ` const inspectDesc = `
@ -146,7 +146,7 @@ func newInspectCmd(out io.Writer) *cobra.Command {
} }
func (i *inspectOptions) run(out io.Writer) error { func (i *inspectOptions) run(out io.Writer) error {
chrt, err := chartutil.Load(i.chartpath) chrt, err := loader.Load(i.chartpath)
if err != nil { if err != nil {
return err return err
} }
@ -163,7 +163,11 @@ func (i *inspectOptions) run(out io.Writer) error {
if i.output == all { if i.output == all {
fmt.Fprintln(out, "---") fmt.Fprintln(out, "---")
} }
fmt.Fprintln(out, string(chrt.Values)) b, err := yaml.Marshal(chrt.Values)
if err != nil {
return err
}
fmt.Fprintln(out, string(b))
} }
if i.output == readmeOnly || i.output == all { if i.output == readmeOnly || i.output == all {

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -20,18 +20,20 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"path/filepath"
"strings" "strings"
"text/template" "text/template"
"time"
"github.com/Masterminds/sprig" "github.com/Masterminds/sprig"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require" "k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/downloader" "k8s.io/helm/pkg/downloader"
"k8s.io/helm/pkg/getter" "k8s.io/helm/pkg/getter"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/hapi/release" "k8s.io/helm/pkg/hapi/release"
"k8s.io/helm/pkg/helm" "k8s.io/helm/pkg/helm"
) )
@ -46,27 +48,27 @@ To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line, to force or use the '--set' flag and pass configuration from the command line, to force
a string value use '--set-string'. a string value use '--set-string'.
$ helm install -f myvalues.yaml ./redis $ helm install -f myvalues.yaml myredis ./redis
or or
$ helm install --set name=prod ./redis $ helm install --set name=prod myredis ./redis
or or
$ helm install --set-string long_int=1234567890 ./redis $ helm install --set-string long_int=1234567890 myredis ./redis
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
contained a key called 'Test', the value set in override.yaml would take precedence: contained a key called 'Test', the value set in override.yaml would take precedence:
$ helm install -f myvalues.yaml -f override.yaml ./redis $ helm install -f myvalues.yaml -f override.yaml myredis ./redis
You can specify the '--set' flag multiple times. The priority will be given to the You can specify the '--set' flag multiple times. The priority will be given to the
last (right-most) set specified. For example, if both 'bar' and 'newbar' values are last (right-most) set specified. For example, if both 'bar' and 'newbar' values are
set for a key called 'foo', the 'newbar' value would take precedence: set for a key called 'foo', the 'newbar' value would take precedence:
$ helm install --set foo=bar --set foo=newbar ./redis $ helm install --set foo=bar --set foo=newbar myredis ./redis
To check the generated manifests of a release without installing the chart, To check the generated manifests of a release without installing the chart,
@ -99,7 +101,7 @@ charts in a repository, use 'helm search'.
` `
type installOptions struct { type installOptions struct {
name string // --name name string // arg 0
dryRun bool // --dry-run dryRun bool // --dry-run
disableHooks bool // --disable-hooks disableHooks bool // --disable-hooks
replace bool // --replace replace bool // --replace
@ -108,7 +110,8 @@ type installOptions struct {
wait bool // --wait wait bool // --wait
devel bool // --devel devel bool // --devel
depUp bool // --dep-up depUp bool // --dep-up
chartPath string // arg chartPath string // arg 1
generateName bool // --generate-name
valuesOptions valuesOptions
chartPathOptions chartPathOptions
@ -120,10 +123,10 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
o := &installOptions{client: c} o := &installOptions{client: c}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "install [CHART]", Use: "install [NAME] [CHART]",
Short: "install a chart archive", Short: "install a chart",
Long: installDesc, Long: installDesc,
Args: require.ExactArgs(1), Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
debug("Original chart version: %q", o.version) debug("Original chart version: %q", o.version)
if o.version == "" && o.devel { if o.version == "" && o.devel {
@ -131,7 +134,13 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
o.version = ">0.0.0-0" o.version = ">0.0.0-0"
} }
cp, err := o.locateChart(args[0]) name, chart, err := o.nameAndChart(args)
if err != nil {
return err
}
o.name = name // FIXME
cp, err := o.locateChart(chart)
if err != nil { if err != nil {
return err return err
} }
@ -142,7 +151,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
} }
f := cmd.Flags() f := cmd.Flags()
f.StringVarP(&o.name, "name", "", "", "release name. If unspecified, it will autogenerate one for you") f.BoolVarP(&o.generateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)")
f.BoolVar(&o.dryRun, "dry-run", false, "simulate an install") f.BoolVar(&o.dryRun, "dry-run", false, "simulate an install")
f.BoolVar(&o.disableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&o.disableHooks, "no-hooks", false, "prevent hooks from running during install")
f.BoolVar(&o.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production") f.BoolVar(&o.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production")
@ -157,6 +166,41 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
return cmd return cmd
} }
// nameAndChart returns the name of the release and the chart that should be used.
//
// This will read the flags and handle name generation if necessary.
func (o *installOptions) nameAndChart(args []string) (string, string, error) {
flagsNotSet := func() error {
if o.generateName {
return errors.New("cannot set --generate-name and also specify a name")
}
if o.nameTemplate != "" {
return errors.New("cannot set --name-template and also specify a name")
}
return nil
}
if len(args) == 2 {
return args[0], args[1], flagsNotSet()
}
if o.nameTemplate != "" {
newName, err := templateName(o.nameTemplate)
return newName, args[0], err
}
if !o.generateName {
return "", args[0], errors.New("must either provide a name or specify --generate-name")
}
base := filepath.Base(args[0])
if base == "." || base == "" {
base = "chart"
}
newName := fmt.Sprintf("%s-%d", base, time.Now().Unix())
return newName, args[0], nil
}
func (o *installOptions) run(out io.Writer) error { func (o *installOptions) run(out io.Writer) error {
debug("CHART PATH: %s\n", o.chartPath) debug("CHART PATH: %s\n", o.chartPath)
@ -167,7 +211,7 @@ func (o *installOptions) run(out io.Writer) error {
// If template is specified, try to run the template. // If template is specified, try to run the template.
if o.nameTemplate != "" { if o.nameTemplate != "" {
o.name, err = generateName(o.nameTemplate) o.name, err = templateName(o.nameTemplate)
if err != nil { if err != nil {
return err return err
} }
@ -176,12 +220,12 @@ func (o *installOptions) run(out io.Writer) error {
} }
// Check chart requirements to make sure all dependencies are present in /charts // Check chart requirements to make sure all dependencies are present in /charts
chartRequested, err := chartutil.Load(o.chartPath) chartRequested, err := loader.Load(o.chartPath)
if err != nil { if err != nil {
return err return err
} }
if req, err := chartutil.LoadRequirements(chartRequested); err == nil { if req := chartRequested.Metadata.Requirements; req != nil {
// If checkDependencies returns an error, we have unfulfilled dependencies. // If checkDependencies returns an error, we have unfulfilled dependencies.
// As of Helm 2.4.0, this is treated as a stopping condition: // As of Helm 2.4.0, this is treated as a stopping condition:
// https://github.com/kubernetes/helm/issues/2209 // https://github.com/kubernetes/helm/issues/2209
@ -203,8 +247,6 @@ func (o *installOptions) run(out io.Writer) error {
} }
} }
} else if err != chartutil.ErrRequirementsNotFound {
return errors.Wrap(err, "cannot load requirements")
} }
rel, err := o.client.InstallReleaseFromChart( rel, err := o.client.InstallReleaseFromChart(
@ -272,41 +314,33 @@ func (o *installOptions) printRelease(out io.Writer, rel *release.Release) {
if rel == nil { if rel == nil {
return return
} }
// TODO: Switch to text/template like everything else.
fmt.Fprintf(out, "NAME: %s\n", rel.Name) fmt.Fprintf(out, "NAME: %s\n", rel.Name)
if settings.Debug { if settings.Debug {
printRelease(out, rel) printRelease(out, rel)
} }
} }
func generateName(nameTemplate string) (string, error) { func templateName(nameTemplate string) (string, error) {
t, err := template.New("name-template").Funcs(sprig.TxtFuncMap()).Parse(nameTemplate) t, err := template.New("name-template").Funcs(sprig.TxtFuncMap()).Parse(nameTemplate)
if err != nil { if err != nil {
return "", err return "", err
} }
var b bytes.Buffer var b bytes.Buffer
err = t.Execute(&b, nil) err = t.Execute(&b, nil)
if err != nil { return b.String(), err
return "", err
}
return b.String(), nil
} }
func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements) error { func checkDependencies(ch *chart.Chart, reqs []*chart.Dependency) error {
missing := []string{} var missing []string
deps := ch.Dependencies OUTER:
for _, r := range reqs.Dependencies { for _, r := range reqs {
found := false for _, d := range ch.Dependencies() {
for _, d := range deps { if d.Name() == r.Name {
if d.Metadata.Name == r.Name { continue OUTER
found = true
break
} }
} }
if !found { missing = append(missing, r.Name)
missing = append(missing, r.Name)
}
} }
if len(missing) > 0 { if len(missing) > 0 {

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -27,37 +27,37 @@ func TestInstall(t *testing.T) {
// Install, base case // Install, base case
{ {
name: "basic install", name: "basic install",
cmd: "install testdata/testcharts/alpine --name aeneas", cmd: "install aeneas testdata/testcharts/alpine ",
golden: "output/install.txt", golden: "output/install.txt",
}, },
// Install, no hooks // Install, no hooks
{ {
name: "install without hooks", name: "install without hooks",
cmd: "install testdata/testcharts/alpine --name aeneas --no-hooks", cmd: "install aeneas testdata/testcharts/alpine --no-hooks",
golden: "output/install-no-hooks.txt", golden: "output/install-no-hooks.txt",
}, },
// Install, values from cli // Install, values from cli
{ {
name: "install with values", name: "install with values",
cmd: "install testdata/testcharts/alpine --name virgil --set foo=bar", cmd: "install virgil testdata/testcharts/alpine --set foo=bar",
golden: "output/install-with-values.txt", golden: "output/install-with-values.txt",
}, },
// Install, values from cli via multiple --set // Install, values from cli via multiple --set
{ {
name: "install with multiple values", name: "install with multiple values",
cmd: "install testdata/testcharts/alpine --name virgil --set foo=bar --set bar=foo", cmd: "install virgil testdata/testcharts/alpine --set foo=bar --set bar=foo",
golden: "output/install-with-multiple-values.txt", golden: "output/install-with-multiple-values.txt",
}, },
// Install, values from yaml // Install, values from yaml
{ {
name: "install with values file", name: "install with values file",
cmd: "install testdata/testcharts/alpine --name virgil -f testdata/testcharts/alpine/extra_values.yaml", cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml",
golden: "output/install-with-values-file.txt", golden: "output/install-with-values-file.txt",
}, },
// Install, values from multiple yaml // Install, values from multiple yaml
{ {
name: "install with values", name: "install with values",
cmd: "install testdata/testcharts/alpine --name virgil -f testdata/testcharts/alpine/extra_values.yaml -f testdata/testcharts/alpine/more_values.yaml", cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml -f testdata/testcharts/alpine/more_values.yaml",
golden: "output/install-with-multiple-values-files.txt", golden: "output/install-with-multiple-values-files.txt",
}, },
// Install, no charts // Install, no charts
@ -70,19 +70,19 @@ func TestInstall(t *testing.T) {
// Install, re-use name // Install, re-use name
{ {
name: "install and replace release", name: "install and replace release",
cmd: "install testdata/testcharts/alpine --name aeneas --replace", cmd: "install aeneas testdata/testcharts/alpine --replace",
golden: "output/install-and-replace.txt", golden: "output/install-and-replace.txt",
}, },
// Install, with timeout // Install, with timeout
{ {
name: "install with a timeout", name: "install with a timeout",
cmd: "install testdata/testcharts/alpine --name foobar --timeout 120", cmd: "install foobar testdata/testcharts/alpine --timeout 120",
golden: "output/install-with-timeout.txt", golden: "output/install-with-timeout.txt",
}, },
// Install, with wait // Install, with wait
{ {
name: "install with a wait", name: "install with a wait",
cmd: "install testdata/testcharts/alpine --name apollo --wait", cmd: "install apollo testdata/testcharts/alpine --wait",
golden: "output/install-with-wait.txt", golden: "output/install-with-wait.txt",
}, },
// Install, using the name-template // Install, using the name-template
@ -94,28 +94,28 @@ func TestInstall(t *testing.T) {
// Install, perform chart verification along the way. // Install, perform chart verification along the way.
{ {
name: "install with verification, missing provenance", name: "install with verification, missing provenance",
cmd: "install testdata/testcharts/compressedchart-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub", cmd: "install bogus testdata/testcharts/compressedchart-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub",
wantError: true, wantError: true,
}, },
{ {
name: "install with verification, directory instead of file", name: "install with verification, directory instead of file",
cmd: "install testdata/testcharts/signtest --verify --keyring testdata/helm-test-key.pub", cmd: "install bogus testdata/testcharts/signtest --verify --keyring testdata/helm-test-key.pub",
wantError: true, wantError: true,
}, },
{ {
name: "install with verification, valid", name: "install with verification, valid",
cmd: "install testdata/testcharts/signtest-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub", cmd: "install signtest testdata/testcharts/signtest-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub",
}, },
// Install, chart with missing dependencies in /charts // Install, chart with missing dependencies in /charts
{ {
name: "install chart with missing dependencies", name: "install chart with missing dependencies",
cmd: "install testdata/testcharts/chart-missing-deps", cmd: "install nodeps testdata/testcharts/chart-missing-deps",
wantError: true, wantError: true,
}, },
// Install, chart with bad requirements.yaml in /charts // Install, chart with bad dependencies in Chart.yaml in /charts
{ {
name: "install chart with bad requirements.yaml", name: "install chart with bad dependencies in Chart.yaml",
cmd: "install testdata/testcharts/chart-bad-requirements", cmd: "install badreq testdata/testcharts/chart-bad-requirements",
wantError: true, wantError: true,
}, },
} }
@ -165,7 +165,7 @@ func TestNameTemplate(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
n, err := generateName(tc.tpl) n, err := templateName(tc.tpl)
if err != nil { if err != nil {
if tc.expectedErrorStr == "" { if tc.expectedErrorStr == "" {
t.Errorf("Was not expecting error, but got: %v", err) t.Errorf("Was not expecting error, but got: %v", err)

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -34,8 +34,8 @@ var listHelp = `
This command lists all of the releases. This command lists all of the releases.
By default, it lists only releases that are deployed or failed. Flags like By default, it lists only releases that are deployed or failed. Flags like
'--deleted' and '--all' will alter this behavior. Such flags can be combined: '--uninstalled' and '--all' will alter this behavior. Such flags can be combined:
'--deleted --failed'. '--uninstalled --failed'.
By default, items are sorted alphabetically. Use the '-d' flag to sort by By default, items are sorted alphabetically. Use the '-d' flag to sort by
release date. release date.
@ -63,8 +63,8 @@ type listOptions struct {
allNamespaces bool // --all-namespaces allNamespaces bool // --all-namespaces
byDate bool // --date byDate bool // --date
colWidth uint // --col-width colWidth uint // --col-width
deleted bool // --deleted uninstalled bool // --uninstalled
deleting bool // --deleting uninstalling bool // --uninstalling
deployed bool // --deployed deployed bool // --deployed
failed bool // --failed failed bool // --failed
limit int // --max limit int // --max
@ -104,9 +104,9 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
f.IntVarP(&o.limit, "max", "m", 256, "maximum number of releases to fetch") f.IntVarP(&o.limit, "max", "m", 256, "maximum number of releases to fetch")
f.StringVarP(&o.offset, "offset", "o", "", "next release name in the list, used to offset from start value") f.StringVarP(&o.offset, "offset", "o", "", "next release name in the list, used to offset from start value")
f.BoolVarP(&o.all, "all", "a", false, "show all releases, not just the ones marked deployed") f.BoolVarP(&o.all, "all", "a", false, "show all releases, not just the ones marked deployed")
f.BoolVar(&o.deleted, "deleted", false, "show deleted releases") f.BoolVar(&o.uninstalled, "uninstalled", false, "show uninstalled releases")
f.BoolVar(&o.superseded, "superseded", false, "show superseded releases") f.BoolVar(&o.superseded, "superseded", false, "show superseded releases")
f.BoolVar(&o.deleting, "deleting", false, "show releases that are currently being deleted") f.BoolVar(&o.uninstalling, "uninstalling", false, "show releases that are currently being uninstalled")
f.BoolVar(&o.deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") f.BoolVar(&o.deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled")
f.BoolVar(&o.failed, "failed", false, "show failed releases") f.BoolVar(&o.failed, "failed", false, "show failed releases")
f.BoolVar(&o.pending, "pending", false, "show pending releases") f.BoolVar(&o.pending, "pending", false, "show pending releases")
@ -188,8 +188,8 @@ func (o *listOptions) statusCodes() []release.ReleaseStatus {
return []release.ReleaseStatus{ return []release.ReleaseStatus{
release.StatusUnknown, release.StatusUnknown,
release.StatusDeployed, release.StatusDeployed,
release.StatusDeleted, release.StatusUninstalled,
release.StatusDeleting, release.StatusUninstalling,
release.StatusFailed, release.StatusFailed,
release.StatusPendingInstall, release.StatusPendingInstall,
release.StatusPendingUpgrade, release.StatusPendingUpgrade,
@ -200,11 +200,11 @@ func (o *listOptions) statusCodes() []release.ReleaseStatus {
if o.deployed { if o.deployed {
status = append(status, release.StatusDeployed) status = append(status, release.StatusDeployed)
} }
if o.deleted { if o.uninstalled {
status = append(status, release.StatusDeleted) status = append(status, release.StatusUninstalled)
} }
if o.deleting { if o.uninstalling {
status = append(status, release.StatusDeleting) status = append(status, release.StatusUninstalling)
} }
if o.failed { if o.failed {
status = append(status, release.StatusFailed) status = append(status, release.StatusFailed)

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -48,9 +48,9 @@ func TestListCmd(t *testing.T) {
golden: "output/list-with-failed.txt", golden: "output/list-with-failed.txt",
}, { }, {
name: "with a release, multiple flags", name: "with a release, multiple flags",
cmd: "list --deleted --deployed --failed -q", cmd: "list --uninstalled --deployed --failed -q",
rels: []*release.Release{ rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusDeleted}), helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusUninstalled}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}), helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
}, },
// Note: We're really only testing that the flags parsed correctly. Which results are returned // Note: We're really only testing that the flags parsed correctly. Which results are returned
@ -60,7 +60,7 @@ func TestListCmd(t *testing.T) {
name: "with a release, multiple flags", name: "with a release, multiple flags",
cmd: "list --all -q", cmd: "list --all -q",
rels: []*release.Release{ rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusDeleted}), helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusUninstalled}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}), helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
}, },
// See note on previous test. // See note on previous test.
@ -69,7 +69,7 @@ func TestListCmd(t *testing.T) {
name: "with a release, multiple flags, deleting", name: "with a release, multiple flags, deleting",
cmd: "list --all -q", cmd: "list --all -q",
rels: []*release.Release{ rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusDeleting}), helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusUninstalling}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}), helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
}, },
// See note on previous test. // See note on previous test.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2018 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -25,15 +25,15 @@ import (
"syscall" "syscall"
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
"github.com/ghodss/yaml"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/downloader" "k8s.io/helm/pkg/downloader"
"k8s.io/helm/pkg/getter" "k8s.io/helm/pkg/getter"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/helm/helmpath" "k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/provenance" "k8s.io/helm/pkg/provenance"
) )
@ -102,7 +102,7 @@ func newPackageCmd(out io.Writer) *cobra.Command {
f.StringVar(&o.version, "version", "", "set the version on the chart to this semver version") f.StringVar(&o.version, "version", "", "set the version on the chart to this semver version")
f.StringVar(&o.appVersion, "app-version", "", "set the appVersion on the chart to this version") f.StringVar(&o.appVersion, "app-version", "", "set the appVersion on the chart to this version")
f.StringVarP(&o.destination, "destination", "d", ".", "location to write the chart.") f.StringVarP(&o.destination, "destination", "d", ".", "location to write the chart.")
f.BoolVarP(&o.dependencyUpdate, "dependency-update", "u", false, `update dependencies from "requirements.yaml" to dir "charts/" before packaging`) f.BoolVarP(&o.dependencyUpdate, "dependency-update", "u", false, `update dependencies from "Chart.yaml" to dir "charts/" before packaging`)
o.valuesOptions.addFlags(f) o.valuesOptions.addFlags(f)
return cmd return cmd
@ -129,7 +129,7 @@ func (o *packageOptions) run(out io.Writer) error {
} }
} }
ch, err := chartutil.LoadDir(path) ch, err := loader.LoadDir(path)
if err != nil { if err != nil {
return err return err
} }
@ -142,11 +142,7 @@ func (o *packageOptions) run(out io.Writer) error {
if err != nil { if err != nil {
return err return err
} }
newVals, err := yaml.Marshal(combinedVals) ch.Values = combinedVals
if err != nil {
return err
}
ch.Values = newVals
// If version is set, modify the version. // If version is set, modify the version.
if len(o.version) != 0 { if len(o.version) != 0 {
@ -161,18 +157,10 @@ func (o *packageOptions) run(out io.Writer) error {
debug("Setting appVersion to %s", o.appVersion) debug("Setting appVersion to %s", o.appVersion)
} }
if filepath.Base(path) != ch.Metadata.Name { if reqs := ch.Metadata.Requirements; reqs != nil {
return errors.Errorf("directory name (%s) and Chart.yaml name (%s) must match", filepath.Base(path), ch.Metadata.Name)
}
if reqs, err := chartutil.LoadRequirements(ch); err == nil {
if err := checkDependencies(ch, reqs); err != nil { if err := checkDependencies(ch, reqs); err != nil {
return err return err
} }
} else {
if err != chartutil.ErrRequirementsNotFound {
return err
}
} }
var dest string var dest string
@ -188,11 +176,10 @@ func (o *packageOptions) run(out io.Writer) error {
} }
name, err := chartutil.Save(ch, dest) name, err := chartutil.Save(ch, dest)
if err == nil { if err != nil {
fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", name)
} else {
return errors.Wrap(err, "failed to save") return errors.Wrap(err, "failed to save")
} }
fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", name)
if o.sign { if o.sign {
err = o.clearsign(name) err = o.clearsign(name)

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -26,8 +26,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/helm/helmpath" "k8s.io/helm/pkg/helm/helmpath"
) )
@ -97,6 +98,12 @@ func TestPackage(t *testing.T) {
expect: "", expect: "",
hasfile: "alpine-0.1.0.tgz", hasfile: "alpine-0.1.0.tgz",
}, },
{
name: "package testdata/testcharts/issue1979",
args: []string{"testdata/testcharts/issue1979"},
expect: "",
hasfile: "alpine-0.1.0.tgz",
},
{ {
name: "package --destination toot", name: "package --destination toot",
args: []string{"testdata/testcharts/alpine"}, args: []string{"testdata/testcharts/alpine"},
@ -206,7 +213,7 @@ func TestSetAppVersion(t *testing.T) {
tmp := testTempDir(t) tmp := testTempDir(t)
hh := testHelmHome(t) hh := testHelmHome(t)
settings.Home = helmpath.Home(hh) settings.Home = hh
c := newPackageCmd(&bytes.Buffer{}) c := newPackageCmd(&bytes.Buffer{})
flags := map[string]string{ flags := map[string]string{
@ -224,7 +231,7 @@ func TestSetAppVersion(t *testing.T) {
} else if fi.Size() == 0 { } else if fi.Size() == 0 {
t.Errorf("file %q has zero bytes.", chartPath) t.Errorf("file %q has zero bytes.", chartPath)
} }
ch, err := chartutil.Load(chartPath) ch, err := loader.Load(chartPath)
if err != nil { if err != nil {
t.Errorf("unexpected error loading packaged chart: %v", err) t.Errorf("unexpected error loading packaged chart: %v", err)
} }
@ -291,6 +298,7 @@ func TestPackageValues(t *testing.T) {
} }
func runAndVerifyPackageCommandValues(t *testing.T, args []string, flags map[string]string, valueFiles string, expected chartutil.Values) { func runAndVerifyPackageCommandValues(t *testing.T, args []string, flags map[string]string, valueFiles string, expected chartutil.Values) {
t.Helper()
outputDir := testTempDir(t) outputDir := testTempDir(t)
if len(flags) == 0 { if len(flags) == 0 {
@ -332,15 +340,16 @@ func createValuesFile(t *testing.T, data string) string {
func getChartValues(chartPath string) (chartutil.Values, error) { func getChartValues(chartPath string) (chartutil.Values, error) {
chart, err := chartutil.Load(chartPath) chart, err := loader.Load(chartPath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return chartutil.ReadValues(chart.Values) return chart.Values, nil
} }
func verifyValues(t *testing.T, actual, expected chartutil.Values) { func verifyValues(t *testing.T, actual, expected chartutil.Values) {
t.Helper()
for key, value := range expected.AsMap() { for key, value := range expected.AsMap() {
if got := actual[key]; got != value { if got := actual[key]; got != value {
t.Errorf("Expected %q, got %q (%v)", value, got, actual) t.Errorf("Expected %q, got %q (%v)", value, got, actual)

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2017 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -33,7 +33,7 @@ import (
"k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/repo"
) )
const fetchDesc = ` const pullDesc = `
Retrieve a package from a package repository, and download it locally. Retrieve a package from a package repository, and download it locally.
This is useful for fetching packages to inspect, modify, or repackage. It can This is useful for fetching packages to inspect, modify, or repackage. It can
@ -48,7 +48,7 @@ file, and MUST pass the verification process. Failure in any part of this will
result in an error, and the chart will not be saved locally. result in an error, and the chart will not be saved locally.
` `
type fetchOptions struct { type pullOptions struct {
destdir string // --destination destdir string // --destination
devel bool // --devel devel bool // --devel
untar bool // --untar untar bool // --untar
@ -60,14 +60,15 @@ type fetchOptions struct {
chartPathOptions chartPathOptions
} }
func newFetchCmd(out io.Writer) *cobra.Command { func newPullCmd(out io.Writer) *cobra.Command {
o := &fetchOptions{} o := &pullOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "fetch [chart URL | repo/chartname] [...]", Use: "pull [chart URL | repo/chartname] [...]",
Short: "download a chart from a repository and (optionally) unpack it in local directory", Short: "download a chart from a repository and (optionally) unpack it in local directory",
Long: fetchDesc, Aliases: []string{"fetch"},
Args: require.MinimumNArgs(1), Long: pullDesc,
Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if o.version == "" && o.devel { if o.version == "" && o.devel {
debug("setting version to >0.0.0-0") debug("setting version to >0.0.0-0")
@ -96,7 +97,7 @@ func newFetchCmd(out io.Writer) *cobra.Command {
return cmd return cmd
} }
func (o *fetchOptions) run(out io.Writer) error { func (o *pullOptions) run(out io.Writer) error {
c := downloader.ChartDownloader{ c := downloader.ChartDownloader{
HelmHome: settings.Home, HelmHome: settings.Home,
Out: out, Out: out,

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import (
"k8s.io/helm/pkg/repo/repotest" "k8s.io/helm/pkg/repo/repotest"
) )
func TestFetchCmd(t *testing.T) { func TestPullCmd(t *testing.T) {
defer resetEnv()() defer resetEnv()()
hh := testHelmHome(t) hh := testHelmHome(t)

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
@ -45,7 +45,7 @@ func TestUpdateCmd(t *testing.T) {
} }
o := &repoUpdateOptions{ o := &repoUpdateOptions{
update: updater, update: updater,
home: helmpath.Home(hh), home: hh,
} }
if err := o.run(out); err != nil { if err := o.run(out); err != nil {
t.Fatal(err) t.Fatal(err)

@ -1,5 +1,5 @@
/* /*
Copyright 2018 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2018 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ func newRootCmd(c helm.Interface, out io.Writer, args []string) *cobra.Command {
// chart commands // chart commands
newCreateCmd(out), newCreateCmd(out),
newDependencyCmd(out), newDependencyCmd(out),
newFetchCmd(out), newPullCmd(out),
newInspectCmd(out), newInspectCmd(out),
newLintCmd(out), newLintCmd(out),
newPackageCmd(out), newPackageCmd(out),
@ -71,7 +71,6 @@ func newRootCmd(c helm.Interface, out io.Writer, args []string) *cobra.Command {
newVerifyCmd(out), newVerifyCmd(out),
// release commands // release commands
newDeleteCmd(c, out),
newGetCmd(c, out), newGetCmd(c, out),
newHistoryCmd(c, out), newHistoryCmd(c, out),
newInstallCmd(c, out), newInstallCmd(c, out),
@ -79,6 +78,7 @@ func newRootCmd(c helm.Interface, out io.Writer, args []string) *cobra.Command {
newReleaseTestCmd(c, out), newReleaseTestCmd(c, out),
newRollbackCmd(c, out), newRollbackCmd(c, out),
newStatusCmd(c, out), newStatusCmd(c, out),
newUninstallCmd(c, out),
newUpgradeCmd(c, out), newUpgradeCmd(c, out),
newCompletionCmd(out), newCompletionCmd(out),

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import (
"strings" "strings"
"testing" "testing"
"k8s.io/helm/pkg/hapi/chart" "k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/repo"
) )

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
Copyright 2017 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import (
func TestStatusCmd(t *testing.T) { func TestStatusCmd(t *testing.T) {
releasesMockWithStatus := func(info *release.Info) []*release.Release { releasesMockWithStatus := func(info *release.Info) []*release.Release {
info.LastDeployed = time.Unix(1452902400, 0) info.LastDeployed = time.Unix(1452902400, 0).UTC()
return []*release.Release{{ return []*release.Release{{
Name: "flummoxed-chickadee", Name: "flummoxed-chickadee",
Info: info, Info: info,

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -27,16 +27,17 @@ import (
"time" "time"
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
"github.com/ghodss/yaml"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require" "k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine" "k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/hapi/release" "k8s.io/helm/pkg/hapi/release"
util "k8s.io/helm/pkg/releaseutil" util "k8s.io/helm/pkg/releaseutil"
"k8s.io/helm/pkg/tiller" "k8s.io/helm/pkg/tiller"
tversion "k8s.io/helm/pkg/version"
) )
const defaultDirectoryPermission = 0755 const defaultDirectoryPermission = 0755
@ -145,30 +146,32 @@ func (o *templateOptions) run(out io.Writer) error {
// If template is specified, try to run the template. // If template is specified, try to run the template.
if o.nameTemplate != "" { if o.nameTemplate != "" {
o.releaseName, err = generateName(o.nameTemplate) o.releaseName, err = templateName(o.nameTemplate)
if err != nil { if err != nil {
return err return err
} }
} }
// Check chart requirements to make sure all dependencies are present in /charts // Check chart requirements to make sure all dependencies are present in /charts
c, err := chartutil.Load(o.chartPath) c, err := loader.Load(o.chartPath)
if err != nil { if err != nil {
return err return err
} }
if req, err := chartutil.LoadRequirements(c); err == nil { if req := c.Metadata.Requirements; req != nil {
if err := checkDependencies(c, req); err != nil { if err := checkDependencies(c, req); err != nil {
return err return err
} }
} else if err != chartutil.ErrRequirementsNotFound {
return errors.Wrap(err, "cannot load requirements")
} }
options := chartutil.ReleaseOptions{ options := chartutil.ReleaseOptions{
Name: o.releaseName, Name: o.releaseName,
} }
if err := chartutil.ProcessRequirementsEnabled(c, config); err != nil { var m map[string]interface{}
if err := yaml.Unmarshal(config, &m); err != nil {
return err
}
if err := chartutil.ProcessRequirementsEnabled(c, m); err != nil {
return err return err
} }
if err := chartutil.ProcessRequirementsImportValues(c); err != nil { if err := chartutil.ProcessRequirementsImportValues(c); err != nil {
@ -178,22 +181,18 @@ func (o *templateOptions) run(out io.Writer) error {
// Set up engine. // Set up engine.
renderer := engine.New() renderer := engine.New()
caps := &chartutil.Capabilities{
APIVersions: chartutil.DefaultVersionSet,
KubeVersion: chartutil.DefaultKubeVersion,
HelmVersion: tversion.GetBuildInfo(),
}
// kubernetes version // kubernetes version
kv, err := semver.NewVersion(o.kubeVersion) kv, err := semver.NewVersion(o.kubeVersion)
if err != nil { if err != nil {
return errors.Wrap(err, "could not parse a kubernetes version") return errors.Wrap(err, "could not parse a kubernetes version")
} }
caps := chartutil.DefaultCapabilities
caps.KubeVersion.Major = fmt.Sprint(kv.Major()) caps.KubeVersion.Major = fmt.Sprint(kv.Major())
caps.KubeVersion.Minor = fmt.Sprint(kv.Minor()) caps.KubeVersion.Minor = fmt.Sprint(kv.Minor())
caps.KubeVersion.GitVersion = fmt.Sprintf("v%d.%d.0", kv.Major(), kv.Minor()) caps.KubeVersion.GitVersion = fmt.Sprintf("v%d.%d.0", kv.Major(), kv.Minor())
vals, err := chartutil.ToRenderValuesCaps(c, config, options, caps) vals, err := chartutil.ToRenderValues(c, config, options, caps)
if err != nil { if err != nil {
return err return err
} }

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -1,3 +0,0 @@
Error: "helm delete" requires at least 1 argument
Usage: helm delete RELEASE_NAME [...] [flags]

@ -1 +0,0 @@
release "aeneas" deleted

@ -1 +0,0 @@
release "aeneas" deleted

@ -1 +0,0 @@
release "aeneas" deleted

@ -1 +0,0 @@
release "aeneas" deleted

@ -1,4 +1,5 @@
NAME VERSION REPOSITORY STATUS NAME VERSION REPOSITORY STATUS
reqsubchart 0.1.0 https://example.com/charts missing reqsubchart 0.1.0 https://example.com/charts missing
reqsubchart2 0.2.0 https://example.com/charts missing reqsubchart2 0.2.0 https://example.com/charts missing
reqsubchart3 >=0.1.0 https://example.com/charts missing

@ -1,3 +1,3 @@
Error: "helm install" requires 1 argument Error: "helm install" requires at least 1 argument
Usage: helm install [CHART] [flags] Usage: helm install [NAME] [CHART] [flags]

@ -0,0 +1,3 @@
Error: "helm uninstall" requires at least 1 argument
Usage: helm uninstall RELEASE_NAME [...] [flags]

@ -0,0 +1 @@
release "aeneas" uninstalled

@ -0,0 +1 @@
release "aeneas" uninstalled

@ -0,0 +1 @@
release "aeneas" uninstalled

@ -0,0 +1 @@
release "aeneas" uninstalled

@ -1 +1 @@
Error: cannot load requirements: error converting YAML to JSON: yaml: line 2: did not find expected '-' indicator Error: cannot load Chart.yaml: error converting YAML to JSON: yaml: line 5: did not find expected '-' indicator

@ -1,2 +1 @@
# The pod name
Name: my-alpine Name: my-alpine

@ -1,3 +1,7 @@
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: chart-missing-deps name: chart-missing-deps
version: 0.1.0 version: 0.1.0
dependencies:
- name: reqsubchart
version: 0.1.0
repository: "https://example.com/charts"

@ -1,3 +1,10 @@
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: chart-missing-deps name: chart-missing-deps
version: 0.1.0 version: 0.1.0
dependencies:
- name: reqsubchart
version: 0.1.0
repository: "https://example.com/charts"
- name: reqsubchart2
version: 0.2.0
repository: "https://example.com/charts"

@ -0,0 +1,6 @@
description: Deploy a basic Alpine Linux pod
home: https://k8s.io/helm
name: alpine
sources:
- https://github.com/kubernetes/helm
version: 0.1.0

@ -0,0 +1,13 @@
#Alpine: A simple Helm chart
Run a single pod of Alpine Linux.
This example was generated using the command `helm create alpine`.
The `templates/` directory contains a very simple pod resource with a
couple of parameters.
The `values.yaml` file contains the default values for the
`alpine-pod.yaml` template.
You can install this example using `helm install docs/examples/alpine`.

@ -0,0 +1,2 @@
test:
Name: extra-values

@ -0,0 +1,2 @@
test:
Name: more-values

@ -0,0 +1,25 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{.Release.Name}}-{{.Values.Name}}"
labels:
# The "heritage" label is used to track which tool deployed a given chart.
# It is useful for admins who want to see what releases a particular tool
# is responsible for.
heritage: {{.Release.Service | quote }}
# The "release" convention makes it easy to tie a release to all of the
# Kubernetes resources that were created as part of that release.
release: {{.Release.Name | quote }}
# This makes it easy to audit chart usage.
chart: "{{.Chart.Name}}-{{.Chart.Version}}"
values: {{.Values.test.Name}}
spec:
# This shows how to use a simple value. This will look for a passed-in value
# called restartPolicy. If it is not found, it will use the default value.
# {{default "Never" .restartPolicy}} is a slightly optimized version of the
# more conventional syntax: {{.restartPolicy | default "Never"}}
restartPolicy: {{default "Never" .Values.restartPolicy}}
containers:
- name: waiter
image: "alpine:3.3"
command: ["/bin/sleep","9000"]

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save