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
# Copyright 2016 The Kubernetes Authors All rights reserved.
# Copyright The Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
#!/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");
# you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
#!/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");
# 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"
branch = "master"
[[constraint]]
name = "github.com/technosophos/moniker"
branch = "master"
[[constraint]]
name = "k8s.io/api"
branch = "release-1.10"
branch = "release-1.12"
[[constraint]]
name = "k8s.io/apimachinery"
branch = "release-1.10"
branch = "release-1.12"
[[constraint]]
version = "kubernetes-1.10.0"
version = "kubernetes-1.12.1"
name = "k8s.io/client-go"
[[constraint]]
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]
go-tests = true

@ -1,6 +1,7 @@
BINDIR := $(CURDIR)/bin
DIST_DIRS := find * -type d -exec
TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64
BINNAME ?= helm
# go option
GO ?= go
@ -41,12 +42,12 @@ all: build
.PHONY: 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
build-cross: LDFLAGS += -extldflags "-static"
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
dist:

@ -20,9 +20,8 @@ Use Helm to:
Helm is a tool that streamlines installing and managing Kubernetes applications.
Think of it like apt/yum/homebrew for Kubernetes.
- Helm has two parts: a client (`helm`) and a server (`tiller`)
- Tiller runs inside of your Kubernetes cluster, and manages releases (installations)
of your charts.
- Helm has two parts: a client (`helm`) and a library
- The library renders your templates and communicates with the Kubernetes API
- Helm runs on your laptop, CI/CD, or wherever you want it to run.
- Charts are Helm packages that contain at least two things:
- 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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
@ -24,8 +24,8 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
)
const createDesc = `
@ -80,7 +80,7 @@ func (o *createOptions) run(out io.Writer) error {
Description: "A Helm chart for Kubernetes",
Version: "0.1.0",
AppVersion: "1.0",
APIVersion: chartutil.APIVersionv1,
APIVersion: chart.APIVersionv1,
}
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");
you may not use this file except in compliance with the License.
@ -23,8 +23,9 @@ import (
"path/filepath"
"testing"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
)
func TestCreateCmd(t *testing.T) {
@ -46,15 +47,15 @@ func TestCreateCmd(t *testing.T) {
t.Fatalf("chart is not directory")
}
c, err := chartutil.LoadDir(cname)
c, err := loader.LoadDir(cname)
if err != nil {
t.Fatal(err)
}
if c.Metadata.Name != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name)
if c.Name() != cname {
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)
}
}
@ -97,15 +98,15 @@ func TestCreateStarterCmd(t *testing.T) {
t.Fatalf("chart is not directory")
}
c, err := chartutil.LoadDir(cname)
c, err := loader.LoadDir(cname)
if err != nil {
t.Fatal(err)
}
if c.Metadata.Name != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name)
if c.Name() != cname {
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)
}

@ -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");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -26,7 +26,8 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
)
const dependencyDesc = `
@ -130,27 +131,23 @@ func newDependencyListCmd(out io.Writer) *cobra.Command {
}
func (o *dependencyLisOptions) run(out io.Writer) error {
c, err := chartutil.Load(o.chartpath)
c, err := loader.Load(o.chartpath)
if err != nil {
return err
}
r, err := chartutil.LoadRequirements(c)
if err != nil {
if err == chartutil.ErrRequirementsNotFound {
if c.Metadata.Requirements == 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)
o.printMissing(out, r)
o.printMissing(out, c.Metadata.Requirements)
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, "*")
archives, err := filepath.Glob(filepath.Join(o.chartpath, "charts", filename))
if err != nil {
@ -160,11 +157,11 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) strin
} else if len(archives) == 1 {
archive := archives[0]
if _, err := os.Stat(archive); err == nil {
c, err := chartutil.Load(archive)
c, err := loader.Load(archive)
if err != nil {
return "corrupt"
}
if c.Metadata.Name != dep.Name {
if c.Name() != dep.Name {
return "misnamed"
}
@ -195,12 +192,12 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) strin
return "mispackaged"
}
c, err := chartutil.Load(folder)
c, err := loader.Load(folder)
if err != nil {
return "corrupt"
}
if c.Metadata.Name != dep.Name {
if c.Name() != dep.Name {
return "misnamed"
}
@ -225,18 +222,18 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chartutil.Dependency) strin
}
// 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.MaxColWidth = 80
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))
}
fmt.Fprintln(out, table)
}
// 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/*")
files, err := filepath.Glob(folder)
if err != nil {
@ -253,20 +250,20 @@ func (o *dependencyLisOptions) printMissing(out io.Writer, reqs *chartutil.Requi
if !fi.IsDir() && filepath.Ext(f) != ".tgz" {
continue
}
c, err := chartutil.Load(f)
c, err := loader.Load(f)
if err != nil {
fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f)
continue
}
found := false
for _, d := range reqs.Dependencies {
if d.Name == c.Metadata.Name {
for _, d := range reqs {
if d.Name == c.Name() {
found = true
break
}
}
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");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -26,7 +26,7 @@ import (
)
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
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{
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,
Args: require.MaximumNArgs(1),
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");
you may not use this file except in compliance with the License.
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,
// 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 {
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -28,18 +28,18 @@ import (
)
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
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
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
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'
@ -63,7 +63,7 @@ func newDependencyUpdateCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "update CHART",
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,
Args: require.MaximumNArgs(1),
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");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -24,11 +24,8 @@ import (
"strings"
"testing"
"github.com/ghodss/yaml"
"k8s.io/helm/pkg/chart"
"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/repo"
"k8s.io/helm/pkg/repo/repotest"
@ -50,7 +47,8 @@ func TestDependencyUpdateCmd(t *testing.T) {
t.Logf("Listening on directory %s", srv.Root())
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)
}
@ -88,14 +86,12 @@ func TestDependencyUpdateCmd(t *testing.T) {
// Now change the dependencies and update. This verifies that on update,
// old dependencies are cleansed and new dependencies are added.
reqfile := &chartutil.Requirements{
Dependencies: []*chartutil.Dependency{
md.Requirements = []*chart.Dependency{
{Name: "reqtest", Version: "0.1.0", Repository: srv.URL()},
{Name: "compressedchart", Version: "0.3.0", Repository: srv.URL()},
},
}
dir := hh.Path(chartname)
if err := writeRequirements(dir, reqfile); err != nil {
dir := hh.Path(chartname, "Chart.yaml")
if err := chartutil.SaveChartfile(dir, md); err != nil {
t.Fatal(err)
}
@ -170,7 +166,7 @@ func TestDependencyUpdateCmd_DontDeleteOldChartsOnError(t *testing.T) {
out := bytes.NewBuffer(nil)
o := &dependencyUpdateOptions{}
o.helmhome = helmpath.Home(hh)
o.helmhome = hh
o.chartpath = hh.Path(chartname)
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.
func createTestingChart(dest, name, baseURL string) error {
cfile := &chart.Metadata{
func createTestingMetadata(name, baseURL string) *chart.Metadata {
return &chart.Metadata{
Name: name,
Version: "1.2.3",
}
dir := filepath.Join(dest, name)
_, err := chartutil.Create(cfile, dest)
if err != nil {
return err
}
req := &chartutil.Requirements{
Dependencies: []*chartutil.Dependency{
Requirements: []*chart.Dependency{
{Name: "reqtest", 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 {
data, err := yaml.Marshal(req)
if err != nil {
// createTestingChart creates a basic chart that depends on reqtest-0.1.0
//
// The baseURL can be used to point to a particular repository server.
func createTestingChart(dest, name, baseURL string) error {
cfile := createTestingMetadata(name, baseURL)
_, err := chartutil.Create(cfile, dest)
return err
}
return ioutil.WriteFile(filepath.Join(dir, "requirements.yaml"), data, 0655)
}

@ -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");
you may not use this file except in compliance with the License.
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");
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");
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");
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");
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");
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");
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");
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");
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");
you may not use this file except in compliance with the License.
@ -23,8 +23,8 @@ import (
"sync"
// Import to initialize client auth plugins.
"k8s.io/cli-runtime/pkg/genericclioptions"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm/environment"
@ -34,7 +34,7 @@ import (
var (
settings environment.EnvSettings
config clientcmd.ClientConfig
config genericclioptions.RESTClientGetter
configOnce sync.Once
)
@ -89,7 +89,7 @@ func newClient(allNamespaces bool) helm.Interface {
)
}
func kubeConfig() clientcmd.ClientConfig {
func kubeConfig() genericclioptions.RESTClientGetter {
configOnce.Do(func() {
config = kube.GetConfig(settings.KubeConfig, settings.KubeContext, settings.Namespace)
})
@ -97,7 +97,7 @@ func kubeConfig() clientcmd.ClientConfig {
}
func getNamespace() string {
if ns, _, err := kubeConfig().Namespace(); err == nil {
if ns, _, err := kubeConfig().ToRawKubeConfigLoader().Namespace(); err == nil {
return ns
}
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");
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 {
t.Log("Updating repository file format...")
if err := r.WriteFile(repoFile, 0644); err != nil {
t.Fatal(err)
}
}
t.Logf("$HELM_HOME has been configured at %s.\n", home)
}
// 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");
you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import (
"github.com/spf13/cobra"
"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/helm"
)
@ -167,5 +167,5 @@ func formatChartname(c *chart.Chart) string {
// know how: https://github.com/kubernetes/helm/issues/1347
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");
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");
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");
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");
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");
you may not use this file except in compliance with the License.
@ -25,8 +25,8 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
)
const inspectDesc = `
@ -146,7 +146,7 @@ func newInspectCmd(out io.Writer) *cobra.Command {
}
func (i *inspectOptions) run(out io.Writer) error {
chrt, err := chartutil.Load(i.chartpath)
chrt, err := loader.Load(i.chartpath)
if err != nil {
return err
}
@ -163,7 +163,11 @@ func (i *inspectOptions) run(out io.Writer) error {
if i.output == all {
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 {

@ -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");
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");
you may not use this file except in compliance with the License.
@ -20,18 +20,20 @@ import (
"bytes"
"fmt"
"io"
"path/filepath"
"strings"
"text/template"
"time"
"github.com/Masterminds/sprig"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"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/getter"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/hapi/release"
"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
a string value use '--set-string'.
$ helm install -f myvalues.yaml ./redis
$ helm install -f myvalues.yaml myredis ./redis
or
$ helm install --set name=prod ./redis
$ helm install --set name=prod myredis ./redis
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
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:
$ 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
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:
$ 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,
@ -99,7 +101,7 @@ charts in a repository, use 'helm search'.
`
type installOptions struct {
name string // --name
name string // arg 0
dryRun bool // --dry-run
disableHooks bool // --disable-hooks
replace bool // --replace
@ -108,7 +110,8 @@ type installOptions struct {
wait bool // --wait
devel bool // --devel
depUp bool // --dep-up
chartPath string // arg
chartPath string // arg 1
generateName bool // --generate-name
valuesOptions
chartPathOptions
@ -120,10 +123,10 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
o := &installOptions{client: c}
cmd := &cobra.Command{
Use: "install [CHART]",
Short: "install a chart archive",
Use: "install [NAME] [CHART]",
Short: "install a chart",
Long: installDesc,
Args: require.ExactArgs(1),
Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
debug("Original chart version: %q", o.version)
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"
}
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 {
return err
}
@ -142,7 +151,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
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.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")
@ -157,6 +166,41 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
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 {
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 o.nameTemplate != "" {
o.name, err = generateName(o.nameTemplate)
o.name, err = templateName(o.nameTemplate)
if err != nil {
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
chartRequested, err := chartutil.Load(o.chartPath)
chartRequested, err := loader.Load(o.chartPath)
if err != nil {
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.
// As of Helm 2.4.0, this is treated as a stopping condition:
// 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(
@ -272,42 +314,34 @@ func (o *installOptions) printRelease(out io.Writer, rel *release.Release) {
if rel == nil {
return
}
// TODO: Switch to text/template like everything else.
fmt.Fprintf(out, "NAME: %s\n", rel.Name)
if settings.Debug {
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)
if err != nil {
return "", err
}
var b bytes.Buffer
err = t.Execute(&b, nil)
if err != nil {
return "", err
}
return b.String(), nil
return b.String(), err
}
func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements) error {
missing := []string{}
func checkDependencies(ch *chart.Chart, reqs []*chart.Dependency) error {
var missing []string
deps := ch.Dependencies
for _, r := range reqs.Dependencies {
found := false
for _, d := range deps {
if d.Metadata.Name == r.Name {
found = true
break
OUTER:
for _, r := range reqs {
for _, d := range ch.Dependencies() {
if d.Name() == r.Name {
continue OUTER
}
}
if !found {
missing = append(missing, r.Name)
}
}
if len(missing) > 0 {
return errors.Errorf("found in requirements.yaml, but missing in charts/ directory: %s", strings.Join(missing, ", "))

@ -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");
you may not use this file except in compliance with the License.
@ -27,37 +27,37 @@ func TestInstall(t *testing.T) {
// Install, base case
{
name: "basic install",
cmd: "install testdata/testcharts/alpine --name aeneas",
cmd: "install aeneas testdata/testcharts/alpine ",
golden: "output/install.txt",
},
// Install, no 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",
},
// Install, values from cli
{
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",
},
// Install, values from cli via multiple --set
{
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",
},
// Install, values from yaml
{
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",
},
// Install, values from multiple yaml
{
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",
},
// Install, no charts
@ -70,19 +70,19 @@ func TestInstall(t *testing.T) {
// Install, re-use name
{
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",
},
// Install, with 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",
},
// Install, with 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",
},
// Install, using the name-template
@ -94,28 +94,28 @@ func TestInstall(t *testing.T) {
// Install, perform chart verification along the way.
{
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,
},
{
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,
},
{
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
{
name: "install chart with missing dependencies",
cmd: "install testdata/testcharts/chart-missing-deps",
cmd: "install nodeps testdata/testcharts/chart-missing-deps",
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",
cmd: "install testdata/testcharts/chart-bad-requirements",
name: "install chart with bad dependencies in Chart.yaml",
cmd: "install badreq testdata/testcharts/chart-bad-requirements",
wantError: true,
},
}
@ -165,7 +165,7 @@ func TestNameTemplate(t *testing.T) {
for _, tc := range testCases {
n, err := generateName(tc.tpl)
n, err := templateName(tc.tpl)
if err != nil {
if tc.expectedErrorStr == "" {
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");
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");
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");
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.
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:
'--deleted --failed'.
'--uninstalled' and '--all' will alter this behavior. Such flags can be combined:
'--uninstalled --failed'.
By default, items are sorted alphabetically. Use the '-d' flag to sort by
release date.
@ -63,8 +63,8 @@ type listOptions struct {
allNamespaces bool // --all-namespaces
byDate bool // --date
colWidth uint // --col-width
deleted bool // --deleted
deleting bool // --deleting
uninstalled bool // --uninstalled
uninstalling bool // --uninstalling
deployed bool // --deployed
failed bool // --failed
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.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.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.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.failed, "failed", false, "show failed releases")
f.BoolVar(&o.pending, "pending", false, "show pending releases")
@ -188,8 +188,8 @@ func (o *listOptions) statusCodes() []release.ReleaseStatus {
return []release.ReleaseStatus{
release.StatusUnknown,
release.StatusDeployed,
release.StatusDeleted,
release.StatusDeleting,
release.StatusUninstalled,
release.StatusUninstalling,
release.StatusFailed,
release.StatusPendingInstall,
release.StatusPendingUpgrade,
@ -200,11 +200,11 @@ func (o *listOptions) statusCodes() []release.ReleaseStatus {
if o.deployed {
status = append(status, release.StatusDeployed)
}
if o.deleted {
status = append(status, release.StatusDeleted)
if o.uninstalled {
status = append(status, release.StatusUninstalled)
}
if o.deleting {
status = append(status, release.StatusDeleting)
if o.uninstalling {
status = append(status, release.StatusUninstalling)
}
if o.failed {
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");
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",
}, {
name: "with a release, multiple flags",
cmd: "list --deleted --deployed --failed -q",
cmd: "list --uninstalled --deployed --failed -q",
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}),
},
// 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",
cmd: "list --all -q",
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}),
},
// See note on previous test.
@ -69,7 +69,7 @@ func TestListCmd(t *testing.T) {
name: "with a release, multiple flags, deleting",
cmd: "list --all -q",
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}),
},
// 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");
you may not use this file except in compliance with the License.
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");
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");
you may not use this file except in compliance with the License.
@ -25,15 +25,15 @@ import (
"syscall"
"github.com/Masterminds/semver"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"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/downloader"
"k8s.io/helm/pkg/getter"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/helm/helmpath"
"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.appVersion, "app-version", "", "set the appVersion on the chart to this version")
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)
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 {
return err
}
@ -142,11 +142,7 @@ func (o *packageOptions) run(out io.Writer) error {
if err != nil {
return err
}
newVals, err := yaml.Marshal(combinedVals)
if err != nil {
return err
}
ch.Values = newVals
ch.Values = combinedVals
// If version is set, modify the version.
if len(o.version) != 0 {
@ -161,18 +157,10 @@ func (o *packageOptions) run(out io.Writer) error {
debug("Setting appVersion to %s", o.appVersion)
}
if filepath.Base(path) != ch.Metadata.Name {
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 reqs := ch.Metadata.Requirements; reqs != nil {
if err := checkDependencies(ch, reqs); err != nil {
return err
}
} else {
if err != chartutil.ErrRequirementsNotFound {
return err
}
}
var dest string
@ -188,11 +176,10 @@ func (o *packageOptions) run(out io.Writer) error {
}
name, err := chartutil.Save(ch, dest)
if err == nil {
fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", name)
} else {
if err != nil {
return errors.Wrap(err, "failed to save")
}
fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", name)
if o.sign {
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");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -26,8 +26,9 @@ import (
"github.com/spf13/cobra"
"k8s.io/helm/pkg/chart"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/helm/helmpath"
)
@ -97,6 +98,12 @@ func TestPackage(t *testing.T) {
expect: "",
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",
args: []string{"testdata/testcharts/alpine"},
@ -206,7 +213,7 @@ func TestSetAppVersion(t *testing.T) {
tmp := testTempDir(t)
hh := testHelmHome(t)
settings.Home = helmpath.Home(hh)
settings.Home = hh
c := newPackageCmd(&bytes.Buffer{})
flags := map[string]string{
@ -224,7 +231,7 @@ func TestSetAppVersion(t *testing.T) {
} else if fi.Size() == 0 {
t.Errorf("file %q has zero bytes.", chartPath)
}
ch, err := chartutil.Load(chartPath)
ch, err := loader.Load(chartPath)
if err != nil {
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) {
t.Helper()
outputDir := testTempDir(t)
if len(flags) == 0 {
@ -332,15 +340,16 @@ func createValuesFile(t *testing.T, data string) string {
func getChartValues(chartPath string) (chartutil.Values, error) {
chart, err := chartutil.Load(chartPath)
chart, err := loader.Load(chartPath)
if err != nil {
return nil, err
}
return chartutil.ReadValues(chart.Values)
return chart.Values, nil
}
func verifyValues(t *testing.T, actual, expected chartutil.Values) {
t.Helper()
for key, value := range expected.AsMap() {
if got := actual[key]; got != value {
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
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");
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");
you may not use this file except in compliance with the License.
@ -33,7 +33,7 @@ import (
"k8s.io/helm/pkg/repo"
)
const fetchDesc = `
const pullDesc = `
Retrieve a package from a package repository, and download it locally.
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.
`
type fetchOptions struct {
type pullOptions struct {
destdir string // --destination
devel bool // --devel
untar bool // --untar
@ -60,13 +60,14 @@ type fetchOptions struct {
chartPathOptions
}
func newFetchCmd(out io.Writer) *cobra.Command {
o := &fetchOptions{}
func newPullCmd(out io.Writer) *cobra.Command {
o := &pullOptions{}
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",
Long: fetchDesc,
Aliases: []string{"fetch"},
Long: pullDesc,
Args: require.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if o.version == "" && o.devel {
@ -96,7 +97,7 @@ func newFetchCmd(out io.Writer) *cobra.Command {
return cmd
}
func (o *fetchOptions) run(out io.Writer) error {
func (o *pullOptions) run(out io.Writer) error {
c := downloader.ChartDownloader{
HelmHome: settings.Home,
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");
you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import (
"k8s.io/helm/pkg/repo/repotest"
)
func TestFetchCmd(t *testing.T) {
func TestPullCmd(t *testing.T) {
defer resetEnv()()
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
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");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -45,7 +45,7 @@ func TestUpdateCmd(t *testing.T) {
}
o := &repoUpdateOptions{
update: updater,
home: helmpath.Home(hh),
home: hh,
}
if err := o.run(out); err != nil {
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");
you may not use this file except in compliance with the License.
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");
you may not use this file except in compliance with the License.
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");
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");
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");
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
newCreateCmd(out),
newDependencyCmd(out),
newFetchCmd(out),
newPullCmd(out),
newInspectCmd(out),
newLintCmd(out),
newPackageCmd(out),
@ -71,7 +71,6 @@ func newRootCmd(c helm.Interface, out io.Writer, args []string) *cobra.Command {
newVerifyCmd(out),
// release commands
newDeleteCmd(c, out),
newGetCmd(c, out),
newHistoryCmd(c, out),
newInstallCmd(c, out),
@ -79,6 +78,7 @@ func newRootCmd(c helm.Interface, out io.Writer, args []string) *cobra.Command {
newReleaseTestCmd(c, out),
newRollbackCmd(c, out),
newStatusCmd(c, out),
newUninstallCmd(c, out),
newUpgradeCmd(c, 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");
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");
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");
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");
you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import (
"strings"
"testing"
"k8s.io/helm/pkg/hapi/chart"
"k8s.io/helm/pkg/chart"
"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");
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");
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");
you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import (
func TestStatusCmd(t *testing.T) {
releasesMockWithStatus := func(info *release.Info) []*release.Release {
info.LastDeployed = time.Unix(1452902400, 0)
info.LastDeployed = time.Unix(1452902400, 0).UTC()
return []*release.Release{{
Name: "flummoxed-chickadee",
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");
you may not use this file except in compliance with the License.
@ -27,16 +27,17 @@ import (
"time"
"github.com/Masterminds/semver"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"k8s.io/helm/cmd/helm/require"
"k8s.io/helm/pkg/chart/loader"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/hapi/release"
util "k8s.io/helm/pkg/releaseutil"
"k8s.io/helm/pkg/tiller"
tversion "k8s.io/helm/pkg/version"
)
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 o.nameTemplate != "" {
o.releaseName, err = generateName(o.nameTemplate)
o.releaseName, err = templateName(o.nameTemplate)
if err != nil {
return err
}
}
// 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 {
return err
}
if req, err := chartutil.LoadRequirements(c); err == nil {
if req := c.Metadata.Requirements; req != nil {
if err := checkDependencies(c, req); err != nil {
return err
}
} else if err != chartutil.ErrRequirementsNotFound {
return errors.Wrap(err, "cannot load requirements")
}
options := chartutil.ReleaseOptions{
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
}
if err := chartutil.ProcessRequirementsImportValues(c); err != nil {
@ -178,22 +181,18 @@ func (o *templateOptions) run(out io.Writer) error {
// Set up engine.
renderer := engine.New()
caps := &chartutil.Capabilities{
APIVersions: chartutil.DefaultVersionSet,
KubeVersion: chartutil.DefaultKubeVersion,
HelmVersion: tversion.GetBuildInfo(),
}
// kubernetes version
kv, err := semver.NewVersion(o.kubeVersion)
if err != nil {
return errors.Wrap(err, "could not parse a kubernetes version")
}
caps := chartutil.DefaultCapabilities
caps.KubeVersion.Major = fmt.Sprint(kv.Major())
caps.KubeVersion.Minor = fmt.Sprint(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 {
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");
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
reqsubchart 0.1.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

@ -1,3 +1,7 @@
description: A Helm chart for Kubernetes
name: chart-missing-deps
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
name: chart-missing-deps
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