From ee8cd8bffb536a6ab31ac89d09cced994f6838ab Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 18 Oct 2019 12:43:55 -0700 Subject: [PATCH 001/279] fix(sympath): walk symbolic links one once Signed-off-by: Matthew Fisher --- internal/sympath/walk.go | 3 +- internal/sympath/walk_test.go | 61 ++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index 196a6f489..4c5bc0950 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -73,9 +73,10 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { if info, err = os.Lstat(resolved); err != nil { return err } - if err := symwalk(resolved, info, walkFn); err != nil && err != filepath.SkipDir { + if err := symwalk(path, info, walkFn); err != nil && err != filepath.SkipDir { return err } + return nil } if err := walkFn(path, info, nil); err != nil { diff --git a/internal/sympath/walk_test.go b/internal/sympath/walk_test.go index c9364e91a..25f737134 100644 --- a/internal/sympath/walk_test.go +++ b/internal/sympath/walk_test.go @@ -27,36 +27,45 @@ import ( ) type Node struct { - name string - entries []*Node // nil if the entry is a file - mark int + name string + entries []*Node // nil if the entry is a file + marks int + expectedMarks int + symLinkedTo string } var tree = &Node{ "testdata", []*Node{ - {"a", nil, 0}, - {"b", []*Node{}, 0}, - {"c", nil, 0}, + {"a", nil, 0, 1, ""}, + {"b", []*Node{}, 0, 1, ""}, + {"c", nil, 0, 2, ""}, + {"d", nil, 0, 0, "c"}, { - "d", + "e", []*Node{ - {"x", nil, 0}, - {"y", []*Node{}, 0}, + {"x", nil, 0, 1, ""}, + {"y", []*Node{}, 0, 1, ""}, { "z", []*Node{ - {"u", nil, 0}, - {"v", nil, 0}, - {"w", nil, 0}, + {"u", nil, 0, 1, ""}, + {"v", nil, 0, 1, ""}, + {"w", nil, 0, 1, ""}, }, 0, + 1, + "", }, }, 0, + 1, + "", }, }, 0, + 1, + "", } func walkTree(n *Node, path string, f func(path string, n *Node)) { @@ -69,24 +78,32 @@ func walkTree(n *Node, path string, f func(path string, n *Node)) { func makeTree(t *testing.T) { walkTree(tree, tree.name, func(path string, n *Node) { if n.entries == nil { - fd, err := os.Create(path) - if err != nil { - t.Errorf("makeTree: %v", err) - return + if n.symLinkedTo != "" { + if err := os.Symlink(n.symLinkedTo, path); err != nil { + t.Fatalf("makeTree: %v", err) + } + } else { + fd, err := os.Create(path) + if err != nil { + t.Fatalf("makeTree: %v", err) + return + } + fd.Close() } - fd.Close() } else { - os.Mkdir(path, 0770) + if err := os.Mkdir(path, 0770); err != nil { + t.Fatalf("makeTree: %v", err) + } } }) } func checkMarks(t *testing.T, report bool) { walkTree(tree, tree.name, func(path string, n *Node) { - if n.mark != 1 && report { - t.Errorf("node %s mark = %d; expected 1", path, n.mark) + if n.marks != n.expectedMarks && report { + t.Errorf("node %s mark = %d; expected %d", path, n.marks, n.expectedMarks) } - n.mark = 0 + n.marks = 0 }) } @@ -104,7 +121,7 @@ func mark(info os.FileInfo, err error, errors *[]error, clear bool) error { name := info.Name() walkTree(tree, tree.name, func(path string, n *Node) { if n.name == name { - n.mark++ + n.marks++ } }) return nil From af498be38b6fdd29407a61c34e649f2f7632018d Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 21 Oct 2019 10:54:17 -0700 Subject: [PATCH 002/279] fix(scripts): update get script Signed-off-by: Matthew Fisher --- scripts/get | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/scripts/get b/scripts/get index e8dd25d99..3f645f807 100755 --- a/scripts/get +++ b/scripts/get @@ -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. @@ -18,7 +18,9 @@ # the package manager for Go: https://github.com/Masterminds/glide.sh/blob/master/get PROJECT_NAME="helm" +TILLER_NAME="tiller" +: ${USE_SUDO:="true"} : ${HELM_INSTALL_DIR:="/usr/local/bin"} # initArch discovers the architecture for this system. @@ -27,7 +29,7 @@ initArch() { case $ARCH in armv5*) ARCH="armv5";; armv6*) ARCH="armv6";; - armv7*) ARCH="armv7";; + armv7*) ARCH="arm";; aarch64) ARCH="arm64";; x86) ARCH="386";; x86_64) ARCH="amd64";; @@ -50,7 +52,7 @@ initOS() { runAsRoot() { local CMD="$*" - if [ $EUID -ne 0 ]; then + if [ $EUID -ne 0 -a $USE_SUDO = "true" ]; then CMD="sudo $CMD" fi @@ -75,16 +77,16 @@ verifySupported() { # checkDesiredVersion checks if the desired version is available. checkDesiredVersion() { - # Use the GitHub releases webpage for the project to find the desired version for this project. - local release_url="https://github.com/helm/helm/releases/${DESIRED_VERSION:-latest}" - if type "curl" > /dev/null; then - TAG=$(curl -SsL $release_url | awk '/\/tag\//' | grep -v no-underline | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}') - elif type "wget" > /dev/null; then - TAG=$(wget -q -O - $release_url | awk '/\/tag\//' | grep -v no-underline | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}') - fi - if [ "x$TAG" == "x" ]; then - echo "Cannot determine ${DESIRED_VERSION} tag." - exit 1 + if [ "x$DESIRED_VERSION" == "x" ]; then + # Get tag from release URL + local latest_release_url="https://github.com/helm/helm/releases/latest" + if type "curl" > /dev/null; then + TAG=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) + elif type "wget" > /dev/null; then + TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") + fi + else + TAG=$DESIRED_VERSION fi } @@ -92,7 +94,7 @@ checkDesiredVersion() { # if it needs to be changed. checkHelmInstalledVersion() { if [[ -f "${HELM_INSTALL_DIR}/${PROJECT_NAME}" ]]; then - local version=$(helm version | grep '^Client' | cut -d'"' -f2) + local version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version -c | grep '^Client' | cut -d'"' -f2) if [[ "$version" == "$TAG" ]]; then echo "Helm ${version} is already ${DESIRED_VERSION:-latest}" return 0 @@ -141,8 +143,16 @@ installFile() { mkdir -p "$HELM_TMP" tar xf "$HELM_TMP_FILE" -C "$HELM_TMP" HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME" - echo "Preparing to install into ${HELM_INSTALL_DIR}" + TILLER_TMP_BIN="$HELM_TMP/$OS-$ARCH/$TILLER_NAME" + echo "Preparing to install $PROJECT_NAME and $TILLER_NAME into ${HELM_INSTALL_DIR}" runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR" + echo "$PROJECT_NAME installed into $HELM_INSTALL_DIR/$PROJECT_NAME" + if [ -x "$TILLER_TMP_BIN" ]; then + runAsRoot cp "$TILLER_TMP_BIN" "$HELM_INSTALL_DIR" + echo "$TILLER_NAME installed into $HELM_INSTALL_DIR/$TILLER_NAME" + else + echo "info: $TILLER_NAME binary was not found in this release; skipping $TILLER_NAME installation" + fi } # fail_trap is executed if an error occurs. @@ -164,7 +174,6 @@ fail_trap() { # testVersion tests the installed client to make sure it is working. testVersion() { set +e - echo "$PROJECT_NAME installed into $HELM_INSTALL_DIR/$PROJECT_NAME" HELM="$(which $PROJECT_NAME)" if [ "$?" = "1" ]; then echo "$PROJECT_NAME not found. Is $HELM_INSTALL_DIR on your "'$PATH?' @@ -180,6 +189,7 @@ help () { echo -e "\t[--help|-h ] ->> prints this help" echo -e "\t[--version|-v ] . When not defined it defaults to latest" echo -e "\te.g. --version v2.4.0 or -v latest" + echo -e "\t[--no-sudo] ->> install without sudo" } # cleanup temporary files to avoid https://github.com/helm/helm/issues/2977 @@ -209,6 +219,9 @@ while [[ $# -gt 0 ]]; do exit 0 fi ;; + '--no-sudo') + USE_SUDO="false" + ;; '--help'|-h) help exit 0 From 2f2430a9ad11a74b78a2fce37cb194831a1ed6c7 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 21 Oct 2019 11:16:33 -0700 Subject: [PATCH 003/279] fix(ci): update to work as master Signed-off-by: Matthew Fisher --- .circleci/deploy.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh index f6881eadb..bbb08e6f0 100755 --- a/.circleci/deploy.sh +++ b/.circleci/deploy.sh @@ -28,8 +28,6 @@ if [[ -n "${CIRCLE_TAG:-}" ]]; then VERSION="${CIRCLE_TAG}" elif [[ "${CIRCLE_BRANCH:-}" == "master" ]]; then VERSION="canary" -elif [[ "${CIRCLE_BRANCH:-}" == "dev-v3" ]]; then - VERSION="dev-v3" else echo "Skipping deploy step; this is neither a releasable branch or a tag" exit From ac86c75b3718d558d36b4aa80b669ad6ce581fa0 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 17 Oct 2019 20:58:09 -0400 Subject: [PATCH 004/279] feat(comp): Dynamic completion of charts helm show - completes to chart (ref, path, url) helm pull - completes to chart (ref, url) helm install [NAME] - completes to chart (ref, path, url) helm template [NAME] - completes to chart (ref, path, url) helm upgrade - completes to release name helm upgrade - completes to chart (ref, path, url) Signed-off-by: Marc Khouzam --- cmd/helm/root.go | 145 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 5 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index d40d9fa95..a03f77576 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -67,6 +67,11 @@ __helm_override_flags_to_kubectl_flags() echo "$1" | sed s/kube-context/context/ } +__helm_get_repos() +{ + eval $(__helm_binary_name) repo list 2>/dev/null | tail +2 | cut -f1 +} + __helm_get_contexts() { __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" @@ -106,6 +111,104 @@ __helm_binary_name() echo ${helm_binary} } +# This function prevents the zsh shell from adding a space after +# a completion by adding a second, fake completion +__helm_zsh_comp_nospace() { + __helm_debug "${FUNCNAME[0]}: in is ${in[*]}" + + local out in=("$@") + + # The shell will normally add a space after these completions. + # To avoid that we should use "compopt -o nospace". However, it is not + # available in zsh. + # Instead, we trick the shell by pretending there is a second, longer match. + # We only do this if there is a single choice left for completion + # to reduce the times the user could be presented with the fake completion choice. + + out=($(echo ${in[*]} | tr " " "\n" | \grep "^${cur}")) + __helm_debug "${FUNCNAME[0]}: out is ${out[*]}" + + [ ${#out[*]} -eq 1 ] && out+=("${out}.") + + __helm_debug "${FUNCNAME[0]}: out is now ${out[*]}" + + echo "${out[*]}" +} + +# $1 = 1 if the completion should include local charts (which means file completion) +__helm_list_charts() +{ + __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" + local repo url file out=() nospace=0 wantFiles=$1 + + # Handle completions for repos + for repo in $(__helm_get_repos); do + if [[ "${cur}" =~ ^${repo}/.* ]]; then + # We are doing completion from within a repo + out=$(eval $(__helm_binary_name) search repo ${cur} 2>/dev/null | cut -f1 | \grep ^${cur}) + nospace=0 + elif [[ ${repo} =~ ^${cur}.* ]]; then + # We are completing a repo name + out+=(${repo}/) + nospace=1 + fi + done + __helm_debug "${FUNCNAME[0]}: out after repos is ${out[*]}" + + # Handle completions for url prefixes + for url in https:// http:// file://; do + if [[ "${cur}" =~ ^${url}.* ]]; then + # The user already put in the full url prefix. Return it + # back as a completion to avoid the shell doing path completion + out="${cur}" + nospace=1 + elif [[ ${url} =~ ^${cur}.* ]]; then + # We are completing a url prefix + out+=(${url}) + nospace=1 + fi + done + __helm_debug "${FUNCNAME[0]}: out after urls is ${out[*]}" + + # Handle completion for files. + # We only do this if: + # 1- There are other completions found (if there are no completions, + # the shell will do file completion itself) + # 2- If there is some input from the user (or else we will end up + # lising the entire content of the current directory which will + # be too many choices for the user to find the real repos) + if [ $wantFiles -eq 1 ] && [ -n "${out[*]}" ] && [ -n "${cur}" ]; then + for file in $(\ls); do + if [[ ${file} =~ ^${cur}.* ]]; then + # We are completing a file prefix + out+=(${file}) + nospace=1 + fi + done + fi + __helm_debug "${FUNCNAME[0]}: out after files is ${out[*]}" + + # If the user didn't provide any input to completion, + # we provide a hint that a path can also be used + [ $wantFiles -eq 1 ] && [ -z "${cur}" ] && out+=(./ /) + + __helm_debug "${FUNCNAME[0]}: out after checking empty input is ${out[*]}" + + if [ $nospace -eq 1 ]; then + if [[ -n "${ZSH_VERSION}" ]]; then + # Don't let the shell add a space after the completion + local tmpout=$(__helm_zsh_comp_nospace "${out[@]}") + unset out + out=$tmpout + elif [[ $(type -t compopt) = "builtin" ]]; then + compopt -o nospace + fi + fi + + __helm_debug "${FUNCNAME[0]}: final out is ${out[*]}" + COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) +} + __helm_list_releases() { __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" @@ -123,7 +226,7 @@ __helm_list_repos() __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" local out # Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3) - if out=$(eval $(__helm_binary_name) repo list 2>/dev/null | tail +2 | cut -f1); then + if out=$(__helm_get_repos); then COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) fi } @@ -138,15 +241,47 @@ __helm_list_plugins() fi } +__helm_list_charts_after_name() { + __helm_debug "${FUNCNAME[0]}: last_command is $last_command" + if [[ ${#nouns[@]} -eq 1 ]]; then + __helm_list_charts 1 + fi +} + +__helm_list_releases_then_charts() { + __helm_debug "${FUNCNAME[0]}: last_command is $last_command" + if [[ ${#nouns[@]} -eq 0 ]]; then + __helm_list_releases + elif [[ ${#nouns[@]} -eq 1 ]]; then + __helm_list_charts 1 + fi +} + __helm_custom_func() { - __helm_debug "${FUNCNAME[0]}: last_command is $last_command" + __helm_debug "${FUNCNAME[0]}: last_command is $last_command" case ${last_command} in - helm_uninstall | helm_history | helm_status | helm_test |\ - helm_upgrade | helm_rollback | helm_get_*) + helm_pull) + __helm_list_charts 0 + return + ;; + helm_show_*) + __helm_list_charts 1 + return + ;; + helm_install | helm_template) + __helm_list_charts_after_name + return + ;; + helm_upgrade) + __helm_list_releases_then_charts + return + ;; + helm_uninstall | helm_history | helm_status | helm_test |\ + helm_rollback | helm_get_*) __helm_list_releases return - ;; + ;; helm_repo_remove) __helm_list_repos return From 9e9999b6714b1dc53ced5140815de387aa85bd21 Mon Sep 17 00:00:00 2001 From: Hang Park Date: Mon, 14 Oct 2019 19:29:06 +0900 Subject: [PATCH 005/279] fix(pkg/downloader): Add failing tests for #6416 and bugs due to #5874 This commit includes failing tests for a bug reported by #6416 and several bugs due to #5874. `helm dependency build` command fails if one of subcharts has optional dependency fields (e.g. Alias / Condition / Tags) or SemVer ranges. Signed-off-by: Hang Park --- pkg/downloader/manager_test.go | 107 ++++++++++++++++++ .../testdata/local-subchart-0.1.0.tgz | Bin 0 -> 259 bytes 2 files changed, 107 insertions(+) create mode 100644 pkg/downloader/testdata/local-subchart-0.1.0.tgz diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index b21106fea..0c5c08615 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -17,10 +17,14 @@ package downloader import ( "bytes" + "path/filepath" "reflect" "testing" "helm.sh/helm/v3/pkg/chart" + "helm.sh/helm/v3/pkg/chartutil" + "helm.sh/helm/v3/pkg/getter" + "helm.sh/helm/v3/pkg/repo/repotest" ) func TestVersionEquals(t *testing.T) { @@ -176,3 +180,106 @@ func TestGetRepoNames(t *testing.T) { } } } + +// This function is the skeleton test code of failing tests for #6416 and bugs due to #5874. +// This function is used by below tests that ensures success of build operation +// with optional fields, alias, condition, tags, and even with ranged version. +// Parent chart includes local-subchart 0.1.0 subchart from a fake repository, by default. +// If each of these main fields (name, version, repository) is not supplied by dep param, default value will be used. +func checkBuildWithOptionalFields(t *testing.T, chartName string, dep chart.Dependency) { + // Set up a fake repo + srv, err := repotest.NewTempServer("testdata/*.tgz*") + if err != nil { + t.Fatal(err) + } + defer srv.Stop() + if err := srv.LinkIndices(); err != nil { + t.Fatal(err) + } + dir := func(p ...string) string { + return filepath.Join(append([]string{srv.Root()}, p...)...) + } + + // Set main fields if not exist + if dep.Name == "" { + dep.Name = "local-subchart" + } + if dep.Version == "" { + dep.Version = "0.1.0" + } + if dep.Repository == "" { + dep.Repository = srv.URL() + } + + // Save a chart + c := &chart.Chart{ + Metadata: &chart.Metadata{ + Name: chartName, + Version: "0.1.0", + APIVersion: "v1", + Dependencies: []*chart.Dependency{&dep}, + }, + } + if err := chartutil.SaveDir(c, dir()); err != nil { + t.Fatal(err) + } + + // Set-up a manager + b := bytes.NewBuffer(nil) + g := getter.Providers{getter.Provider{ + Schemes: []string{"http", "https"}, + New: getter.NewHTTPGetter, + }} + m := &Manager{ + ChartPath: dir(chartName), + Out: b, + Getters: g, + RepositoryConfig: dir("repositories.yaml"), + RepositoryCache: dir(), + } + + // First build will update dependencies and create Chart.lock file. + err = m.Build() + if err != nil { + t.Fatal(err) + } + + // Second build should be passed. See PR #6655. + err = m.Build() + if err != nil { + t.Fatal(err) + } +} + +func TestBuild_WithoutOptionalFields(t *testing.T) { + // Dependency has main fields only (name/version/repository) + checkBuildWithOptionalFields(t, "without-optional-fields", chart.Dependency{}) +} + +func TestBuild_WithSemVerRange(t *testing.T) { + // Dependency version is the form of SemVer range + checkBuildWithOptionalFields(t, "with-semver-range", chart.Dependency{ + Version: ">=0.1.0", + }) +} + +func TestBuild_WithAlias(t *testing.T) { + // Dependency has an alias + checkBuildWithOptionalFields(t, "with-alias", chart.Dependency{ + Alias: "local-subchart-alias", + }) +} + +func TestBuild_WithCondition(t *testing.T) { + // Dependency has a condition + checkBuildWithOptionalFields(t, "with-condition", chart.Dependency{ + Condition: "some.condition", + }) +} + +func TestBuild_WithTags(t *testing.T) { + // Dependency has several tags + checkBuildWithOptionalFields(t, "with-tags", chart.Dependency{ + Tags: []string{"tag1", "tag2"}, + }) +} diff --git a/pkg/downloader/testdata/local-subchart-0.1.0.tgz b/pkg/downloader/testdata/local-subchart-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..4853121056a718bf02392623cf46a826f7908752 GIT binary patch literal 259 zcmV+e0sQ_SiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PNJuio!4y2H>vq6nTN^{F#I Date: Wed, 23 Oct 2019 02:11:00 +0530 Subject: [PATCH 006/279] fix rename for helm dependency upgrade This code was ported over from PR #5038, #6738 which were originally for helm v2. The code contains functions from golang/dep/internal/fs for renaming files. Signed-off-by: Yagnesh Mistry --- internal/third_party/dep/fs/fs.go | 373 +++++++++ internal/third_party/dep/fs/fs_test.go | 719 ++++++++++++++++++ internal/third_party/dep/fs/rename.go | 58 ++ internal/third_party/dep/fs/rename_windows.go | 69 ++ .../dep/fs/testdata/symlinks/file-symlink | 1 + .../dep/fs/testdata/symlinks/invalid-symlink | 1 + .../fs/testdata/symlinks/windows-file-symlink | 1 + .../third_party/dep/fs/testdata/test.file | 0 pkg/downloader/manager.go | 7 +- 9 files changed, 1226 insertions(+), 3 deletions(-) create mode 100644 internal/third_party/dep/fs/fs.go create mode 100644 internal/third_party/dep/fs/fs_test.go create mode 100644 internal/third_party/dep/fs/rename.go create mode 100644 internal/third_party/dep/fs/rename_windows.go create mode 120000 internal/third_party/dep/fs/testdata/symlinks/file-symlink create mode 120000 internal/third_party/dep/fs/testdata/symlinks/invalid-symlink create mode 120000 internal/third_party/dep/fs/testdata/symlinks/windows-file-symlink create mode 100644 internal/third_party/dep/fs/testdata/test.file diff --git a/internal/third_party/dep/fs/fs.go b/internal/third_party/dep/fs/fs.go new file mode 100644 index 000000000..832592197 --- /dev/null +++ b/internal/third_party/dep/fs/fs.go @@ -0,0 +1,373 @@ +/* +Copyright (c) for portions of fs.go are held by The Go Authors, 2016 and are provided under +the BSD license. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package fs + +import ( + "io" + "io/ioutil" + "os" + "path/filepath" + "runtime" + "syscall" + + "github.com/pkg/errors" +) + +// fs contains a copy of a few functions from dep tool code to avoid a dependency on golang/dep. +// This code is copied from https://github.com/golang/dep/blob/37d6c560cdf407be7b6cd035b23dba89df9275cf/internal/fs/fs.go +// No changes to the code were made other than removing some unused functions + +// RenameWithFallback attempts to rename a file or directory, but falls back to +// copying in the event of a cross-device link error. If the fallback copy +// succeeds, src is still removed, emulating normal rename behavior. +func RenameWithFallback(src, dst string) error { + _, err := os.Stat(src) + if err != nil { + return errors.Wrapf(err, "cannot stat %s", src) + } + + err = os.Rename(src, dst) + if err == nil { + return nil + } + + return renameFallback(err, src, dst) +} + +// renameByCopy attempts to rename a file or directory by copying it to the +// destination and then removing the src thus emulating the rename behavior. +func renameByCopy(src, dst string) error { + var cerr error + if dir, _ := IsDir(src); dir { + cerr = CopyDir(src, dst) + if cerr != nil { + cerr = errors.Wrap(cerr, "copying directory failed") + } + } else { + cerr = copyFile(src, dst) + if cerr != nil { + cerr = errors.Wrap(cerr, "copying file failed") + } + } + + if cerr != nil { + return errors.Wrapf(cerr, "rename fallback failed: cannot rename %s to %s", src, dst) + } + + return errors.Wrapf(os.RemoveAll(src), "cannot delete %s", src) +} + +var ( + errSrcNotDir = errors.New("source is not a directory") + errDstExist = errors.New("destination already exists") +) + +// CopyDir recursively copies a directory tree, attempting to preserve permissions. +// Source directory must exist, destination directory must *not* exist. +func CopyDir(src, dst string) error { + src = filepath.Clean(src) + dst = filepath.Clean(dst) + + // We use os.Lstat() here to ensure we don't fall in a loop where a symlink + // actually links to a one of its parent directories. + fi, err := os.Lstat(src) + if err != nil { + return err + } + if !fi.IsDir() { + return errSrcNotDir + } + + _, err = os.Stat(dst) + if err != nil && !os.IsNotExist(err) { + return err + } + if err == nil { + return errDstExist + } + + if err = os.MkdirAll(dst, fi.Mode()); err != nil { + return errors.Wrapf(err, "cannot mkdir %s", dst) + } + + entries, err := ioutil.ReadDir(src) + if err != nil { + return errors.Wrapf(err, "cannot read directory %s", dst) + } + + for _, entry := range entries { + srcPath := filepath.Join(src, entry.Name()) + dstPath := filepath.Join(dst, entry.Name()) + + if entry.IsDir() { + if err = CopyDir(srcPath, dstPath); err != nil { + return errors.Wrap(err, "copying directory failed") + } + } else { + // This will include symlinks, which is what we want when + // copying things. + if err = copyFile(srcPath, dstPath); err != nil { + return errors.Wrap(err, "copying file failed") + } + } + } + + return nil +} + +// copyFile copies the contents of the file named src to the file named +// by dst. The file will be created if it does not already exist. If the +// destination file exists, all its contents will be replaced by the contents +// of the source file. The file mode will be copied from the source. +func copyFile(src, dst string) (err error) { + if sym, err := IsSymlink(src); err != nil { + return errors.Wrap(err, "symlink check failed") + } else if sym { + if err := cloneSymlink(src, dst); err != nil { + if runtime.GOOS == "windows" { + // If cloning the symlink fails on Windows because the user + // does not have the required privileges, ignore the error and + // fall back to copying the file contents. + // + // ERROR_PRIVILEGE_NOT_HELD is 1314 (0x522): + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms681385(v=vs.85).aspx + if lerr, ok := err.(*os.LinkError); ok && lerr.Err != syscall.Errno(1314) { + return err + } + } else { + return err + } + } else { + return nil + } + } + + in, err := os.Open(src) + if err != nil { + return + } + defer in.Close() + + out, err := os.Create(dst) + if err != nil { + return + } + + if _, err = io.Copy(out, in); err != nil { + out.Close() + return + } + + // Check for write errors on Close + if err = out.Close(); err != nil { + return + } + + si, err := os.Stat(src) + if err != nil { + return + } + + // Temporary fix for Go < 1.9 + // + // See: https://github.com/golang/dep/issues/774 + // and https://github.com/golang/go/issues/20829 + if runtime.GOOS == "windows" { + dst = fixLongPath(dst) + } + err = os.Chmod(dst, si.Mode()) + + return +} + +// cloneSymlink will create a new symlink that points to the resolved path of sl. +// If sl is a relative symlink, dst will also be a relative symlink. +func cloneSymlink(sl, dst string) error { + resolved, err := os.Readlink(sl) + if err != nil { + return err + } + + return os.Symlink(resolved, dst) +} + +// IsDir determines is the path given is a directory or not. +func IsDir(name string) (bool, error) { + fi, err := os.Stat(name) + if err != nil { + return false, err + } + if !fi.IsDir() { + return false, errors.Errorf("%q is not a directory", name) + } + return true, nil +} + +// IsSymlink determines if the given path is a symbolic link. +func IsSymlink(path string) (bool, error) { + l, err := os.Lstat(path) + if err != nil { + return false, err + } + + return l.Mode()&os.ModeSymlink == os.ModeSymlink, nil +} + +// fixLongPath returns the extended-length (\\?\-prefixed) form of +// path when needed, in order to avoid the default 260 character file +// path limit imposed by Windows. If path is not easily converted to +// the extended-length form (for example, if path is a relative path +// or contains .. elements), or is short enough, fixLongPath returns +// path unmodified. +// +// See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath +func fixLongPath(path string) string { + // Do nothing (and don't allocate) if the path is "short". + // Empirically (at least on the Windows Server 2013 builder), + // the kernel is arbitrarily okay with < 248 bytes. That + // matches what the docs above say: + // "When using an API to create a directory, the specified + // path cannot be so long that you cannot append an 8.3 file + // name (that is, the directory name cannot exceed MAX_PATH + // minus 12)." Since MAX_PATH is 260, 260 - 12 = 248. + // + // The MSDN docs appear to say that a normal path that is 248 bytes long + // will work; empirically the path must be less then 248 bytes long. + if len(path) < 248 { + // Don't fix. (This is how Go 1.7 and earlier worked, + // not automatically generating the \\?\ form) + return path + } + + // The extended form begins with \\?\, as in + // \\?\c:\windows\foo.txt or \\?\UNC\server\share\foo.txt. + // The extended form disables evaluation of . and .. path + // elements and disables the interpretation of / as equivalent + // to \. The conversion here rewrites / to \ and elides + // . elements as well as trailing or duplicate separators. For + // simplicity it avoids the conversion entirely for relative + // paths or paths containing .. elements. For now, + // \\server\share paths are not converted to + // \\?\UNC\server\share paths because the rules for doing so + // are less well-specified. + if len(path) >= 2 && path[:2] == `\\` { + // Don't canonicalize UNC paths. + return path + } + if !isAbs(path) { + // Relative path + return path + } + + const prefix = `\\?` + + pathbuf := make([]byte, len(prefix)+len(path)+len(`\`)) + copy(pathbuf, prefix) + n := len(path) + r, w := 0, len(prefix) + for r < n { + switch { + case os.IsPathSeparator(path[r]): + // empty block + r++ + case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])): + // /./ + r++ + case r+1 < n && path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])): + // /../ is currently unhandled + return path + default: + pathbuf[w] = '\\' + w++ + for ; r < n && !os.IsPathSeparator(path[r]); r++ { + pathbuf[w] = path[r] + w++ + } + } + } + // A drive's root directory needs a trailing \ + if w == len(`\\?\c:`) { + pathbuf[w] = '\\' + w++ + } + return string(pathbuf[:w]) +} + +func isAbs(path string) (b bool) { + v := volumeName(path) + if v == "" { + return false + } + path = path[len(v):] + if path == "" { + return false + } + return os.IsPathSeparator(path[0]) +} + +func volumeName(path string) (v string) { + if len(path) < 2 { + return "" + } + // with drive letter + c := path[0] + if path[1] == ':' && + ('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || + 'A' <= c && c <= 'Z') { + return path[:2] + } + // is it UNC + if l := len(path); l >= 5 && os.IsPathSeparator(path[0]) && os.IsPathSeparator(path[1]) && + !os.IsPathSeparator(path[2]) && path[2] != '.' { + // first, leading `\\` and next shouldn't be `\`. its server name. + for n := 3; n < l-1; n++ { + // second, next '\' shouldn't be repeated. + if os.IsPathSeparator(path[n]) { + n++ + // third, following something characters. its share name. + if !os.IsPathSeparator(path[n]) { + if path[n] == '.' { + break + } + for ; n < l; n++ { + if os.IsPathSeparator(path[n]) { + break + } + } + return path[:n] + } + break + } + } + } + return "" +} diff --git a/internal/third_party/dep/fs/fs_test.go b/internal/third_party/dep/fs/fs_test.go new file mode 100644 index 000000000..bf4b803f8 --- /dev/null +++ b/internal/third_party/dep/fs/fs_test.go @@ -0,0 +1,719 @@ +/* +Copyright (c) for portions of fs_test.go are held by The Go Authors, 2016 and are provided under +the BSD license. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package fs + +import ( + "io/ioutil" + "os" + "os/exec" + "os/user" + "path/filepath" + "runtime" + "sync" + "testing" +) + +var ( + mu sync.Mutex +) + +func TestRenameWithFallback(t *testing.T) { + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + if err = RenameWithFallback(filepath.Join(dir, "does_not_exists"), filepath.Join(dir, "dst")); err == nil { + t.Fatal("expected an error for non existing file, but got nil") + } + + srcpath := filepath.Join(dir, "src") + + if srcf, err := os.Create(srcpath); err != nil { + t.Fatal(err) + } else { + srcf.Close() + } + + if err = RenameWithFallback(srcpath, filepath.Join(dir, "dst")); err != nil { + t.Fatal(err) + } + + srcpath = filepath.Join(dir, "a") + if err = os.MkdirAll(srcpath, 0777); err != nil { + t.Fatal(err) + } + + dstpath := filepath.Join(dir, "b") + if err = os.MkdirAll(dstpath, 0777); err != nil { + t.Fatal(err) + } + + if err = RenameWithFallback(srcpath, dstpath); err == nil { + t.Fatal("expected an error if dst is an existing directory, but got nil") + } +} + +func TestCopyDir(t *testing.T) { + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcdir := filepath.Join(dir, "src") + if err := os.MkdirAll(srcdir, 0755); err != nil { + t.Fatal(err) + } + + files := []struct { + path string + contents string + fi os.FileInfo + }{ + {path: "myfile", contents: "hello world"}, + {path: filepath.Join("subdir", "file"), contents: "subdir file"}, + } + + // Create structure indicated in 'files' + for i, file := range files { + fn := filepath.Join(srcdir, file.path) + dn := filepath.Dir(fn) + if err = os.MkdirAll(dn, 0755); err != nil { + t.Fatal(err) + } + + fh, err := os.Create(fn) + if err != nil { + t.Fatal(err) + } + + if _, err = fh.Write([]byte(file.contents)); err != nil { + t.Fatal(err) + } + fh.Close() + + files[i].fi, err = os.Stat(fn) + if err != nil { + t.Fatal(err) + } + } + + destdir := filepath.Join(dir, "dest") + if err := CopyDir(srcdir, destdir); err != nil { + t.Fatal(err) + } + + // Compare copy against structure indicated in 'files' + for _, file := range files { + fn := filepath.Join(srcdir, file.path) + dn := filepath.Dir(fn) + dirOK, err := IsDir(dn) + if err != nil { + t.Fatal(err) + } + if !dirOK { + t.Fatalf("expected %s to be a directory", dn) + } + + got, err := ioutil.ReadFile(fn) + if err != nil { + t.Fatal(err) + } + + if file.contents != string(got) { + t.Fatalf("expected: %s, got: %s", file.contents, string(got)) + } + + gotinfo, err := os.Stat(fn) + if err != nil { + t.Fatal(err) + } + + if file.fi.Mode() != gotinfo.Mode() { + t.Fatalf("expected %s: %#v\n to be the same mode as %s: %#v", + file.path, file.fi.Mode(), fn, gotinfo.Mode()) + } + } +} + +func TestCopyDirFail_SrcInaccessible(t *testing.T) { + if runtime.GOOS == "windows" { + // XXX: setting permissions works differently in + // Microsoft Windows. Skipping this this until a + // compatible implementation is provided. + t.Skip("skipping on windows") + } + + var currentUser, err = user.Current() + + if err != nil { + t.Fatalf("Failed to get name of current user: %s", err) + } + + if currentUser.Name == "root" { + // Skipping if root, because all files are accessible + t.Skip("Skipping for root user") + } + + var srcdir, dstdir string + + cleanup := setupInaccessibleDir(t, func(dir string) error { + srcdir = filepath.Join(dir, "src") + return os.MkdirAll(srcdir, 0755) + }) + defer cleanup() + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + dstdir = filepath.Join(dir, "dst") + if err = CopyDir(srcdir, dstdir); err == nil { + t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir) + } +} + +func TestCopyDirFail_DstInaccessible(t *testing.T) { + if runtime.GOOS == "windows" { + // XXX: setting permissions works differently in + // Microsoft Windows. Skipping this this until a + // compatible implementation is provided. + t.Skip("skipping on windows") + } + + var currentUser, err = user.Current() + + if err != nil { + t.Fatalf("Failed to get name of current user: %s", err) + } + + if currentUser.Name == "root" { + // Skipping if root, because all files are accessible + t.Skip("Skipping for root user") + } + + var srcdir, dstdir string + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcdir = filepath.Join(dir, "src") + if err = os.MkdirAll(srcdir, 0755); err != nil { + t.Fatal(err) + } + + cleanup := setupInaccessibleDir(t, func(dir string) error { + dstdir = filepath.Join(dir, "dst") + return nil + }) + defer cleanup() + + if err := CopyDir(srcdir, dstdir); err == nil { + t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir) + } +} + +func TestCopyDirFail_SrcIsNotDir(t *testing.T) { + var srcdir, dstdir string + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcdir = filepath.Join(dir, "src") + if _, err = os.Create(srcdir); err != nil { + t.Fatal(err) + } + + dstdir = filepath.Join(dir, "dst") + + if err = CopyDir(srcdir, dstdir); err == nil { + t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir) + } + + if err != errSrcNotDir { + t.Fatalf("expected %v error for CopyDir(%s, %s), got %s", errSrcNotDir, srcdir, dstdir, err) + } + +} + +func TestCopyDirFail_DstExists(t *testing.T) { + var srcdir, dstdir string + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcdir = filepath.Join(dir, "src") + if err = os.MkdirAll(srcdir, 0755); err != nil { + t.Fatal(err) + } + + dstdir = filepath.Join(dir, "dst") + if err = os.MkdirAll(dstdir, 0755); err != nil { + t.Fatal(err) + } + + if err = CopyDir(srcdir, dstdir); err == nil { + t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir) + } + + if err != errDstExist { + t.Fatalf("expected %v error for CopyDir(%s, %s), got %s", errDstExist, srcdir, dstdir, err) + } +} + +func TestCopyDirFailOpen(t *testing.T) { + if runtime.GOOS == "windows" { + // XXX: setting permissions works differently in + // Microsoft Windows. os.Chmod(..., 0222) below is not + // enough for the file to be readonly, and os.Chmod(..., + // 0000) returns an invalid argument error. Skipping + // this this until a compatible implementation is + // provided. + t.Skip("skipping on windows") + } + + var currentUser, err = user.Current() + + if err != nil { + t.Fatalf("Failed to get name of current user: %s", err) + } + + if currentUser.Name == "root" { + // Skipping if root, because all files are accessible + t.Skip("Skipping for root user") + } + + var srcdir, dstdir string + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcdir = filepath.Join(dir, "src") + if err = os.MkdirAll(srcdir, 0755); err != nil { + t.Fatal(err) + } + + srcfn := filepath.Join(srcdir, "file") + srcf, err := os.Create(srcfn) + if err != nil { + t.Fatal(err) + } + srcf.Close() + + // setup source file so that it cannot be read + if err = os.Chmod(srcfn, 0222); err != nil { + t.Fatal(err) + } + + dstdir = filepath.Join(dir, "dst") + + if err = CopyDir(srcdir, dstdir); err == nil { + t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir) + } +} + +func TestCopyFile(t *testing.T) { + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcf, err := os.Create(filepath.Join(dir, "srcfile")) + if err != nil { + t.Fatal(err) + } + + want := "hello world" + if _, err := srcf.Write([]byte(want)); err != nil { + t.Fatal(err) + } + srcf.Close() + + destf := filepath.Join(dir, "destf") + if err := copyFile(srcf.Name(), destf); err != nil { + t.Fatal(err) + } + + got, err := ioutil.ReadFile(destf) + if err != nil { + t.Fatal(err) + } + + if want != string(got) { + t.Fatalf("expected: %s, got: %s", want, string(got)) + } + + wantinfo, err := os.Stat(srcf.Name()) + if err != nil { + t.Fatal(err) + } + + gotinfo, err := os.Stat(destf) + if err != nil { + t.Fatal(err) + } + + if wantinfo.Mode() != gotinfo.Mode() { + t.Fatalf("expected %s: %#v\n to be the same mode as %s: %#v", srcf.Name(), wantinfo.Mode(), destf, gotinfo.Mode()) + } +} + +func cleanUpDir(dir string) { + // NOTE(mattn): It seems that sometimes git.exe is not dead + // when cleanUpDir() is called. But we do not know any way to wait for it. + if runtime.GOOS == "windows" { + mu.Lock() + exec.Command(`taskkill`, `/F`, `/IM`, `git.exe`).Run() + mu.Unlock() + } + if dir != "" { + os.RemoveAll(dir) + } +} + +func TestCopyFileSymlink(t *testing.T) { + var tempdir, err = ioutil.TempDir("", "gotest") + + if err != nil { + t.Fatalf("failed to create directory: %s", err) + } + + defer cleanUpDir(tempdir) + + testcases := map[string]string{ + filepath.Join("./testdata/symlinks/file-symlink"): filepath.Join(tempdir, "dst-file"), + filepath.Join("./testdata/symlinks/windows-file-symlink"): filepath.Join(tempdir, "windows-dst-file"), + filepath.Join("./testdata/symlinks/invalid-symlink"): filepath.Join(tempdir, "invalid-symlink"), + } + + for symlink, dst := range testcases { + t.Run(symlink, func(t *testing.T) { + var err error + if err = copyFile(symlink, dst); err != nil { + t.Fatalf("failed to copy symlink: %s", err) + } + + var want, got string + + if runtime.GOOS == "windows" { + // Creating symlinks on Windows require an additional permission + // regular users aren't granted usually. So we copy the file + // content as a fall back instead of creating a real symlink. + srcb, err := ioutil.ReadFile(symlink) + if err != nil { + t.Fatalf("%+v", err) + } + dstb, err := ioutil.ReadFile(dst) + if err != nil { + t.Fatalf("%+v", err) + } + + want = string(srcb) + got = string(dstb) + } else { + want, err = os.Readlink(symlink) + if err != nil { + t.Fatalf("%+v", err) + } + + got, err = os.Readlink(dst) + if err != nil { + t.Fatalf("could not resolve symlink: %s", err) + } + } + + if want != got { + t.Fatalf("resolved path is incorrect. expected %s, got %s", want, got) + } + }) + } +} + +func TestCopyFileFail(t *testing.T) { + if runtime.GOOS == "windows" { + // XXX: setting permissions works differently in + // Microsoft Windows. Skipping this this until a + // compatible implementation is provided. + t.Skip("skipping on windows") + } + + var currentUser, err = user.Current() + + if err != nil { + t.Fatalf("Failed to get name of current user: %s", err) + } + + if currentUser.Name == "root" { + // Skipping if root, because all files are accessible + t.Skip("Skipping for root user") + } + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + srcf, err := os.Create(filepath.Join(dir, "srcfile")) + if err != nil { + t.Fatal(err) + } + srcf.Close() + + var dstdir string + + cleanup := setupInaccessibleDir(t, func(dir string) error { + dstdir = filepath.Join(dir, "dir") + return os.Mkdir(dstdir, 0777) + }) + defer cleanup() + + fn := filepath.Join(dstdir, "file") + if err := copyFile(srcf.Name(), fn); err == nil { + t.Fatalf("expected error for %s, got none", fn) + } +} + +// setupInaccessibleDir creates a temporary location with a single +// directory in it, in such a way that that directory is not accessible +// after this function returns. +// +// op is called with the directory as argument, so that it can create +// files or other test artifacts. +// +// If setupInaccessibleDir fails in its preparation, or op fails, t.Fatal +// will be invoked. +// +// This function returns a cleanup function that removes all the temporary +// files this function creates. It is the caller's responsibility to call +// this function before the test is done running, whether there's an error or not. +func setupInaccessibleDir(t *testing.T, op func(dir string) error) func() { + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + return nil // keep compiler happy + } + + subdir := filepath.Join(dir, "dir") + + cleanup := func() { + if err := os.Chmod(subdir, 0777); err != nil { + t.Error(err) + } + if err := os.RemoveAll(dir); err != nil { + t.Error(err) + } + } + + if err := os.Mkdir(subdir, 0777); err != nil { + cleanup() + t.Fatal(err) + return nil + } + + if err := op(subdir); err != nil { + cleanup() + t.Fatal(err) + return nil + } + + if err := os.Chmod(subdir, 0666); err != nil { + cleanup() + t.Fatal(err) + return nil + } + + return cleanup +} + +func TestIsDir(t *testing.T) { + + var currentUser, err = user.Current() + + if err != nil { + t.Fatalf("Failed to get name of current user: %s", err) + } + + if currentUser.Name == "root" { + // Skipping if root, because all files are accessible + t.Skip("Skipping for root user") + } + + wd, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + var dn string + + cleanup := setupInaccessibleDir(t, func(dir string) error { + dn = filepath.Join(dir, "dir") + return os.Mkdir(dn, 0777) + }) + defer cleanup() + + tests := map[string]struct { + exists bool + err bool + }{ + wd: {true, false}, + filepath.Join(wd, "testdata"): {true, false}, + filepath.Join(wd, "main.go"): {false, true}, + filepath.Join(wd, "this_file_does_not_exist.thing"): {false, true}, + dn: {false, true}, + } + + if runtime.GOOS == "windows" { + // This test doesn't work on Microsoft Windows because + // of the differences in how file permissions are + // implemented. For this to work, the directory where + // the directory exists should be inaccessible. + delete(tests, dn) + } + + for f, want := range tests { + got, err := IsDir(f) + if err != nil && !want.err { + t.Fatalf("expected no error, got %v", err) + } + + if got != want.exists { + t.Fatalf("expected %t for %s, got %t", want.exists, f, got) + } + } +} + +func TestIsSymlink(t *testing.T) { + + var currentUser, err = user.Current() + + if err != nil { + t.Fatalf("Failed to get name of current user: %s", err) + } + + if currentUser.Name == "root" { + // Skipping if root, because all files are accessible + t.Skip("Skipping for root user") + } + + dir, err := ioutil.TempDir("", "helm-tmp") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(dir) + + dirPath := filepath.Join(dir, "directory") + if err = os.MkdirAll(dirPath, 0777); err != nil { + t.Fatal(err) + } + + filePath := filepath.Join(dir, "file") + f, err := os.Create(filePath) + if err != nil { + t.Fatal(err) + } + f.Close() + + dirSymlink := filepath.Join(dir, "dirSymlink") + fileSymlink := filepath.Join(dir, "fileSymlink") + + if err = os.Symlink(dirPath, dirSymlink); err != nil { + t.Fatal(err) + } + if err = os.Symlink(filePath, fileSymlink); err != nil { + t.Fatal(err) + } + + var ( + inaccessibleFile string + inaccessibleSymlink string + ) + + cleanup := setupInaccessibleDir(t, func(dir string) error { + inaccessibleFile = filepath.Join(dir, "file") + if fh, err := os.Create(inaccessibleFile); err != nil { + return err + } else if err = fh.Close(); err != nil { + return err + } + + inaccessibleSymlink = filepath.Join(dir, "symlink") + return os.Symlink(inaccessibleFile, inaccessibleSymlink) + }) + defer cleanup() + + tests := map[string]struct{ expected, err bool }{ + dirPath: {false, false}, + filePath: {false, false}, + dirSymlink: {true, false}, + fileSymlink: {true, false}, + inaccessibleFile: {false, true}, + inaccessibleSymlink: {false, true}, + } + + if runtime.GOOS == "windows" { + // XXX: setting permissions works differently in Windows. Skipping + // these cases until a compatible implementation is provided. + delete(tests, inaccessibleFile) + delete(tests, inaccessibleSymlink) + } + + for path, want := range tests { + got, err := IsSymlink(path) + if err != nil { + if !want.err { + t.Errorf("expected no error, got %v", err) + } + } + + if got != want.expected { + t.Errorf("expected %t for %s, got %t", want.expected, path, got) + } + } +} diff --git a/internal/third_party/dep/fs/rename.go b/internal/third_party/dep/fs/rename.go new file mode 100644 index 000000000..0bb600949 --- /dev/null +++ b/internal/third_party/dep/fs/rename.go @@ -0,0 +1,58 @@ +// +build !windows + +/* +Copyright (c) for portions of rename.go are held by The Go Authors, 2016 and are provided under +the BSD license. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package fs + +import ( + "os" + "syscall" + + "github.com/pkg/errors" +) + +// renameFallback attempts to determine the appropriate fallback to failed rename +// operation depending on the resulting error. +func renameFallback(err error, src, dst string) error { + // Rename may fail if src and dst are on different devices; fall back to + // copy if we detect that case. syscall.EXDEV is the common name for the + // cross device link error which has varying output text across different + // operating systems. + terr, ok := err.(*os.LinkError) + if !ok { + return err + } else if terr.Err != syscall.EXDEV { + return errors.Wrapf(terr, "link error: cannot rename %s to %s", src, dst) + } + + return renameByCopy(src, dst) +} diff --git a/internal/third_party/dep/fs/rename_windows.go b/internal/third_party/dep/fs/rename_windows.go new file mode 100644 index 000000000..14f017d09 --- /dev/null +++ b/internal/third_party/dep/fs/rename_windows.go @@ -0,0 +1,69 @@ +// +build windows + +/* +Copyright (c) for portions of rename_windows.go are held by The Go Authors, 2016 and are provided under +the BSD license. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package fs + +import ( + "os" + "syscall" + + "github.com/pkg/errors" +) + +// renameFallback attempts to determine the appropriate fallback to failed rename +// operation depending on the resulting error. +func renameFallback(err error, src, dst string) error { + // Rename may fail if src and dst are on different devices; fall back to + // copy if we detect that case. syscall.EXDEV is the common name for the + // cross device link error which has varying output text across different + // operating systems. + terr, ok := err.(*os.LinkError) + if !ok { + return err + } + + if terr.Err != syscall.EXDEV { + // In windows it can drop down to an operating system call that + // returns an operating system error with a different number and + // message. Checking for that as a fall back. + noerr, ok := terr.Err.(syscall.Errno) + + // 0x11 (ERROR_NOT_SAME_DEVICE) is the windows error. + // See https://msdn.microsoft.com/en-us/library/cc231199.aspx + if ok && noerr != 0x11 { + return errors.Wrapf(terr, "link error: cannot rename %s to %s", src, dst) + } + } + + return renameByCopy(src, dst) +} diff --git a/internal/third_party/dep/fs/testdata/symlinks/file-symlink b/internal/third_party/dep/fs/testdata/symlinks/file-symlink new file mode 120000 index 000000000..4c52274de --- /dev/null +++ b/internal/third_party/dep/fs/testdata/symlinks/file-symlink @@ -0,0 +1 @@ +../test.file \ No newline at end of file diff --git a/internal/third_party/dep/fs/testdata/symlinks/invalid-symlink b/internal/third_party/dep/fs/testdata/symlinks/invalid-symlink new file mode 120000 index 000000000..0edf4f301 --- /dev/null +++ b/internal/third_party/dep/fs/testdata/symlinks/invalid-symlink @@ -0,0 +1 @@ +/non/existing/file \ No newline at end of file diff --git a/internal/third_party/dep/fs/testdata/symlinks/windows-file-symlink b/internal/third_party/dep/fs/testdata/symlinks/windows-file-symlink new file mode 120000 index 000000000..af1d6c8f5 --- /dev/null +++ b/internal/third_party/dep/fs/testdata/symlinks/windows-file-symlink @@ -0,0 +1 @@ +C:/Users/ibrahim/go/src/github.com/golang/dep/internal/fs/testdata/test.file \ No newline at end of file diff --git a/internal/third_party/dep/fs/testdata/test.file b/internal/third_party/dep/fs/testdata/test.file new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index cc3af74db..393e981b8 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -30,6 +30,7 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" + "helm.sh/helm/v3/internal/dep/fs" "helm.sh/helm/v3/internal/resolver" "helm.sh/helm/v3/internal/urlutil" "helm.sh/helm/v3/pkg/chart" @@ -192,7 +193,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { return errors.Errorf("%q is not a directory", destPath) } - if err := os.Rename(destPath, tmpPath); err != nil { + if err := fs.RenameWithFallback(destPath, tmpPath); err != nil { return errors.Wrap(err, "unable to move current charts to tmp dir") } @@ -296,7 +297,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { if err := os.RemoveAll(destPath); err != nil { return errors.Wrapf(err, "failed to remove %v", destPath) } - if err := os.Rename(tmpPath, destPath); err != nil { + if err := fs.RenameWithFallback(tmpPath, destPath); err != nil { return errors.Wrap(err, "unable to move current charts to tmp dir") } return saveError @@ -672,7 +673,7 @@ func move(tmpPath, destPath string) error { filename := file.Name() tmpfile := filepath.Join(tmpPath, filename) destfile := filepath.Join(destPath, filename) - if err := os.Rename(tmpfile, destfile); err != nil { + if err := fs.RenameWithFallback(tmpfile, destfile); err != nil { return errors.Wrap(err, "unable to move local charts to charts dir") } } From b048f8914b08c42f77bbf40158cb00435aa8f7dd Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 22 Oct 2019 13:52:30 -0700 Subject: [PATCH 007/279] fix(coverage): cd to root dir to avoid adding godir to go modules Signed-off-by: Matthew Fisher --- .golangci.yml | 2 +- scripts/coverage.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index b391a3e18..601d98661 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,6 @@ linters-settings: gofmt: simplify: true goimports: - local-prefixes: helm.sh/helm + local-prefixes: helm.sh/helm/v3 dupl: threshold: 400 diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 62d495769..68ac1b42d 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -20,8 +20,10 @@ covermode=${COVERMODE:-atomic} coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX) profile="${coverdir}/cover.out" +pushd / hash goveralls 2>/dev/null || go get github.com/mattn/goveralls hash godir 2>/dev/null || go get github.com/Masterminds/godir +popd generate_cover_data() { for d in $(godir) ; do From 630134a904e105a44187d7534c34579a527f11e1 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 22 Oct 2019 13:55:14 -0700 Subject: [PATCH 008/279] fix(coverage): use `go list` instead of `godir` Signed-off-by: Matthew Fisher --- scripts/coverage.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 68ac1b42d..bdbfaa991 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -22,11 +22,10 @@ profile="${coverdir}/cover.out" pushd / hash goveralls 2>/dev/null || go get github.com/mattn/goveralls -hash godir 2>/dev/null || go get github.com/Masterminds/godir popd generate_cover_data() { - for d in $(godir) ; do + for d in $(go list ./...) ; do ( local output="${coverdir}/${d//\//-}.cover" go test -coverprofile="${output}" -covermode="$covermode" "$d" From 44a81f63f739e941418085514572c2bafe04e7dd Mon Sep 17 00:00:00 2001 From: Oleg Sidorov Date: Wed, 23 Oct 2019 09:15:00 +0200 Subject: [PATCH 009/279] Revert "chartutil.ReadValues is forced to unmarshal numbers into json.Number refs #1707 [dev-v3]" This reverts commit f94bac0643ad5d39c740c57c6c8ea6a4569a1db0. Due to a major numeric regression detected in dev-v2 reported in #6708, we believe the master branch (former dev-v3) is also impacted by this change and will expose the same set of problems. In order to not jeopardize the stability of helm3 this commit is reverted in favor of a better fix in the future. Signed-off-by: Oleg Sidorov --- pkg/chartutil/testdata/coleridge.yaml | 1 - pkg/chartutil/values.go | 6 +----- pkg/chartutil/values_test.go | 7 ------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/pkg/chartutil/testdata/coleridge.yaml b/pkg/chartutil/testdata/coleridge.yaml index 15535988b..b6579628b 100644 --- a/pkg/chartutil/testdata/coleridge.yaml +++ b/pkg/chartutil/testdata/coleridge.yaml @@ -10,4 +10,3 @@ water: water: where: "everywhere" nor: "any drop to drink" - temperature: 1234567890 diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index d9b94212c..e1cdf4642 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -17,7 +17,6 @@ limitations under the License. package chartutil import ( - "encoding/json" "fmt" "io" "io/ioutil" @@ -106,10 +105,7 @@ func tableLookup(v Values, simple string) (Values, error) { // ReadValues will parse YAML byte data into a Values. func ReadValues(data []byte) (vals Values, err error) { - err = yaml.Unmarshal(data, &vals, func(d *json.Decoder) *json.Decoder { - d.UseNumber() - return d - }) + err = yaml.Unmarshal(data, &vals) if len(vals) == 0 { vals = Values{} } diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index 2cb328d5d..a3fe7aeac 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -45,7 +45,6 @@ water: water: where: "everywhere" nor: "any drop to drink" - temperature: 1234567890 ` data, err := ReadValues([]byte(doc)) @@ -246,12 +245,6 @@ func matchValues(t *testing.T, data map[string]interface{}) { } else if o != "everywhere" { t.Errorf("Expected water water everywhere") } - - if o, err := ttpl("{{.water.water.temperature}}", data); err != nil { - t.Errorf(".water.water.temperature: %s", err) - } else if o != "1234567890" { - t.Errorf("Expected water water temperature: 1234567890, got: %s", o) - } } func ttpl(tpl string, v map[string]interface{}) (string, error) { From 41e70306b3464b99cf3afe4e23e85948fede3483 Mon Sep 17 00:00:00 2001 From: Yagnesh Mistry Date: Wed, 23 Oct 2019 09:27:35 +0530 Subject: [PATCH 010/279] Fix import Signed-off-by: Yagnesh Mistry --- pkg/downloader/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 393e981b8..388ba67f2 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -30,8 +30,8 @@ import ( "github.com/pkg/errors" "sigs.k8s.io/yaml" - "helm.sh/helm/v3/internal/dep/fs" "helm.sh/helm/v3/internal/resolver" + "helm.sh/helm/v3/internal/third_party/dep/fs" "helm.sh/helm/v3/internal/urlutil" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" From 0f94af1f3a569f6aba3c89d7d135f81a8c59372a Mon Sep 17 00:00:00 2001 From: Mike Ryan Date: Thu, 24 Oct 2019 12:34:20 +0200 Subject: [PATCH 011/279] Removed inaccurate statement re library (#6771) This PR is a self-admitted exercise in pedantry. The previous wording suggested a distinction between the Helm client and Helm library, but from a user perspective the usage of the library is hidden. As a user, I use the Helm client to render my templates and communicate with k8s, so mentioning the library in this section reduces clarity. Signed-off-by: Mike Ryan --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 91a06916a..9af358e10 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,7 @@ 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 library -- The library renders your templates and communicates with the Kubernetes API +- Helm 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`) From 5e1ad8b0258067c67374025cae00be7f02d72f32 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> Date: Thu, 24 Oct 2019 07:20:34 -0500 Subject: [PATCH 012/279] Change mediatype for chart content layer Mediatype changed to application/tar+gzip. Please see the following OCI mailing list item for more info: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/pdc1lucm_Ak Also, improved check for invalid manifests, a nil reference error was occurring when upgrading from existing cache with old mediatype. Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> --- internal/experimental/registry/cache.go | 6 +++++- internal/experimental/registry/constants.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/experimental/registry/cache.go b/internal/experimental/registry/cache.go index 19ceb86ea..fbd62562a 100644 --- a/internal/experimental/registry/cache.go +++ b/internal/experimental/registry/cache.go @@ -122,10 +122,14 @@ func (cache *Cache) FetchReference(ref *Reference) (*CacheRefSummary, error) { contentLayer = &layer } } - if contentLayer.Size == 0 { + if contentLayer == nil { return &r, errors.New( fmt.Sprintf("manifest does not contain a layer with mediatype %s", HelmChartContentLayerMediaType)) } + if contentLayer.Size == 0 { + return &r, errors.New( + fmt.Sprintf("manifest layer with mediatype %s is of size 0", HelmChartContentLayerMediaType)) + } r.ContentLayer = contentLayer info, err := cache.ociStore.Info(ctx(cache.out, cache.debug), contentLayer.Digest) if err != nil { diff --git a/internal/experimental/registry/constants.go b/internal/experimental/registry/constants.go index e0f17fe61..dafb3c9e5 100644 --- a/internal/experimental/registry/constants.go +++ b/internal/experimental/registry/constants.go @@ -21,7 +21,7 @@ const ( HelmChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json" // HelmChartContentLayerMediaType is the reserved media type for Helm chart package content - HelmChartContentLayerMediaType = "application/vnd.cncf.helm.chart.content.layer.v1+tar" + HelmChartContentLayerMediaType = "application/tar+gzip" ) // KnownMediaTypes returns a list of layer mediaTypes that the Helm client knows about From e14db65ad22fcc795b45b59f5ffde05fc1543743 Mon Sep 17 00:00:00 2001 From: Mateusz Szostok Date: Thu, 24 Oct 2019 15:25:21 +0200 Subject: [PATCH 013/279] fix(Makefile): remove orphaned targets for documentation Signed-off-by: Mateusz Szostok --- Makefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Makefile b/Makefile index 5cc931af3..b52464ba9 100644 --- a/Makefile +++ b/Makefile @@ -100,10 +100,6 @@ test-acceptance: build build-cross test-acceptance-completion: ACCEPTANCE_RUN_TESTS = shells.robot test-acceptance-completion: test-acceptance -.PHONY: verify-docs -verify-docs: build - @scripts/verify-docs.sh - .PHONY: coverage coverage: @scripts/coverage.sh @@ -154,10 +150,6 @@ checksum: # ------------------------------------------------------------------------------ -.PHONY: docs -docs: build - @scripts/update-docs.sh - .PHONY: clean clean: @rm -rf $(BINDIR) ./_dist From bfd825080377db771821ef742ac513dc1dcc7ccb Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Thu, 24 Oct 2019 19:04:48 +0530 Subject: [PATCH 014/279] fix list not showing multiple releases with same name in different namespaces (#6756) Signed-off-by: Karuppiah Natarajan --- pkg/action/list.go | 31 ++++++++++++-------------- pkg/action/list_test.go | 35 +++++++++++++++++++++++++----- pkg/storage/driver/cfgmaps_test.go | 2 +- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/pkg/action/list.go b/pkg/action/list.go index f72edc83b..4af0ef8e5 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -17,6 +17,7 @@ limitations under the License. package action import ( + "path" "regexp" "helm.sh/helm/v3/pkg/release" @@ -218,27 +219,23 @@ func (l *List) sort(rels []*release.Release) { } // filterList returns a list scrubbed of old releases. -func filterList(rels []*release.Release) []*release.Release { - idx := map[string]int{} - - for _, r := range rels { - name, version := r.Name, r.Version - if max, ok := idx[name]; ok { - // check if we have a greater version already - if max > version { - continue - } +func filterList(releases []*release.Release) []*release.Release { + latestReleases := make(map[string]*release.Release) + + for _, rls := range releases { + name, namespace := rls.Name, rls.Namespace + key := path.Join(namespace, name) + if latestRelease, exists := latestReleases[key]; exists && latestRelease.Version > rls.Version { + continue } - idx[name] = version + latestReleases[key] = rls } - uniq := make([]*release.Release, 0, len(idx)) - for _, r := range rels { - if idx[r.Name] == r.Version { - uniq = append(uniq, r) - } + var list = make([]*release.Release, 0, len(latestReleases)) + for _, rls := range latestReleases { + list = append(list, rls) } - return uniq + return list } // setStateMask calculates the state mask based on parameters. diff --git a/pkg/action/list_test.go b/pkg/action/list_test.go index cab0111fd..cd86aee68 100644 --- a/pkg/action/list_test.go +++ b/pkg/action/list_test.go @@ -159,6 +159,7 @@ func TestList_LimitOffsetOutOfBounds(t *testing.T) { is.NoError(err) is.Len(list, 2) } + func TestList_StateMask(t *testing.T) { is := assert.New(t) lister := newListFixture(t) @@ -166,7 +167,8 @@ func TestList_StateMask(t *testing.T) { one, err := lister.cfg.Releases.Get("one", 1) is.NoError(err) one.SetStatus(release.StatusUninstalled, "uninstalled") - lister.cfg.Releases.Update(one) + err = lister.cfg.Releases.Update(one) + is.NoError(err) res, err := lister.Run() is.NoError(err) @@ -222,11 +224,6 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) { three.Name = "three" three.Namespace = "default" three.Version = 3 - four := releaseStub() - four.Name = "four" - four.Namespace = "default" - four.Version = 4 - four.Info.Status = release.StatusSuperseded for _, rel := range []*release.Release{one, two, three} { if err := store.Create(rel); err != nil { @@ -238,3 +235,29 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) { assert.NoError(t, err) assert.Len(t, all, 3, "sanity test: three items added") } + +func TestFilterList(t *testing.T) { + one := releaseStub() + one.Name = "one" + one.Namespace = "default" + one.Version = 1 + two := releaseStub() + two.Name = "two" + two.Namespace = "default" + two.Version = 1 + anotherOldOne := releaseStub() + anotherOldOne.Name = "one" + anotherOldOne.Namespace = "testing" + anotherOldOne.Version = 1 + anotherOne := releaseStub() + anotherOne.Name = "one" + anotherOne.Namespace = "testing" + anotherOne.Version = 2 + + list := []*release.Release{one, two, anotherOne} + expectedFilteredList := []*release.Release{one, two, anotherOne} + + filteredList := filterList(list) + + assert.ElementsMatch(t, expectedFilteredList, filteredList) +} diff --git a/pkg/storage/driver/cfgmaps_test.go b/pkg/storage/driver/cfgmaps_test.go index 6efd790ce..2aa38f284 100644 --- a/pkg/storage/driver/cfgmaps_test.go +++ b/pkg/storage/driver/cfgmaps_test.go @@ -51,7 +51,7 @@ func TestConfigMapGet(t *testing.T) { } } -func TestUNcompressedConfigMapGet(t *testing.T) { +func TestUncompressedConfigMapGet(t *testing.T) { vers := 1 name := "smug-pigeon" namespace := "default" From 062235142b2edbc7c4b16292135daf1cfa4810c7 Mon Sep 17 00:00:00 2001 From: Mateusz Szostok Date: Thu, 24 Oct 2019 16:10:47 +0200 Subject: [PATCH 015/279] fix(repo/search): fix helm repo search command to display proper versions Introduce the `--devel` flag for `helm repo search` command. `helm repo search` - searches only for stable releases, prerelease versions will be skip `helm repo search --devel` - searches for releases and prereleases (alpha, beta, and release candidate releases) `helm repo search --version 1.0.0 - searches for release in version 1.0.0 Signed-off-by: Mateusz Szostok --- cmd/helm/install.go | 6 ++-- cmd/helm/search_repo.go | 34 +++++++++++++++++++ cmd/helm/search_repo_test.go | 10 +++--- .../helm/repository/testing-index.yaml | 12 +++++++ .../output/search-multiple-devel-release.txt | 2 ++ ...txt => search-multiple-stable-release.txt} | 0 pkg/repo/index.go | 3 +- 7 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 cmd/helm/testdata/output/search-multiple-devel-release.txt rename cmd/helm/testdata/output/{search-multiple.txt => search-multiple-stable-release.txt} (100%) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 6c6920daa..c80f8875d 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -93,9 +93,9 @@ A chart reference is a convenient way of referencing a chart in a chart reposito When you use a chart reference with a repo prefix ('example/mariadb'), Helm will look in the local configuration for a chart repository named 'example', and will then look for a -chart in that repository whose name is 'mariadb'. It will install the latest -version of that chart unless you also supply a version number with the -'--version' flag. +chart in that repository whose name is 'mariadb'. It will install the latest stable version of that chart +until you specify '--devel' flag to also include development version (alpha, beta, and release candidate releases), or +supply a version number with the '--version' flag. To see the list of chart repositories, use 'helm repo list'. To search for charts in a repository, use 'helm search'. diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index 9a448f75f..8abcd1eb7 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -38,6 +38,20 @@ Search reads through all of the repositories configured on the system, and looks for matches. Search of these repositories uses the metadata stored on the system. +It will display the latest stable versions of that chart until you specify '--devel' flag +to also include development versions (alpha, beta, and release candidate releases), or +supply a version number with the '--version' flag. + +Examples: + # Searches only for stable releases, prerelease versions will be skipped + helm repo search + + # Searches for releases and prereleases (alpha, beta, and release candidate releases) + helm repo search --devel + + # searches only for release in version 1.0.0 + helm repo search --version 1.0.0 + Repositories are managed with 'helm repo' commands. ` @@ -47,6 +61,7 @@ const searchMaxScore = 25 type searchRepoOptions struct { versions bool regexp bool + devel bool version string maxColWidth uint repoFile string @@ -71,6 +86,7 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command { f := cmd.Flags() f.BoolVarP(&o.regexp, "regexp", "r", false, "use regular expressions for searching repositories you have added") f.BoolVarP(&o.versions, "versions", "l", false, "show the long listing, with each version of each chart on its own line, for repositories you have added") + f.BoolVar(&o.devel, "devel", false, "use development versions (alpha, beta, and release candidate releases), too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") f.StringVar(&o.version, "version", "", "search using semantic versioning constraints on repositories you have added") f.UintVar(&o.maxColWidth, "max-col-width", 50, "maximum column width for output table") bindOutputFlag(cmd, &o.outputFormat) @@ -79,6 +95,8 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command { } func (o *searchRepoOptions) run(out io.Writer, args []string) error { + o.setupSearchedVersion() + index, err := o.buildIndex(out) if err != nil { return err @@ -104,6 +122,22 @@ func (o *searchRepoOptions) run(out io.Writer, args []string) error { return o.outputFormat.Write(out, &repoSearchWriter{data, o.maxColWidth}) } +func (o *searchRepoOptions) setupSearchedVersion() { + debug("Original chart version: %q", o.version) + + if o.version != "" { + return + } + + if o.devel { // search for releases and prereleases (alpha, beta, and release candidate releases). + debug("setting version to >0.0.0-0") + o.version = ">0.0.0-0" + } else { // search only for stable releases, prerelease versions will be skip + debug("setting version to >0.0.0") + o.version = ">0.0.0" + } +} + func (o *searchRepoOptions) applyConstraint(res []*search.Result) ([]*search.Result, error) { if len(o.version) == 0 { return res, nil diff --git a/cmd/helm/search_repo_test.go b/cmd/helm/search_repo_test.go index 5e945e3b7..6ece55505 100644 --- a/cmd/helm/search_repo_test.go +++ b/cmd/helm/search_repo_test.go @@ -25,13 +25,13 @@ func TestSearchRepositoriesCmd(t *testing.T) { repoCache := "testdata/helmhome/helm/repository" tests := []cmdTestCase{{ - name: "search for 'alpine', expect two matches", + name: "search for 'alpine', expect one match with latest stable version", cmd: "search repo alpine", - golden: "output/search-multiple.txt", + golden: "output/search-multiple-stable-release.txt", }, { - name: "search for 'alpine', expect two matches", - cmd: "search repo alpine", - golden: "output/search-multiple.txt", + name: "search for 'alpine', expect one match with newest development version", + cmd: "search repo alpine --devel", + golden: "output/search-multiple-devel-release.txt", }, { name: "search for 'alpine' with versions, expect three matches", cmd: "search repo alpine --versions", diff --git a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml b/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml index aab74f742..429388fb8 100644 --- a/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml +++ b/cmd/helm/testdata/helmhome/helm/repository/testing-index.yaml @@ -25,6 +25,18 @@ entries: keywords: [] maintainers: [] icon: "" + - name: alpine + url: https://kubernetes-charts.storage.googleapis.com/alpine-0.3.0-rc.1.tgz + checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d + home: https://helm.sh/helm + sources: + - https://github.com/helm/helm + version: 0.3.0-rc.1 + appVersion: 3.0.0 + description: Deploy a basic Alpine Linux pod + keywords: [] + maintainers: [] + icon: "" mariadb: - name: mariadb url: https://kubernetes-charts.storage.googleapis.com/mariadb-0.3.0.tgz diff --git a/cmd/helm/testdata/output/search-multiple-devel-release.txt b/cmd/helm/testdata/output/search-multiple-devel-release.txt new file mode 100644 index 000000000..7e29a8f7e --- /dev/null +++ b/cmd/helm/testdata/output/search-multiple-devel-release.txt @@ -0,0 +1,2 @@ +NAME CHART VERSION APP VERSION DESCRIPTION +testing/alpine 0.3.0-rc.1 3.0.0 Deploy a basic Alpine Linux pod diff --git a/cmd/helm/testdata/output/search-multiple.txt b/cmd/helm/testdata/output/search-multiple-stable-release.txt similarity index 100% rename from cmd/helm/testdata/output/search-multiple.txt rename to cmd/helm/testdata/output/search-multiple-stable-release.txt diff --git a/pkg/repo/index.go b/pkg/repo/index.go index 8e8f56d47..b3703304f 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -147,7 +147,8 @@ func (i IndexFile) SortEntries() { // Get returns the ChartVersion for the given name. // -// If version is empty, this will return the chart with the highest version. +// If version is empty, this will return the chart with the latest stable version, +// prerelease versions will be skipped. func (i IndexFile) Get(name, version string) (*ChartVersion, error) { vs, ok := i.Entries[name] if !ok { From 3144cf0fed84af00475620c77d184c306ffc6687 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Thu, 10 Oct 2019 18:55:48 +0900 Subject: [PATCH 016/279] fix(v3): fix regression on non-zero plugin exist status Fixes the regression in helm-3.0.0-beta.5 that swallows and rounds any non-zero exit status greater than 1 from a helm plugin to `1`. This, for example, breaks `helm-diff` which relies on helm able to return `2` when `helm-diff` returned `2`. Closese #6788 Signed-off-by: Yusuke Kuoka --- cmd/helm/helm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 0e935addb..b30d6b011 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -68,6 +68,11 @@ func main() { cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) if err := actionConfig.Init(settings, false, os.Getenv("HELM_DRIVER"), debug); err != nil { + debug("%+v", err) + os.Exit(1) + } + + if err := cmd.Execute(); err != nil { debug("%+v", err) switch e := err.(type) { case pluginError: @@ -76,11 +81,6 @@ func main() { os.Exit(1) } } - - if err := cmd.Execute(); err != nil { - debug("%+v", err) - os.Exit(1) - } } // wordSepNormalizeFunc changes all flags that contain "_" separators From d495f06d1581884d8a1c4ce63a601b702654ba9a Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Fri, 25 Oct 2019 11:10:18 +0100 Subject: [PATCH 017/279] Update containerd dependency from beta to release (#6773) Signed-off-by: Martin Hickey --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d986c4b77..6744a7451 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/Masterminds/vcs v1.13.0 github.com/Microsoft/go-winio v0.4.12 // indirect github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a - github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4 + github.com/containerd/containerd v1.3.0 github.com/cyphar/filepath-securejoin v0.2.2 github.com/deislabs/oras v0.7.0 github.com/docker/distribution v2.7.1+incompatible diff --git a/go.sum b/go.sum index de710b39a..c82eb87fe 100644 --- a/go.sum +++ b/go.sum @@ -71,6 +71,8 @@ github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4 h1:aMyA5J7j6D07U7pf8BFEY67BKoDcz0zWleAbQj3zVng= github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/containerd v1.3.0 h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY= +github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 h1:4BX8f882bXEDKfWIf0wa8HRvpnBoPszJJXL+TVbBw4M= github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/coreos/bbolt v1.3.1-coreos.6 h1:uTXKg9gY70s9jMAKdfljFQcuh4e/BXOM+V+d00KFj3A= From 32d9b70d22819c400b777691915aa5087e4386a8 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 25 Oct 2019 22:09:09 +0900 Subject: [PATCH 018/279] Ensure plugins return `pluginError`s on non-zero exit statuses Signed-off-by: Yusuke Kuoka --- cmd/helm/plugin_test.go | 22 ++++++++++++++----- .../helm/plugins/exitwith/exitwith.sh | 2 ++ .../helm/plugins/exitwith/plugin.yaml | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh create mode 100644 cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index e545a5d4f..7bc8fe70c 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -86,11 +86,13 @@ func TestLoadPlugins(t *testing.T) { long string expect string args []string + code int }{ - {"args", "echo args", "This echos args", "-a -b -c\n", []string{"-a", "-b", "-c"}}, - {"echo", "echo stuff", "This echos stuff", "hello\n", []string{}}, - {"env", "env stuff", "show the env", "env\n", []string{}}, - {"fullenv", "show env vars", "show all env vars", envs + "\n", []string{}}, + {"args", "echo args", "This echos args", "-a -b -c\n", []string{"-a", "-b", "-c"}, 0}, + {"echo", "echo stuff", "This echos stuff", "hello\n", []string{}, 0}, + {"env", "env stuff", "show the env", "env\n", []string{}, 0}, + {"exitwith", "exitwith code", "This exits with the specified exit code", "", []string{"2"}, 2}, + {"fullenv", "show env vars", "show all env vars", envs + "\n", []string{}, 0}, } plugins := cmd.Commands() @@ -117,7 +119,17 @@ func TestLoadPlugins(t *testing.T) { // tests until this is fixed if runtime.GOOS != "windows" { if err := pp.RunE(pp, tt.args); err != nil { - t.Errorf("Error running %s: %+v", tt.use, err) + if tt.code > 0 { + perr, ok := err.(pluginError) + if !ok { + t.Errorf("Expected %s to return pluginError: got %v(%T)", tt.use, err, err) + } + if perr.code != tt.code { + t.Errorf("Expected %s to return %d: got %d", tt.use, tt.code, perr.code) + } + } else { + t.Errorf("Error running %s: %+v", tt.use, err) + } } if out.String() != tt.expect { t.Errorf("Expected %s to output:\n%s\ngot\n%s", tt.use, tt.expect, out.String()) diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh new file mode 100755 index 000000000..ec8469657 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/exitwith.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exit $* diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml new file mode 100644 index 000000000..5691d1712 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/plugin.yaml @@ -0,0 +1,4 @@ +name: exitwith +usage: "exitwith code" +description: "This exits with the specified exit code" +command: "$HELM_PLUGIN_DIR/exitwith.sh" From c69af3d5bde00313ad2c818c12060dc9eddb86f3 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Fri, 25 Oct 2019 10:52:37 -0600 Subject: [PATCH 019/279] fix(wait): Removes ingress checks v3 port of #6792 After doing some more digging, I found out that updating the status of an `Ingress` object is completely optional. Because of this, Helm cannot support ingresses with the `--wait` flag because there is no standard way to identify that they are ready Signed-off-by: Taylor Thomas --- pkg/kube/wait.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index f60ce05e9..7198917c4 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -27,7 +27,6 @@ import ( batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" - networkingv1beta1 "k8s.io/api/networking/v1beta1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -126,15 +125,6 @@ func (w *waiter) waitForResources(created ResourceList) error { if !w.statefulSetReady(sts) { return false, nil } - case *extensionsv1beta1.Ingress, *networkingv1beta1.Ingress: - ing, err := w.c.NetworkingV1beta1().Ingresses(v.Namespace).Get(v.Name, metav1.GetOptions{}) - if err != nil { - return false, err - } - if !w.ingressReady(ing) { - return false, nil - } - case *corev1.ReplicationController, *extensionsv1beta1.ReplicaSet, *appsv1beta2.ReplicaSet, *appsv1.ReplicaSet: ok, err = w.podsReadyForObject(v.Namespace, value) } @@ -298,14 +288,6 @@ func (w *waiter) statefulSetReady(sts *appsv1.StatefulSet) bool { return true } -func (w *waiter) ingressReady(ing *networkingv1beta1.Ingress) bool { - if len(ing.Status.LoadBalancer.Ingress) == 0 { - w.log("Ingress is not ready: %s/%s", ing.GetNamespace(), ing.GetName()) - return false - } - return true -} - func getPods(client kubernetes.Interface, namespace, selector string) ([]corev1.Pod, error) { list, err := client.CoreV1().Pods(namespace).List(metav1.ListOptions{ LabelSelector: selector, From 5f27c0cbb7bcc3b356805233664a430d855e71e6 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 25 Oct 2019 22:39:21 +0900 Subject: [PATCH 020/279] Do test that a helm plugin can return non-zero exit code other than 1 Signed-off-by: Yusuke Kuoka --- cmd/helm/helm_test.go | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 934f14f86..924e8e9d3 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -20,6 +20,8 @@ import ( "bytes" "io/ioutil" "os" + "os/exec" + "runtime" "strings" "testing" @@ -151,3 +153,59 @@ func testChdir(t *testing.T, dir string) func() { } return func() { os.Chdir(old) } } + +func TestPluginExitCode(t *testing.T) { + if os.Getenv("RUN_MAIN_FOR_TESTING") == "1" { + os.Args = []string{"helm", "exitwith", "2"} + + // We DO call helm's main() here. So this looks like a normal `helm` process. + main() + + // As main calls os.Exit, we never reach this line. + // But the test called this block of code catches and verifies the exit code. + return + } + + // Currently, plugins assume a Linux subsystem. Skip the execution + // tests until this is fixed + if runtime.GOOS != "windows" { + // Do a second run of this specific test(TestPluginExitCode) with RUN_MAIN_FOR_TESTING=1 set, + // So that the second run is able to run main() and this first run can verify the exit status returned by that. + // + // This technique originates from https://talks.golang.org/2014/testing.slide#23. + cmd := exec.Command(os.Args[0], "-test.run=TestPluginExitCode") + cmd.Env = append( + os.Environ(), + "RUN_MAIN_FOR_TESTING=1", + // See pkg/cli/environment.go for which envvars can be used for configuring these passes + // and also see plugin_test.go for how a plugin env can be set up. + // We just does the same setup as plugin_test.go via envvars + "HELM_PLUGINS=testdata/helmhome/helm/plugins", + "HELM_REPOSITORY_CONFIG=testdata/helmhome/helm/repositories.yaml", + "HELM_REPOSITORY_CACHE=testdata/helmhome/helm/repository", + ) + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + cmd.Stdout = stdout + cmd.Stderr = stderr + err := cmd.Run() + exiterr, ok := err.(*exec.ExitError) + + if !ok { + t.Fatalf("Unexpected error returned by os.Exit: %T", err) + } + + if stdout.String() != "" { + t.Errorf("Expected no write to stdout: Got %q", stdout.String()) + } + + expectedStderr := "Error: plugin \"exitwith\" exited with error\n" + if stderr.String() != expectedStderr { + t.Errorf("Expected %q written to stderr: Got %q", expectedStderr, stderr.String()) + } + + if exiterr.ExitCode() != 2 { + t.Errorf("Expected exit code 2: Got %d", exiterr.ExitCode()) + } + } +} From bc2cd3c794aa50e4401a64bc499e2b914064f787 Mon Sep 17 00:00:00 2001 From: Aaron Mell Date: Sat, 26 Oct 2019 23:16:28 -0500 Subject: [PATCH 021/279] Allow namespace to be set by programs consuming helm. Signed-off-by: Aaron Mell --- cmd/helm/install.go | 2 +- cmd/helm/lint.go | 2 +- cmd/helm/release_testing.go | 2 +- cmd/helm/upgrade.go | 2 +- pkg/action/action.go | 2 +- pkg/cli/environment.go | 17 +++++++++-------- pkg/cli/environment_test.go | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index c80f8875d..32719aba6 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -205,7 +205,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options } } - client.Namespace = settings.Namespace() + client.Namespace = settings.GetNamespace() return client.Run(chartRequested, vals) } diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 9a2e8d31c..302a4b227 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -51,7 +51,7 @@ func newLintCmd(out io.Writer) *cobra.Command { if len(args) > 0 { paths = args } - client.Namespace = settings.Namespace() + client.Namespace = settings.GetNamespace() vals, err := valueOpts.MergeValues(getter.All(settings)) if err != nil { return err diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go index 7190ec736..4c962ccd1 100644 --- a/cmd/helm/release_testing.go +++ b/cmd/helm/release_testing.go @@ -46,7 +46,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command Long: releaseTestHelp, Args: require.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - client.Namespace = settings.Namespace() + client.Namespace = settings.GetNamespace() rel, runErr := client.Run(args[0]) // We only return an error if we weren't even able to get the // release, otherwise we keep going so we can print status and logs diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 282ddff0a..caaa6aca7 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -71,7 +71,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { Long: upgradeDesc, Args: require.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - client.Namespace = settings.Namespace() + client.Namespace = settings.GetNamespace() if client.Version == "" && client.Devel { debug("setting version to >0.0.0-0") diff --git a/pkg/action/action.go b/pkg/action/action.go index 653a57830..e037eb971 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -222,7 +222,7 @@ func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, h } var namespace string if !allNamespaces { - namespace = envSettings.Namespace() + namespace = envSettings.GetNamespace() } var store *storage.Storage diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 28e7873be..57c8e2c0c 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -38,10 +38,11 @@ import ( // EnvSettings describes all of the environment settings. type EnvSettings struct { - namespace string config genericclioptions.RESTClientGetter configOnce sync.Once + // Namespace is the namespace used by storage drivers + Namespace string // KubeConfig is the path to the kubeconfig file KubeConfig string // KubeContext is the name of the kubeconfig context. @@ -61,7 +62,7 @@ type EnvSettings struct { func New() *EnvSettings { env := EnvSettings{ - namespace: os.Getenv("HELM_NAMESPACE"), + Namespace: os.Getenv("HELM_NAMESPACE"), KubeContext: os.Getenv("HELM_KUBECONTEXT"), PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")), RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")), @@ -74,7 +75,7 @@ func New() *EnvSettings { // AddFlags binds flags to the given flagset. func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) { - fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request") + fs.StringVarP(&s.Namespace, "namespace", "n", s.Namespace, "namespace scope for this request") fs.StringVar(&s.KubeConfig, "kubeconfig", "", "path to the kubeconfig file") fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use") fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output") @@ -98,7 +99,7 @@ func (s *EnvSettings) EnvVars() map[string]string { "HELM_REGISTRY_CONFIG": s.RegistryConfig, "HELM_REPOSITORY_CACHE": s.RepositoryCache, "HELM_REPOSITORY_CONFIG": s.RepositoryConfig, - "HELM_NAMESPACE": s.Namespace(), + "HELM_NAMESPACE": s.GetNamespace(), "HELM_KUBECONTEXT": s.KubeContext, } @@ -110,9 +111,9 @@ func (s *EnvSettings) EnvVars() map[string]string { } //Namespace gets the namespace from the configuration -func (s *EnvSettings) Namespace() string { - if s.namespace != "" { - return s.namespace +func (s *EnvSettings) GetNamespace() string { + if s.Namespace != "" { + return s.Namespace } if ns, _, err := s.RESTClientGetter().ToRawKubeConfigLoader().Namespace(); err == nil { @@ -124,7 +125,7 @@ func (s *EnvSettings) Namespace() string { //RESTClientGetter gets the kubeconfig from EnvSettings func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { s.configOnce.Do(func() { - s.config = kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace) + s.config = kube.GetConfig(s.KubeConfig, s.KubeContext, s.Namespace) }) return s.config } diff --git a/pkg/cli/environment_test.go b/pkg/cli/environment_test.go index d6856dd01..60fe477a5 100644 --- a/pkg/cli/environment_test.go +++ b/pkg/cli/environment_test.go @@ -78,8 +78,8 @@ func TestEnvSettings(t *testing.T) { if settings.Debug != tt.debug { t.Errorf("expected debug %t, got %t", tt.debug, settings.Debug) } - if settings.Namespace() != tt.ns { - t.Errorf("expected namespace %q, got %q", tt.ns, settings.Namespace()) + if settings.GetNamespace() != tt.ns { + t.Errorf("expected namespace %q, got %q", tt.ns, settings.GetNamespace()) } if settings.KubeContext != tt.kcontext { t.Errorf("expected kube-context %q, got %q", tt.kcontext, settings.KubeContext) From c72caf6a11c986e6607e583337e4b77e58a45bdb Mon Sep 17 00:00:00 2001 From: Hang Park Date: Tue, 22 Oct 2019 12:38:49 +0900 Subject: [PATCH 022/279] fix(pkg/downloader): Calculate digest from both Chart.lock & Chart.yaml deps To make digests include information about Chart.yaml dependencies, not only the lock file, digest calculation is changed to accept both contents. This terminates the `dep build` command if Chart.yaml dependencies have been updated so that `dep up` should be executed properly, to prevent downloading wrong versions or mismatched subcharts. Note that previous Helm cannot know whether Chart.yaml dependencies were changed or not since the Chart.lock's digest is calculated by only Chart.lock contents, which don't include information about SemVer ranges and extra dependency fields such as aliases, conditions, and tags. Specially, SemVer can be written as a version range in Chart.yaml, but Chart.lock has the specific, resolved version of that range. Signed-off-by: Hang Park --- internal/resolver/resolver.go | 6 +-- internal/resolver/resolver_test.go | 75 +++++++++++++++++++++++------- pkg/downloader/manager.go | 2 +- 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/internal/resolver/resolver.go b/internal/resolver/resolver.go index 20b62dc66..e4dbab227 100644 --- a/internal/resolver/resolver.go +++ b/internal/resolver/resolver.go @@ -132,7 +132,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string return nil, errors.Errorf("can't get a valid version for repositories %s. Try changing the version constraint in Chart.yaml", strings.Join(missing, ", ")) } - digest, err := HashReq(locked) + digest, err := HashReq(reqs, locked) if err != nil { return nil, err } @@ -148,8 +148,8 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string // // This should be used only to compare against another hash generated by this // function. -func HashReq(req []*chart.Dependency) (string, error) { - data, err := json.Marshal(req) +func HashReq(req, lock []*chart.Dependency) (string, error) { + data, err := json.Marshal([2][]*chart.Dependency{req, lock}) if err != nil { return "", err } diff --git a/internal/resolver/resolver_test.go b/internal/resolver/resolver_test.go index 3af62b811..3828771cc 100644 --- a/internal/resolver/resolver_test.go +++ b/internal/resolver/resolver_test.go @@ -130,7 +130,7 @@ func TestResolve(t *testing.T) { t.Fatalf("Expected error in test %q", tt.name) } - if h, err := HashReq(tt.expect.Dependencies); err != nil { + if h, err := HashReq(tt.req, tt.expect.Dependencies); err != nil { t.Fatal(err) } else if h != l.Digest { t.Errorf("%q: hashes don't match.", tt.name) @@ -156,24 +156,63 @@ func TestResolve(t *testing.T) { } func TestHashReq(t *testing.T) { - expect := "sha256:d661820b01ed7bcf26eed8f01cf16380e0a76326ba33058d3150f919d9b15bc0" - req := []*chart.Dependency{ - {Name: "alpine", Version: "0.1.0", Repository: "http://localhost:8879/charts"}, - } - h, err := HashReq(req) - if err != nil { - t.Fatal(err) - } - if expect != h { - t.Errorf("Expected %q, got %q", expect, h) - } + expect := "sha256:fb239e836325c5fa14b29d1540a13b7d3ba13151b67fe719f820e0ef6d66aaaf" - req = []*chart.Dependency{} - h, err = HashReq(req) - if err != nil { - t.Fatal(err) + tests := []struct { + name string + chartVersion string + lockVersion string + wantError bool + }{ + { + name: "chart with the expected digest", + chartVersion: "0.1.0", + lockVersion: "0.1.0", + wantError: false, + }, + { + name: "ranged version but same resolved lock version", + chartVersion: "^0.1.0", + lockVersion: "0.1.0", + wantError: true, + }, + { + name: "ranged version resolved as higher version", + chartVersion: "^0.1.0", + lockVersion: "0.1.2", + wantError: true, + }, + { + name: "different version", + chartVersion: "0.1.2", + lockVersion: "0.1.2", + wantError: true, + }, + { + name: "different version with a range", + chartVersion: "^0.1.2", + lockVersion: "0.1.2", + wantError: true, + }, } - if expect == h { - t.Errorf("Expected %q != %q", expect, h) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req := []*chart.Dependency{ + {Name: "alpine", Version: tt.chartVersion, Repository: "http://localhost:8879/charts"}, + } + lock := []*chart.Dependency{ + {Name: "alpine", Version: tt.lockVersion, Repository: "http://localhost:8879/charts"}, + } + h, err := HashReq(req, lock) + if err != nil { + t.Fatal(err) + } + if !tt.wantError && expect != h { + t.Errorf("Expected %q, got %q", expect, h) + } else if tt.wantError && expect == h { + t.Errorf("Expected not %q, but same", expect) + } + }) } } diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index cc3af74db..ac61ac5ac 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -79,7 +79,7 @@ func (m *Manager) Build() error { } req := c.Metadata.Dependencies - if sum, err := resolver.HashReq(req); err != nil || sum != lock.Digest { + if sum, err := resolver.HashReq(req, lock.Dependencies); err != nil || sum != lock.Digest { return errors.New("Chart.lock is out of sync with Chart.yaml") } From ef7dd12cac1ad5044a086cff049592fa1d58d4cb Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sun, 27 Oct 2019 22:10:07 -0400 Subject: [PATCH 023/279] fix(cli): Remove trailing space of helm env output Signed-off-by: Marc Khouzam --- cmd/helm/env.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/env.go b/cmd/helm/env.go index 1881ac91d..1b9cb4012 100644 --- a/cmd/helm/env.go +++ b/cmd/helm/env.go @@ -56,7 +56,7 @@ type envOptions struct { func (o *envOptions) run(out io.Writer) error { for k, v := range o.settings.EnvVars() { - fmt.Printf("%s=\"%s\" \n", k, v) + fmt.Printf("%s=\"%s\"\n", k, v) } return nil } From eab9d2817db1975a92fa1c50d3f154e00d34e445 Mon Sep 17 00:00:00 2001 From: Aaron Mell Date: Mon, 28 Oct 2019 12:15:53 -0500 Subject: [PATCH 024/279] Revert "Allow namespace to be set by programs consuming helm." bc2cd3c794aa50e4401a64bc499e2b914064f787 Signed-off-by: Aaron Mell --- cmd/helm/install.go | 2 +- cmd/helm/lint.go | 2 +- cmd/helm/release_testing.go | 2 +- cmd/helm/upgrade.go | 2 +- pkg/action/action.go | 2 +- pkg/cli/environment.go | 17 ++++++++--------- pkg/cli/environment_test.go | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 32719aba6..c80f8875d 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -205,7 +205,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options } } - client.Namespace = settings.GetNamespace() + client.Namespace = settings.Namespace() return client.Run(chartRequested, vals) } diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 302a4b227..9a2e8d31c 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -51,7 +51,7 @@ func newLintCmd(out io.Writer) *cobra.Command { if len(args) > 0 { paths = args } - client.Namespace = settings.GetNamespace() + client.Namespace = settings.Namespace() vals, err := valueOpts.MergeValues(getter.All(settings)) if err != nil { return err diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go index 4c962ccd1..7190ec736 100644 --- a/cmd/helm/release_testing.go +++ b/cmd/helm/release_testing.go @@ -46,7 +46,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command Long: releaseTestHelp, Args: require.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - client.Namespace = settings.GetNamespace() + client.Namespace = settings.Namespace() rel, runErr := client.Run(args[0]) // We only return an error if we weren't even able to get the // release, otherwise we keep going so we can print status and logs diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index caaa6aca7..282ddff0a 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -71,7 +71,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { Long: upgradeDesc, Args: require.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - client.Namespace = settings.GetNamespace() + client.Namespace = settings.Namespace() if client.Version == "" && client.Devel { debug("setting version to >0.0.0-0") diff --git a/pkg/action/action.go b/pkg/action/action.go index e037eb971..653a57830 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -222,7 +222,7 @@ func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, h } var namespace string if !allNamespaces { - namespace = envSettings.GetNamespace() + namespace = envSettings.Namespace() } var store *storage.Storage diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 57c8e2c0c..28e7873be 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -38,11 +38,10 @@ import ( // EnvSettings describes all of the environment settings. type EnvSettings struct { + namespace string config genericclioptions.RESTClientGetter configOnce sync.Once - // Namespace is the namespace used by storage drivers - Namespace string // KubeConfig is the path to the kubeconfig file KubeConfig string // KubeContext is the name of the kubeconfig context. @@ -62,7 +61,7 @@ type EnvSettings struct { func New() *EnvSettings { env := EnvSettings{ - Namespace: os.Getenv("HELM_NAMESPACE"), + namespace: os.Getenv("HELM_NAMESPACE"), KubeContext: os.Getenv("HELM_KUBECONTEXT"), PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")), RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")), @@ -75,7 +74,7 @@ func New() *EnvSettings { // AddFlags binds flags to the given flagset. func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) { - fs.StringVarP(&s.Namespace, "namespace", "n", s.Namespace, "namespace scope for this request") + fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request") fs.StringVar(&s.KubeConfig, "kubeconfig", "", "path to the kubeconfig file") fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use") fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output") @@ -99,7 +98,7 @@ func (s *EnvSettings) EnvVars() map[string]string { "HELM_REGISTRY_CONFIG": s.RegistryConfig, "HELM_REPOSITORY_CACHE": s.RepositoryCache, "HELM_REPOSITORY_CONFIG": s.RepositoryConfig, - "HELM_NAMESPACE": s.GetNamespace(), + "HELM_NAMESPACE": s.Namespace(), "HELM_KUBECONTEXT": s.KubeContext, } @@ -111,9 +110,9 @@ func (s *EnvSettings) EnvVars() map[string]string { } //Namespace gets the namespace from the configuration -func (s *EnvSettings) GetNamespace() string { - if s.Namespace != "" { - return s.Namespace +func (s *EnvSettings) Namespace() string { + if s.namespace != "" { + return s.namespace } if ns, _, err := s.RESTClientGetter().ToRawKubeConfigLoader().Namespace(); err == nil { @@ -125,7 +124,7 @@ func (s *EnvSettings) GetNamespace() string { //RESTClientGetter gets the kubeconfig from EnvSettings func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { s.configOnce.Do(func() { - s.config = kube.GetConfig(s.KubeConfig, s.KubeContext, s.Namespace) + s.config = kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace) }) return s.config } diff --git a/pkg/cli/environment_test.go b/pkg/cli/environment_test.go index 60fe477a5..d6856dd01 100644 --- a/pkg/cli/environment_test.go +++ b/pkg/cli/environment_test.go @@ -78,8 +78,8 @@ func TestEnvSettings(t *testing.T) { if settings.Debug != tt.debug { t.Errorf("expected debug %t, got %t", tt.debug, settings.Debug) } - if settings.GetNamespace() != tt.ns { - t.Errorf("expected namespace %q, got %q", tt.ns, settings.GetNamespace()) + if settings.Namespace() != tt.ns { + t.Errorf("expected namespace %q, got %q", tt.ns, settings.Namespace()) } if settings.KubeContext != tt.kcontext { t.Errorf("expected kube-context %q, got %q", tt.kcontext, settings.KubeContext) From 31f2fea06130c4c18e9bb303956ed35f14242b9a Mon Sep 17 00:00:00 2001 From: Aaron Mell Date: Mon, 28 Oct 2019 12:33:55 -0500 Subject: [PATCH 025/279] Passing the namespace to actionconfig.Init instead of the entire object. Signed-off-by: Aaron Mell --- cmd/helm/helm.go | 2 +- cmd/helm/list.go | 2 +- pkg/action/action.go | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 0e935addb..078cc3c5e 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -67,7 +67,7 @@ func main() { actionConfig := new(action.Configuration) cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) - if err := actionConfig.Init(settings, false, os.Getenv("HELM_DRIVER"), debug); err != nil { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil { debug("%+v", err) switch e := err.(type) { case pluginError: diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 2200c153b..f80a81b9a 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -70,7 +70,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { Args: require.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if client.AllNamespaces { - if err := cfg.Init(settings, true, os.Getenv("HELM_DRIVER"), debug); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil { return err } } diff --git a/pkg/action/action.go b/pkg/action/action.go index 653a57830..48d6bf742 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -22,13 +22,13 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/client-go/discovery" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "helm.sh/helm/v3/internal/experimental/registry" "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/kube" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/storage" @@ -210,9 +210,7 @@ func (c *Configuration) recordRelease(r *release.Release) { } // InitActionConfig initializes the action configuration -func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, helmDriver string, log DebugLog) error { - getter := envSettings.RESTClientGetter() - +func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace string, helmDriver string, log DebugLog) error { kc := kube.New(getter) kc.Log = log @@ -220,10 +218,6 @@ func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, h if err != nil { return err } - var namespace string - if !allNamespaces { - namespace = envSettings.Namespace() - } var store *storage.Storage switch helmDriver { From ce494146a43a2d2524dbabeaac0c4a97f9158802 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 24 Oct 2019 14:35:48 -0700 Subject: [PATCH 026/279] fix(cmd): fix up help string - replace `helm repo search` with `helm search repo` - re-clarify that the --version flag accepts a semver range Signed-off-by: Matthew Fisher --- cmd/helm/search_repo.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index 8abcd1eb7..1bc279050 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -38,19 +38,20 @@ Search reads through all of the repositories configured on the system, and looks for matches. Search of these repositories uses the metadata stored on the system. -It will display the latest stable versions of that chart until you specify '--devel' flag -to also include development versions (alpha, beta, and release candidate releases), or -supply a version number with the '--version' flag. - -Examples: - # Searches only for stable releases, prerelease versions will be skipped - helm repo search - - # Searches for releases and prereleases (alpha, beta, and release candidate releases) - helm repo search --devel - - # searches only for release in version 1.0.0 - helm repo search --version 1.0.0 +It will display the latest stable versions of the charts found. If you +specify the --devel flag, the output will include pre-release versions. +If you want to search using a version constraint, use --version. + +Examples: + + # Search for stable release versions matching the keyword "nginx" + $ helm search repo nginx + + # Search for release versions matching the keyword "nginx", including pre-release versions + $ helm search repo nginx --devel + + # Search for the latest patch release for nginx-ingress 1.x + $ helm search repo nginx-ingress --version ^1.0.0 Repositories are managed with 'helm repo' commands. ` From a759f091276a80e83444e31798ee6514960de108 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 28 Oct 2019 13:40:20 -0700 Subject: [PATCH 027/279] ref(cmd): rename `helm plugin remove` to `helm plugin uninstall` Signed-off-by: Matthew Fisher --- cmd/helm/plugin.go | 4 +-- cmd/helm/plugin_install.go | 9 ++++--- .../{plugin_remove.go => plugin_uninstall.go} | 26 +++++++++---------- 3 files changed, 20 insertions(+), 19 deletions(-) rename cmd/helm/{plugin_remove.go => plugin_uninstall.go} (71%) diff --git a/cmd/helm/plugin.go b/cmd/helm/plugin.go index 5c7b34f09..8e1044f54 100644 --- a/cmd/helm/plugin.go +++ b/cmd/helm/plugin.go @@ -33,13 +33,13 @@ Manage client-side Helm plugins. func newPluginCmd(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "plugin", - Short: "add, list, or remove Helm plugins", + Short: "install, list, or uninstall Helm plugins", Long: pluginHelp, } cmd.AddCommand( newPluginInstallCmd(out), newPluginListCmd(out), - newPluginRemoveCmd(out), + newPluginUninstallCmd(out), newPluginUpdateCmd(out), ) return cmd diff --git a/cmd/helm/plugin_install.go b/cmd/helm/plugin_install.go index b790943bc..923352196 100644 --- a/cmd/helm/plugin_install.go +++ b/cmd/helm/plugin_install.go @@ -41,10 +41,11 @@ Example usage: func newPluginInstallCmd(out io.Writer) *cobra.Command { o := &pluginInstallOptions{} cmd := &cobra.Command{ - Use: "install [options] ...", - Short: "install one or more Helm plugins", - Long: pluginInstallDesc, - Args: require.ExactArgs(1), + Use: "install [options] ...", + Short: "install one or more Helm plugins", + Long: pluginInstallDesc, + Aliases: []string{"add"}, + Args: require.ExactArgs(1), PreRunE: func(cmd *cobra.Command, args []string) error { return o.complete(args) }, diff --git a/cmd/helm/plugin_remove.go b/cmd/helm/plugin_uninstall.go similarity index 71% rename from cmd/helm/plugin_remove.go rename to cmd/helm/plugin_uninstall.go index 6d517c15b..30f9bc91d 100644 --- a/cmd/helm/plugin_remove.go +++ b/cmd/helm/plugin_uninstall.go @@ -27,16 +27,16 @@ import ( "helm.sh/helm/v3/pkg/plugin" ) -type pluginRemoveOptions struct { +type pluginUninstallOptions struct { names []string } -func newPluginRemoveCmd(out io.Writer) *cobra.Command { - o := &pluginRemoveOptions{} +func newPluginUninstallCmd(out io.Writer) *cobra.Command { + o := &pluginUninstallOptions{} cmd := &cobra.Command{ - Use: "remove ...", - Aliases: []string{"rm"}, - Short: "remove one or more Helm plugins", + Use: "uninstall ...", + Aliases: []string{"rm", "remove"}, + Short: "uninstall one or more Helm plugins", PreRunE: func(cmd *cobra.Command, args []string) error { return o.complete(args) }, @@ -47,15 +47,15 @@ func newPluginRemoveCmd(out io.Writer) *cobra.Command { return cmd } -func (o *pluginRemoveOptions) complete(args []string) error { +func (o *pluginUninstallOptions) complete(args []string) error { if len(args) == 0 { - return errors.New("please provide plugin name to remove") + return errors.New("please provide plugin name to uninstall") } o.names = args return nil } -func (o *pluginRemoveOptions) run(out io.Writer) error { +func (o *pluginUninstallOptions) run(out io.Writer) error { debug("loading installed plugins from %s", settings.PluginsDirectory) plugins, err := findPlugins(settings.PluginsDirectory) if err != nil { @@ -64,10 +64,10 @@ func (o *pluginRemoveOptions) run(out io.Writer) error { var errorPlugins []string for _, name := range o.names { if found := findPlugin(plugins, name); found != nil { - if err := removePlugin(found); err != nil { - errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to remove plugin %s, got error (%v)", name, err)) + if err := uninstallPlugin(found); err != nil { + errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to uninstall plugin %s, got error (%v)", name, err)) } else { - fmt.Fprintf(out, "Removed plugin: %s\n", name) + fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) } } else { errorPlugins = append(errorPlugins, fmt.Sprintf("Plugin: %s not found", name)) @@ -79,7 +79,7 @@ func (o *pluginRemoveOptions) run(out io.Writer) error { return nil } -func removePlugin(p *plugin.Plugin) error { +func uninstallPlugin(p *plugin.Plugin) error { if err := os.RemoveAll(p.Dir); err != nil { return err } From 712c90fd8282dfa5ac75a23a36577cdc4443032c Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 28 Oct 2019 13:45:51 -0700 Subject: [PATCH 028/279] ref(go.mod): kubernetes 1.16.2 Signed-off-by: Adam Reese --- go.mod | 74 +++++++++++++--------------- go.sum | 150 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 162 insertions(+), 62 deletions(-) diff --git a/go.mod b/go.mod index 6744a7451..57b342ed2 100644 --- a/go.mod +++ b/go.mod @@ -15,40 +15,60 @@ require ( github.com/deislabs/oras v0.7.0 github.com/docker/distribution v2.7.1+incompatible github.com/docker/docker v1.4.2-0.20181221150755-2cb26cfe9cbf - github.com/docker/go-units v0.3.3 + github.com/docker/go-units v0.4.0 github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect - github.com/evanphx/json-patch v4.2.0+incompatible + github.com/emicklei/go-restful v2.11.1+incompatible // indirect + github.com/evanphx/json-patch v4.5.0+incompatible github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-openapi/jsonreference v0.19.3 // indirect + github.com/go-openapi/spec v0.19.4 // indirect github.com/gobwas/glob v0.2.3 github.com/gofrs/flock v0.7.1 - github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect + github.com/gogo/protobuf v1.3.1 // indirect + github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect github.com/google/btree v1.0.0 // indirect - github.com/googleapis/gnostic v0.2.0 // indirect + github.com/google/go-cmp v0.3.1 // indirect + github.com/googleapis/gnostic v0.3.1 // indirect github.com/gosuri/uitable v0.0.1 github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect + github.com/hashicorp/golang-lru v0.5.3 // indirect + github.com/imdario/mergo v0.3.8 // indirect + github.com/mailru/easyjson v0.7.0 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mattn/go-shellwords v1.0.5 github.com/mitchellh/copystructure v1.0.0 + github.com/onsi/ginkgo v1.10.1 // indirect + github.com/onsi/gomega v1.7.0 // indirect github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/image-spec v1.0.1 github.com/pkg/errors v0.8.1 + github.com/prometheus/client_golang v1.2.1 // indirect github.com/sirupsen/logrus v1.4.2 github.com/spf13/cobra v0.0.5 - github.com/spf13/pflag v1.0.3 + github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.1.0 github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656 // indirect - golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 - gopkg.in/yaml.v2 v2.2.2 - k8s.io/api v0.0.0 - k8s.io/apiextensions-apiserver v0.0.0 - k8s.io/apimachinery v0.0.0 - k8s.io/cli-runtime v0.0.0 - k8s.io/client-go v0.0.0 - k8s.io/klog v0.4.0 - k8s.io/kubectl v0.0.0 + golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 + golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 // indirect + golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 // indirect + golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + google.golang.org/appengine v1.6.5 // indirect + google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect + google.golang.org/grpc v1.24.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.2.4 + k8s.io/api v0.0.0-20191016110408-35e52d86657a + k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65 + k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8 + k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5 + k8s.io/client-go v0.0.0-20191016111102-bec269661e48 + k8s.io/klog v1.0.0 + k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d // indirect + k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51 + k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 // indirect sigs.k8s.io/yaml v1.1.0 ) @@ -68,31 +88,5 @@ replace ( gopkg.in/inf.v0 v0.9.1 => github.com/go-inf/inf v0.9.1 gopkg.in/square/go-jose.v2 v2.3.0 => github.com/square/go-jose v2.3.0+incompatible - // k8s.io/kubernetes has a go.mod file that sets the version of the following - // modules to v0.0.0. This causes go to throw an error. These need to be set - // to a version for Go to process them. Here they are set to the same - // revision as the marked version of Kubernetes. When Kubernetes is updated - // these need to be updated as well. - k8s.io/api => k8s.io/kubernetes/staging/src/k8s.io/api v0.0.0-20191001043732-d647ddbd755f - k8s.io/apiextensions-apiserver => k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20191001043732-d647ddbd755f - k8s.io/apimachinery => k8s.io/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20191001043732-d647ddbd755f - k8s.io/apiserver => k8s.io/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20191001043732-d647ddbd755f - k8s.io/cli-runtime => k8s.io/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20191001043732-d647ddbd755f - k8s.io/client-go => k8s.io/kubernetes/staging/src/k8s.io/client-go v0.0.0-20191001043732-d647ddbd755f - k8s.io/cloud-provider => k8s.io/kubernetes/staging/src/k8s.io/cloud-provider v0.0.0-20191001043732-d647ddbd755f - k8s.io/cluster-bootstrap => k8s.io/kubernetes/staging/src/k8s.io/cluster-bootstrap v0.0.0-20191001043732-d647ddbd755f - k8s.io/code-generator => k8s.io/kubernetes/staging/src/k8s.io/code-generator v0.0.0-20191001043732-d647ddbd755f - k8s.io/component-base => k8s.io/kubernetes/staging/src/k8s.io/component-base v0.0.0-20191001043732-d647ddbd755f - k8s.io/cri-api => k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20191001043732-d647ddbd755f - k8s.io/csi-translation-lib => k8s.io/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20191001043732-d647ddbd755f - k8s.io/kube-aggregator => k8s.io/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20191001043732-d647ddbd755f - k8s.io/kube-controller-manager => k8s.io/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20191001043732-d647ddbd755f - k8s.io/kube-proxy => k8s.io/kubernetes/staging/src/k8s.io/kube-proxy v0.0.0-20191001043732-d647ddbd755f - k8s.io/kube-scheduler => k8s.io/kubernetes/staging/src/k8s.io/kube-scheduler v0.0.0-20191001043732-d647ddbd755f - k8s.io/kubectl => k8s.io/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20191001043732-d647ddbd755f - k8s.io/kubelet => k8s.io/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20191001043732-d647ddbd755f - k8s.io/legacy-cloud-providers => k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers v0.0.0-20191001043732-d647ddbd755f - k8s.io/metrics => k8s.io/kubernetes/staging/src/k8s.io/metrics v0.0.0-20191001043732-d647ddbd755f - k8s.io/sample-apiserver => k8s.io/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20191001043732-d647ddbd755f rsc.io/letsencrypt => github.com/dmcgowan/letsencrypt v0.0.0-20160928181947-1847a81d2087 ) diff --git a/go.sum b/go.sum index c82eb87fe..5659b06f8 100644 --- a/go.sum +++ b/go.sum @@ -36,6 +36,7 @@ github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiU github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= github.com/Microsoft/hcsshim v0.8.6 h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -47,13 +48,19 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/blang/semver v3.5.0+incompatible h1:CGxCgetQ64DKk7rdZ++Vfnb1+ogGNnB17OJKJXD2Cfs= @@ -66,6 +73,8 @@ github.com/bugsnag/bugsnag-go v1.5.0 h1:tP8hiPv1pGGW3LA6LKy5lW6WG+y9J2xWUdPd3WC4 github.com/bugsnag/bugsnag-go v1.5.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/panicwrap v1.2.0 h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA= github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA= +github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 h1:7aWHqerlJ41y6FOsEUvknqgXnGmJyJSbjhAWq5pO4F8= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -117,18 +126,25 @@ github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 h1:X0fj836zx99zF github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e h1:p1yVGRW3nmb85p1Sh1ZJSDm4A4iKLS5QNbvUHMgGu/M= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful v2.11.1+incompatible h1:CjKsv3uWcCMvySPQYKxO8XX3f9zD4FeZRsW4G0B4ffE= +github.com/emicklei/go-restful v2.11.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= +github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= @@ -141,48 +157,68 @@ github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2H github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-inf/inf v0.9.1 h1:F4sloU4SED74gTeM3mWLrf8yyMAgVCV0puw3vhtKWrk= +github.com/go-inf/inf v0.9.1/go.mod h1:ZWwB6rTV+0pO94RdIMKue59tExzQp6/pj/BMuPQkXaA= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.19.2 h1:ophLETFestFZHk3ji7niPEL4d466QjW+0Tdg5VyDq7E= github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY= github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= +github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.2 h1:rf5ArTHmIJxyV5Oiks+Su0mUens1+AjpkPoWr5xFRcI= github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= +github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.2 h1:SStNd1jRcYtfKCN7R0laGNs80WYYvn5CbBjM2sOmCrE= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= +github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo= +github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2 h1:jvO6bCMBEilGwMfHhrd61zIID4oIFdwb76V17SM88dE= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/validate v0.19.2 h1:ky5l57HjyVRrsJfd2+Ro5Z9PjGuKbsmftwyMtk8H7js= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= @@ -194,11 +230,13 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff h1:kOkM9whyQYodu09SJ6W3NCsHG7crFaJILQ22Gozp3lg= -github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE= +github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -206,6 +244,8 @@ github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkYFkPcDKwRXegd+iM6E7matEszMG5HhwytU8= github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= @@ -215,6 +255,8 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -225,8 +267,8 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= -github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= +github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/gophercloud/gophercloud v0.1.0 h1:P/nh25+rzXouhytV2pUHBb65fnds26Ghl8/391+sT5o= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA= @@ -248,6 +290,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpg github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= +github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -256,6 +300,8 @@ github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63 github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ= +github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= @@ -289,6 +335,9 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= +github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.5 h1:JhhFTIOslh5ZsPrpa3Wdg8bF0WI3b44EMblmU9wIsXc= @@ -302,6 +351,7 @@ github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFW github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -318,14 +368,19 @@ github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c h1:nXxl5PrvVm2L/wCy8d github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= +github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= @@ -349,16 +404,30 @@ github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prY github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.2.1 h1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI= +github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0 h1:kUZDBDTdBVBYBj5Tmh2NZLlF60mfjA27rM34b+cVwNU= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190129233650-316cf8ccfec5 h1:Etei0Wx6pooT/DeOKcGTr1M/01ggz95Ajq8BBwCOKBU= github.com/prometheus/procfs v0.0.0-20190129233650-316cf8ccfec5/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= +github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -379,6 +448,8 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6 github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -426,6 +497,8 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXT golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 h1:ZC1Xn5A1nlpSmQCIva4bZ3ob3lmhYIefc+GU+DLg1Ow= +golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -449,9 +522,13 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68= golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 h1:N66aaryRB3Ax92gH0v3hp1QYZ3zWWCCUR/j8Ifh45Ss= +golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= @@ -459,6 +536,7 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -476,6 +554,9 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 h1:u/E0NqCIWRDAo9WCFo6Ko49njPFDLSd3z+X1HgWDMpE= +golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -483,6 +564,8 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -496,7 +579,9 @@ golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485 h1:OB/uP/Puiu5vS5QMRPrXCDWUPb+kt8f1KW8oQzFejQw= gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ= @@ -505,17 +590,25 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190128161407-8ac453e89fca/go.mod h1:L3J43x8/uS+qIUoksaLKe6OS3nUKxOKuIFz1sl2/jx4= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7 h1:ZUjXAXmrAyrmmCPHgCA/vChHcpsX27MZ3yBonD/z1KE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 h1:nfPFGzJkUDX6uBmpN/pSw7MbOAWegH5QDQuoXFHedLg= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 h1:UXl+Zk3jqqcbEVV7ace5lrt4YdA4tXiz3f/KbmD29Vo= +google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= +google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= @@ -524,6 +617,7 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/square/go-jose.v1 v1.1.2 h1:/5jmADZB+RiKtZGr4HxsEFOEfbfsjTKsVnqpThUpE30= gopkg.in/square/go-jose.v1 v1.1.2/go.mod h1:QpYS+a4WhS+DTlyQIi6Ka7MS3SuR9a055rgXNEe6EiA= @@ -534,40 +628,51 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.0.0-20191016110408-35e52d86657a h1:VVUE9xTCXP6KUPMf92cQmN88orz600ebexcRRaBTepQ= +k8s.io/api v0.0.0-20191016110408-35e52d86657a/go.mod h1:/L5qH+AD540e7Cetbui1tuJeXdmNhO8jM6VkXeDdDhQ= +k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65 h1:kThoiqgMsSwBdMK/lPgjtYTsEjbUU9nXCA9DyU3feok= +k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65/go.mod h1:5BINdGqggRXXKnDgpwoJ7PyQH8f+Ypp02fvVNcIFy9s= +k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8 h1:Iieh/ZEgT3BWwbLD5qEKcY06jKuPEl6zC7gPSehoLw4= +k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8/go.mod h1:llRdnznGEAqC3DcNm6yEj472xaFVfLM7hnYofMb12tQ= +k8s.io/apiserver v0.0.0-20191016112112-5190913f932d h1:leksCBKKBrPJmW1jV4dZUvwqmVtXpKdzpHsqXfFS094= +k8s.io/apiserver v0.0.0-20191016112112-5190913f932d/go.mod h1:7OqfAolfWxUM/jJ/HBLyE+cdaWFBUoo5Q5pHgJVj2ws= +k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5 h1:8ZfMjkMBzcXEawLsYHg9lDM7aLEVso3NiVKfUTnN56A= +k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5/go.mod h1:sDl6WKSQkDM6zS1u9F49a0VooQ3ycYFBFLqd2jf2Xfo= +k8s.io/client-go v0.0.0-20191016111102-bec269661e48 h1:C2XVy2z0dV94q9hSSoCuTPp1KOG7IegvbdXuz9VGxoU= +k8s.io/client-go v0.0.0-20191016111102-bec269661e48/go.mod h1:hrwktSwYGI4JK+TJA3dMaFyyvHVi/aLarVHpbs8bgCU= +k8s.io/code-generator v0.0.0-20191004115455-8e001e5d1894 h1:NMYlxaF7rYQJk2E2IyrUhaX81zX24+dmoZdkPw0gJqI= +k8s.io/code-generator v0.0.0-20191004115455-8e001e5d1894/go.mod h1:mJUgkl06XV4kstAnLHAIzJPVCOzVR+ZcfPIv4fUsFCY= +k8s.io/component-base v0.0.0-20191016111319-039242c015a9 h1:2D+G/CCNVdYc0h9D+tX+0SmtcyQmby6uzNityrps1s0= +k8s.io/component-base v0.0.0-20191016111319-039242c015a9/go.mod h1:SuWowIgd/dtU/m/iv8OD9eOxp3QZBBhTIiWMsBQvKjI= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/gengo v0.0.0-20190822140433-26a664648505 h1:ZY6yclUKVbZ+SdWnkfY+Je5vrMpKOxmGeKRbsXVmqYM= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.4.0 h1:lCJCxf/LIowc2IGS9TPjWDyXY4nOmdGdfcwwDQCOURQ= k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= +k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kubernetes/staging/src/k8s.io/api v0.0.0-20191001043732-d647ddbd755f h1:qnPdWj5mRMsfvP85N8J2ogqiu8Aq1T6MPsJdxL3g6Ds= -k8s.io/kubernetes/staging/src/k8s.io/api v0.0.0-20191001043732-d647ddbd755f/go.mod h1:cHpnPcbNeE90PrTRnTu13OM+FN+ROt82odVbEh++81o= -k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20191001043732-d647ddbd755f h1:bpyOu4+qNIFZRKRtSXGv/iJ7YzqwXrAOoaKxUaYKrV4= -k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20191001043732-d647ddbd755f/go.mod h1:f1tFT2pOqPzfckbG1GjHIzy3G+T2LW7rchcruNoLaiM= -k8s.io/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20191001043732-d647ddbd755f h1:X3br+JCtf40mnzQsKAnHnezd1CvCENgG5uLJTbAspZ4= -k8s.io/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20191001043732-d647ddbd755f/go.mod h1:PNw+FbGH4/s3zK9V3rAeMiHTbQz2CU/yqAkfQ2UgLVs= -k8s.io/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20191001043732-d647ddbd755f h1:QIhu1g7jmiv/90qGiPiCOTHFYEcrL0HA5P/6G/pt7zM= -k8s.io/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20191001043732-d647ddbd755f/go.mod h1:WmFoxjELD2xtWb77Yj9RPibT5ACkQYEW9lPQtNkGtbE= -k8s.io/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20191001043732-d647ddbd755f h1:6CkT409OUoX4ZiP++1N3id3PCcOoktBvclNsDKPKrfc= -k8s.io/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20191001043732-d647ddbd755f/go.mod h1:nBogvbgjMgo7AeVA6CuqVO13LVIfmlQ11t6xzAJdBN8= -k8s.io/kubernetes/staging/src/k8s.io/client-go v0.0.0-20191001043732-d647ddbd755f h1:ksJC2cpBqkCP8bzmfDYXr65JRpt9JmANvaKIR3qggt4= -k8s.io/kubernetes/staging/src/k8s.io/client-go v0.0.0-20191001043732-d647ddbd755f/go.mod h1:GiGfbsjtP4tOW6zgpL8/vCUoyXAV5+9X2onLursPi08= -k8s.io/kubernetes/staging/src/k8s.io/code-generator v0.0.0-20191001043732-d647ddbd755f/go.mod h1:L8deZCu6NpzgKzY91TOGKJ1JtAoHd8WyJ/HdoxqZCGo= -k8s.io/kubernetes/staging/src/k8s.io/component-base v0.0.0-20191001043732-d647ddbd755f h1:fwZSUxpQ99UBEkIhHbzY2pE3SPU9Zn4yZkMSolEt6Jw= -k8s.io/kubernetes/staging/src/k8s.io/component-base v0.0.0-20191001043732-d647ddbd755f/go.mod h1:spPP+vRNS8EsnNNIhFCZTTuRO3XhV1WoF18HJySoZn8= -k8s.io/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20191001043732-d647ddbd755f h1:vH4+rTRLDI8z9dQCZ6cJcIi3RMGZ6JwJWyLbrSNHBCE= -k8s.io/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20191001043732-d647ddbd755f/go.mod h1:ellVfoCz8MlDjTnkqsTkU5svJOIjcK3XNx/onmixgDk= -k8s.io/kubernetes/staging/src/k8s.io/metrics v0.0.0-20191001043732-d647ddbd755f/go.mod h1:vQHTmz0IaEb7/OXPSor1uga8Er0V+2M5aSdXG832NbU= +k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d h1:Xpe6sK+RY4ZgCTyZ3y273UmFmURhjtoJiwOMbQsXitY= +k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= +k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51 h1:RBkTKVMF+xsNsSOVc0+HdC0B5gD1sr6s6Cu5w9qNbuQ= +k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51/go.mod h1:gL826ZTIfD4vXTGlmzgTbliCAT9NGiqpCqK2aNYv5MQ= +k8s.io/metrics v0.0.0-20191016113814-3b1a734dba6e h1:VbAmCGT95GvCZaGtW3oLhf7d2FXT+lnWiTtPE8hzPVo= +k8s.io/metrics v0.0.0-20191016113814-3b1a734dba6e/go.mod h1:ve7/vMWeY5lEBkZf6Bt5TTbGS3b8wAxwGbdXAsufjRs= k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 h1:Gi+/O1saihwDqnlmC8Vhv1M5Sp4+rbOmK9TbsLn8ZEA= +k8s.io/utils v0.0.0-20191010214722-8d271d903fe4/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= @@ -576,6 +681,7 @@ modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca h1:6dsH6AYQWbyZmtttJNe8Gq1cXOeS1BdV3eW37zHilAQ= sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= From e2233bb5717bedc6a5c267347e7b19edcc2de3ee Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 28 Oct 2019 13:28:36 -0700 Subject: [PATCH 029/279] fix(cmd): clean up helpstring formatting Signed-off-by: Matthew Fisher --- cmd/helm/chart.go | 4 +--- cmd/helm/completion.go | 4 ++-- cmd/helm/docs.go | 2 -- cmd/helm/get.go | 8 ++++---- cmd/helm/history.go | 2 +- cmd/helm/install.go | 16 ++++++++-------- cmd/helm/list.go | 6 +++--- cmd/helm/plugin_install.go | 3 --- cmd/helm/registry.go | 4 ---- cmd/helm/repo.go | 2 -- cmd/helm/root.go | 37 +++++++++++++++++++++---------------- cmd/helm/upgrade.go | 4 ++-- 12 files changed, 42 insertions(+), 50 deletions(-) diff --git a/cmd/helm/chart.go b/cmd/helm/chart.go index 96082ab3e..adc874cfe 100644 --- a/cmd/helm/chart.go +++ b/cmd/helm/chart.go @@ -26,9 +26,7 @@ import ( const chartHelp = ` This command consists of multiple subcommands to work with the chart cache. -It can be used to push, pull, tag, list, or remove Helm charts. -Example usage: - $ helm chart pull [URL] +The subcommands can be used to push, pull, tag, list, or remove Helm charts. ` func newChartCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { diff --git a/cmd/helm/completion.go b/cmd/helm/completion.go index 7122b92be..a44140d9f 100644 --- a/cmd/helm/completion.go +++ b/cmd/helm/completion.go @@ -30,11 +30,11 @@ Generate autocompletions script for Helm for the specified shell (bash or zsh). This command can generate shell autocompletions. e.g. - $ helm completion bash + $ helm completion bash Can be sourced as such - $ source <(helm completion bash) + $ source <(helm completion bash) ` var ( diff --git a/cmd/helm/docs.go b/cmd/helm/docs.go index 7eb9c1c88..2c9020fb9 100644 --- a/cmd/helm/docs.go +++ b/cmd/helm/docs.go @@ -35,8 +35,6 @@ This command can generate documentation for Helm in the following formats: - Man pages It can also generate bash autocompletions. - - $ helm docs markdown -dir mydocs/ ` type docsOptions struct { diff --git a/cmd/helm/get.go b/cmd/helm/get.go index bfb8c2522..7c4854b59 100644 --- a/cmd/helm/get.go +++ b/cmd/helm/get.go @@ -29,10 +29,10 @@ var getHelp = ` This command consists of multiple subcommands which can be used to get extended information about the release, including: - - The values used to generate the release - - The generated manifest file - - The notes provided by the chart of the release - - The hooks associated with the release +- The values used to generate the release +- The generated manifest file +- The notes provided by the chart of the release +- The hooks associated with the release ` func newGetCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 99f3444eb..aa873db1e 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -41,7 +41,7 @@ configures the maximum length of the revision list returned. The historical release set is printed as a formatted table, e.g: - $ helm history angry-bird --max=4 + $ helm history angry-bird REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 1 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Initial install 2 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Upgraded successfully diff --git a/cmd/helm/install.go b/cmd/helm/install.go index c80f8875d..40935db17 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -47,30 +47,30 @@ a string value use '--set-string'. In case a value is large and therefore you want not to use neither '--values' nor '--set', use '--set-file' to read the single large value from file. - $ helm install -f myvalues.yaml myredis ./redis + $ helm install -f myvalues.yaml myredis ./redis or - $ helm install --set name=prod myredis ./redis + $ helm install --set name=prod myredis ./redis or - $ helm install --set-string long_int=1234567890 myredis ./redis + $ helm install --set-string long_int=1234567890 myredis ./redis or - $ helm install --set-file my_script=dothings.sh myredis ./redis + $ helm install --set-file my_script=dothings.sh 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 myredis ./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 myredis ./redis + $ helm install --set foo=bar --set foo=newbar myredis ./redis To check the generated manifests of a release without installing the chart, @@ -93,8 +93,8 @@ A chart reference is a convenient way of referencing a chart in a chart reposito When you use a chart reference with a repo prefix ('example/mariadb'), Helm will look in the local configuration for a chart repository named 'example', and will then look for a -chart in that repository whose name is 'mariadb'. It will install the latest stable version of that chart -until you specify '--devel' flag to also include development version (alpha, beta, and release candidate releases), or +chart in that repository whose name is 'mariadb'. It will install the latest stable version of that chart +until you specify '--devel' flag to also include development version (alpha, beta, and release candidate releases), or supply a version number with the '--version' flag. To see the list of chart repositories, use 'helm repo list'. To search for diff --git a/cmd/helm/list.go b/cmd/helm/list.go index f80a81b9a..a3003e219 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -45,9 +45,9 @@ If the --filter flag is provided, it will be treated as a filter. Filters are regular expressions (Perl compatible) that are applied to the list of releases. Only items that match the filter will be returned. - $ helm list --filter 'ara[a-z]+' - NAME UPDATED CHART - maudlin-arachnid Mon May 9 16:07:08 2016 alpine-0.1.0 + $ helm list --filter 'ara[a-z]+' + NAME UPDATED CHART + maudlin-arachnid Mon May 9 16:07:08 2016 alpine-0.1.0 If no results are found, 'helm list' will exit 0, but with no output (or in the case of no '-q' flag, only headers). diff --git a/cmd/helm/plugin_install.go b/cmd/helm/plugin_install.go index b790943bc..9ff7ff265 100644 --- a/cmd/helm/plugin_install.go +++ b/cmd/helm/plugin_install.go @@ -33,9 +33,6 @@ type pluginInstallOptions struct { const pluginInstallDesc = ` This command allows you to install a plugin from a url to a VCS repo or a local path. - -Example usage: - $ helm plugin install https://github.com/technosophos/helm-template ` func newPluginInstallCmd(out io.Writer) *cobra.Command { diff --git a/cmd/helm/registry.go b/cmd/helm/registry.go index 479f2ed63..d13c308b2 100644 --- a/cmd/helm/registry.go +++ b/cmd/helm/registry.go @@ -25,10 +25,6 @@ import ( const registryHelp = ` This command consists of multiple subcommands to interact with registries. - -It can be used to login to or logout from a registry. -Example usage: - $ helm registry login [URL] ` func newRegistryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { diff --git a/cmd/helm/repo.go b/cmd/helm/repo.go index 8071a8264..ad6ceaa8f 100644 --- a/cmd/helm/repo.go +++ b/cmd/helm/repo.go @@ -30,8 +30,6 @@ var repoHelm = ` This command consists of multiple subcommands to interact with chart repositories. It can be used to add, remove, list, and index chart repositories. -Example usage: - $ helm repo add [NAME] [REPO_URL] ` func newRepoCmd(out io.Writer) *cobra.Command { diff --git a/cmd/helm/root.go b/cmd/helm/root.go index a03f77576..54b4ef59a 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -282,14 +282,14 @@ __helm_custom_func() __helm_list_releases return ;; - helm_repo_remove) - __helm_list_repos - return - ;; - helm_plugin_remove | helm_plugin_update) - __helm_list_plugins - return - ;; + helm_repo_remove) + __helm_list_repos + return + ;; + helm_plugin_remove | helm_plugin_update) + __helm_list_plugins + return + ;; *) ;; esac @@ -311,17 +311,22 @@ var globalUsage = `The Kubernetes package manager Common actions for Helm: - helm search: search for charts -- helm fetch: download a chart to your local directory to view +- helm pull: download a chart to your local directory to view - helm install: upload the chart to Kubernetes - helm list: list releases of charts -Environment: - $XDG_CACHE_HOME set an alternative location for storing cached files. - $XDG_CONFIG_HOME set an alternative location for storing Helm configuration. - $XDG_DATA_HOME set an alternative location for storing Helm data. - $HELM_DRIVER set the backend storage driver. Values are: configmap, secret, memory - $HELM_NO_PLUGINS disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. - $KUBECONFIG set an alternative Kubernetes configuration file (default "~/.kube/config") +Environment variables: + ++------------------+-----------------------------------------------------------------------------+ +| Name | Description | ++------------------+-----------------------------------------------------------------------------+ +| $XDG_CACHE_HOME | set an alternative location for storing cached files. | +| $XDG_CONFIG_HOME | set an alternative location for storing Helm configuration. | +| $XDG_DATA_HOME | set an alternative location for storing Helm data. | +| $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory | +| $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. | +| $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") | ++------------------+-----------------------------------------------------------------------------+ Helm stores configuration based on the XDG base directory specification, so diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 282ddff0a..eadc3b63d 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -51,13 +51,13 @@ You can specify the '--values'/'-f' flag multiple times. The priority will be gi 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 upgrade -f myvalues.yaml -f override.yaml redis ./redis + $ helm upgrade -f myvalues.yaml -f override.yaml redis ./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 upgrade --set foo=bar --set foo=newbar redis ./redis + $ helm upgrade --set foo=bar --set foo=newbar redis ./redis ` func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { From 6d91d1aca802c6bb4ef132408c3534737b765d65 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Tue, 29 Oct 2019 22:22:33 +0900 Subject: [PATCH 030/279] fix(v3): Allow rendering CRDs in `helm template` client-only validation Fixes #6665 Ref https://github.com/helm/helm/pull/6729#issuecomment-547415165 Relates to #6729 and #6811 Signed-off-by: Yusuke Kuoka --- pkg/chartutil/capabilities.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index 9d29c4d9a..97e4cc945 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -17,6 +17,8 @@ package chartutil import ( "k8s.io/client-go/kubernetes/scheme" + + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" ) var ( @@ -73,6 +75,10 @@ func (v VersionSet) Has(apiVersion string) bool { } func allKnownVersions() VersionSet { + // Otherwise `helm template` fails validating due to an error like the below: + // Error: apiVersion "apiextensions.k8s.io/v1beta1" in mychart/templates/crd.yaml is not available + apiextensionsv1beta1.AddToScheme(scheme.Scheme) + groups := scheme.Scheme.PrioritizedVersionsAllGroups() vs := make(VersionSet, 0, len(groups)) for _, gv := range groups { From 5a7d4f1f748afcbe9c714c1ce35cef7395a157f8 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 29 Oct 2019 09:06:09 -0700 Subject: [PATCH 031/279] fix(loader): error out when loading irregular files Signed-off-by: Matthew Fisher --- internal/sympath/walk.go | 2 + pkg/chart/loader/directory.go | 8 ++++ pkg/chart/loader/load_test.go | 40 ++++++++++++++++++ pkg/chart/loader/testdata/LICENSE | 1 + .../frobnitz_with_dev_null/.helmignore | 1 + .../frobnitz_with_dev_null/Chart.lock | 8 ++++ .../frobnitz_with_dev_null/Chart.yaml | 27 ++++++++++++ .../frobnitz_with_dev_null/INSTALL.txt | 1 + .../testdata/frobnitz_with_dev_null/LICENSE | 1 + .../testdata/frobnitz_with_dev_null/README.md | 11 +++++ .../frobnitz_with_dev_null/charts/_ignore_me | 1 + .../charts/alpine/Chart.yaml | 5 +++ .../charts/alpine/README.md | 9 ++++ .../charts/alpine/charts/mast1/Chart.yaml | 5 +++ .../charts/alpine/charts/mast1/values.yaml | 4 ++ .../charts/alpine/charts/mast2-0.1.0.tgz | Bin 0 -> 252 bytes .../charts/alpine/templates/alpine-pod.yaml | 14 ++++++ .../charts/alpine/values.yaml | 2 + .../charts/mariner-4.3.2.tgz | Bin 0 -> 967 bytes .../frobnitz_with_dev_null/docs/README.md | 1 + .../testdata/frobnitz_with_dev_null/icon.svg | 8 ++++ .../frobnitz_with_dev_null/ignore/me.txt | 0 .../testdata/frobnitz_with_dev_null/null | 1 + .../templates/template.tpl | 1 + .../frobnitz_with_dev_null/values.yaml | 6 +++ .../frobnitz_with_symlink/.helmignore | 1 + .../testdata/frobnitz_with_symlink/Chart.lock | 8 ++++ .../testdata/frobnitz_with_symlink/Chart.yaml | 27 ++++++++++++ .../frobnitz_with_symlink/INSTALL.txt | 1 + .../testdata/frobnitz_with_symlink/README.md | 11 +++++ .../frobnitz_with_symlink/charts/_ignore_me | 1 + .../charts/alpine/Chart.yaml | 5 +++ .../charts/alpine/README.md | 9 ++++ .../charts/alpine/charts/mast1/Chart.yaml | 5 +++ .../charts/alpine/charts/mast1/values.yaml | 4 ++ .../charts/alpine/charts/mast2-0.1.0.tgz | Bin 0 -> 252 bytes .../charts/alpine/templates/alpine-pod.yaml | 14 ++++++ .../charts/alpine/values.yaml | 2 + .../charts/mariner-4.3.2.tgz | Bin 0 -> 967 bytes .../frobnitz_with_symlink/docs/README.md | 1 + .../testdata/frobnitz_with_symlink/icon.svg | 8 ++++ .../frobnitz_with_symlink/ignore/me.txt | 0 .../templates/template.tpl | 1 + .../frobnitz_with_symlink/values.yaml | 6 +++ 44 files changed, 261 insertions(+) create mode 100644 pkg/chart/loader/testdata/LICENSE create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/.helmignore create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.lock create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/INSTALL.txt create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/LICENSE create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/README.md create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/docs/README.md create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/icon.svg create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/ignore/me.txt create mode 120000 pkg/chart/loader/testdata/frobnitz_with_dev_null/null create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/templates/template.tpl create mode 100644 pkg/chart/loader/testdata/frobnitz_with_dev_null/values.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/.helmignore create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.lock create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/INSTALL.txt create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/README.md create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/_ignore_me create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/docs/README.md create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/icon.svg create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/ignore/me.txt create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/templates/template.tpl create mode 100644 pkg/chart/loader/testdata/frobnitz_with_symlink/values.yaml diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index 4c5bc0950..752526fe9 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -21,6 +21,7 @@ limitations under the License. package sympath import ( + "log" "os" "path/filepath" "sort" @@ -70,6 +71,7 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { if err != nil { return errors.Wrapf(err, "error evaluating symlink %s", path) } + log.Printf("found symbolic link in path: %s resolves to %s", path, resolved) if info, err = os.Lstat(resolved); err != nil { return err } diff --git a/pkg/chart/loader/directory.go b/pkg/chart/loader/directory.go index bfb632405..a12c5158e 100644 --- a/pkg/chart/loader/directory.go +++ b/pkg/chart/loader/directory.go @@ -17,6 +17,7 @@ limitations under the License. package loader import ( + "fmt" "io/ioutil" "os" "path/filepath" @@ -91,6 +92,13 @@ func LoadDir(dir string) (*chart.Chart, error) { return nil } + // Irregular files include devices, sockets, and other uses of files that + // are not regular files. In Go they have a file mode type bit set. + // See https://golang.org/pkg/os/#FileMode for examples. + if !fi.Mode().IsRegular() { + return fmt.Errorf("cannot load irregular file %s as it has file mode type bits set", name) + } + data, err := ioutil.ReadFile(name) if err != nil { return errors.Wrapf(err, "error reading %s", n) diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index ea5a35560..96b4dc608 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "testing" "time" @@ -45,6 +46,45 @@ func TestLoadDir(t *testing.T) { verifyDependenciesLock(t, c) } +func TestLoadDirWithDevNull(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("test only works on unix systems with /dev/null present") + } + + l, err := Loader("testdata/frobnitz_with_dev_null") + if err != nil { + t.Fatalf("Failed to load testdata: %s", err) + } + if _, err := l.Load(); err == nil { + t.Errorf("packages with an irregular file (/dev/null) should not load") + } +} + +func TestLoadDirWithSymlink(t *testing.T) { + sym := filepath.Join("..", "LICENSE") + link := filepath.Join("testdata", "frobnitz_with_symlink", "LICENSE") + + if err := os.Symlink(sym, link); err != nil { + t.Fatal(err) + } + + defer os.Remove(link) + + l, err := Loader("testdata/frobnitz_with_symlink") + if err != nil { + t.Fatalf("Failed to load testdata: %s", err) + } + + c, err := l.Load() + if err != nil { + t.Fatalf("Failed to load testdata: %s", err) + } + verifyFrobnitz(t, c) + verifyChart(t, c) + verifyDependencies(t, c) + verifyDependenciesLock(t, c) +} + func TestLoadV1(t *testing.T) { l, err := Loader("testdata/frobnitz.v1") if err != nil { diff --git a/pkg/chart/loader/testdata/LICENSE b/pkg/chart/loader/testdata/LICENSE new file mode 100644 index 000000000..6121943b1 --- /dev/null +++ b/pkg/chart/loader/testdata/LICENSE @@ -0,0 +1 @@ +LICENSE placeholder. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/.helmignore b/pkg/chart/loader/testdata/frobnitz_with_dev_null/.helmignore new file mode 100644 index 000000000..9973a57b8 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/.helmignore @@ -0,0 +1 @@ +ignore/ diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.lock b/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.lock new file mode 100644 index 000000000..6fcc2ed9f --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.lock @@ -0,0 +1,8 @@ +dependencies: + - name: alpine + version: "0.1.0" + repository: https://example.com/charts + - name: mariner + version: "4.3.2" + repository: https://example.com/charts +digest: invalid diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.yaml new file mode 100644 index 000000000..fcd4a4a37 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +name: frobnitz +description: This is a frobnitz. +version: "1.2.3" +keywords: + - frobnitz + - sprocket + - dodad +maintainers: + - name: The Helm Team + email: helm@example.com + - name: Someone Else + email: nobody@example.com +sources: + - https://example.com/foo/bar +home: http://example.com +icon: https://example.com/64x64.png +annotations: + extrakey: extravalue + anotherkey: anothervalue +dependencies: + - name: alpine + version: "0.1.0" + repository: https://example.com/charts + - name: mariner + version: "4.3.2" + repository: https://example.com/charts diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/INSTALL.txt b/pkg/chart/loader/testdata/frobnitz_with_dev_null/INSTALL.txt new file mode 100644 index 000000000..2010438c2 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/INSTALL.txt @@ -0,0 +1 @@ +This is an install document. The client may display this. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/LICENSE b/pkg/chart/loader/testdata/frobnitz_with_dev_null/LICENSE new file mode 100644 index 000000000..6121943b1 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/LICENSE @@ -0,0 +1 @@ +LICENSE placeholder. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/README.md b/pkg/chart/loader/testdata/frobnitz_with_dev_null/README.md new file mode 100644 index 000000000..8cf4cc3d7 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/README.md @@ -0,0 +1,11 @@ +# Frobnitz + +This is an example chart. + +## Usage + +This is an example. It has no usage. + +## Development + +For developer info, see the top-level repository. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me new file mode 100644 index 000000000..2cecca682 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/_ignore_me @@ -0,0 +1 @@ +This should be ignored by the loader, but may be included in a chart. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml new file mode 100644 index 000000000..79e0d65db --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +name: alpine +description: Deploy a basic Alpine Linux pod +version: 0.1.0 +home: https://helm.sh/helm diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md new file mode 100644 index 000000000..b30b949dd --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/README.md @@ -0,0 +1,9 @@ +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.toml` file contains the default values for the +`alpine-pod.yaml` template. + +You can install this example using `helm install ./alpine`. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml new file mode 100644 index 000000000..1c9dd5fa4 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +name: mast1 +description: A Helm chart for Kubernetes +version: 0.1.0 +home: "" diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml new file mode 100644 index 000000000..42c39c262 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast1/values.yaml @@ -0,0 +1,4 @@ +# Default values for mast1. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name = "value" diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/charts/mast2-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..61cb62051110b55f3d08213dc81dcf0b1c2d8e53 GIT binary patch literal 252 zcmVDc zVQyr3R8em|NM&qo0PNJUs=_c72H?(liabH@pWIst-7YSIyL+rhEHrIN(t?QZE=F{y zgNRfS&$pa5Ly`mMk2OB%pV`*9knW7FlL-Joo@KED7*{C$d;N~z z37$S{+}wvSU9}|VtF|fRpv9Ve>8dWo|9?5B+RE}Y9CFh-x#(Bq8Vck^V=NUiPLCKa z8z5CF#JgK!4>;$4Fm+FUst4d+{(+nP|0&J+e}(;l^U4@w-{=?s0RR8vgVbLD3;+OM Cs&R<` literal 0 HcmV?d00001 diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml new file mode 100644 index 000000000..21ae20aad --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/templates/alpine-pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{.Release.Name}}-{{.Chart.Name}} + labels: + app.kubernetes.io/managed-by: {{.Release.Service}} + app.kubernetes.io/name: {{.Chart.Name}} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" +spec: + restartPolicy: {{default "Never" .restart_policy}} + containers: + - name: waiter + image: "alpine:3.9" + command: ["/bin/sleep","9000"] diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml new file mode 100644 index 000000000..6c2aab7ba --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/alpine/values.yaml @@ -0,0 +1,2 @@ +# The pod name +name: "my-alpine" diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz b/pkg/chart/loader/testdata/frobnitz_with_dev_null/charts/mariner-4.3.2.tgz new file mode 100644 index 0000000000000000000000000000000000000000..3190136b050e62c628b3c817fd963ac9dc4a9e25 GIT binary patch literal 967 zcmV;&133I2iwFR+9h6)E1MQb_y%a`Bd>#= zhbqf2w!b6}wZ9@rvIhtwzm?~C&+QLm+G2!l%`$_aUgS(@pdjdX3a%E}VXVc7`)dg( zL%IRN2}c1D3xoMi2w@WuWOMZ?5i&3FelBVyq_Ce_8fREdP%NDf<&d!wu3{&VUQNs{N%vK$Ha~k^gB2!0bO7r0ic0 zbqCp*X#j?=|H@GNONsuE)&Idbh>2MX(Z}|+=@*sLod*wS?A8Ugp#mMPuMO0NnZmos9_rr z3xpDL+otj~lRh?B4hHFTl+d5-8NBXmUXB~EyF^bx7m*+!*g>obczvGF|8xkWsHN8; z%#+wiWP{=2pC*98@$VNzzsll&G#D7&11-;D>HT0x|DV2?6}a~*p46@R|2l??e_8dX z@Bb>D3t~VC_*wjq2Dy!6J-_5ME%%J+xmsbK5a#qO>ZV?Wt`d|TDdrB^B&LqFr@lYdUA zs&4-JAg3&uc4dA0gv*bXU9QePa9^8wR{HovA)j@)JOAIkak0Jl)aKqA_3XLM#?H=V z-{tlG=xy^os=1Z><53;&+C4=zp|%rwv!)UyY=%k_t%Y|wNRQl`C6N_Z&S;S+~wb1=)2Uh_4I81`y>DO zoLPSt=btB&x{CUK`0DA&){efW_O36RxnsYZNT0r;JbTLR{H4M3C$8(Cee==aQ~Gbq p$`5v3?NB{4-j0XQHf literal 0 HcmV?d00001 diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/docs/README.md b/pkg/chart/loader/testdata/frobnitz_with_dev_null/docs/README.md new file mode 100644 index 000000000..d40747caf --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/docs/README.md @@ -0,0 +1 @@ +This is a placeholder for documentation. diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/icon.svg b/pkg/chart/loader/testdata/frobnitz_with_dev_null/icon.svg new file mode 100644 index 000000000..892130606 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/icon.svg @@ -0,0 +1,8 @@ + + + Example icon + + + diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/ignore/me.txt b/pkg/chart/loader/testdata/frobnitz_with_dev_null/ignore/me.txt new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/null b/pkg/chart/loader/testdata/frobnitz_with_dev_null/null new file mode 120000 index 000000000..dc1dc0cde --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/null @@ -0,0 +1 @@ +/dev/null \ No newline at end of file diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/templates/template.tpl b/pkg/chart/loader/testdata/frobnitz_with_dev_null/templates/template.tpl new file mode 100644 index 000000000..c651ee6a0 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/templates/template.tpl @@ -0,0 +1 @@ +Hello {{.Name | default "world"}} diff --git a/pkg/chart/loader/testdata/frobnitz_with_dev_null/values.yaml b/pkg/chart/loader/testdata/frobnitz_with_dev_null/values.yaml new file mode 100644 index 000000000..61f501258 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_dev_null/values.yaml @@ -0,0 +1,6 @@ +# A values file contains configuration. + +name: "Some Name" + +section: + name: "Name in a section" diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/.helmignore b/pkg/chart/loader/testdata/frobnitz_with_symlink/.helmignore new file mode 100644 index 000000000..9973a57b8 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/.helmignore @@ -0,0 +1 @@ +ignore/ diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.lock b/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.lock new file mode 100644 index 000000000..6fcc2ed9f --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.lock @@ -0,0 +1,8 @@ +dependencies: + - name: alpine + version: "0.1.0" + repository: https://example.com/charts + - name: mariner + version: "4.3.2" + repository: https://example.com/charts +digest: invalid diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.yaml new file mode 100644 index 000000000..fcd4a4a37 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +name: frobnitz +description: This is a frobnitz. +version: "1.2.3" +keywords: + - frobnitz + - sprocket + - dodad +maintainers: + - name: The Helm Team + email: helm@example.com + - name: Someone Else + email: nobody@example.com +sources: + - https://example.com/foo/bar +home: http://example.com +icon: https://example.com/64x64.png +annotations: + extrakey: extravalue + anotherkey: anothervalue +dependencies: + - name: alpine + version: "0.1.0" + repository: https://example.com/charts + - name: mariner + version: "4.3.2" + repository: https://example.com/charts diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/INSTALL.txt b/pkg/chart/loader/testdata/frobnitz_with_symlink/INSTALL.txt new file mode 100644 index 000000000..2010438c2 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/INSTALL.txt @@ -0,0 +1 @@ +This is an install document. The client may display this. diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/README.md b/pkg/chart/loader/testdata/frobnitz_with_symlink/README.md new file mode 100644 index 000000000..8cf4cc3d7 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/README.md @@ -0,0 +1,11 @@ +# Frobnitz + +This is an example chart. + +## Usage + +This is an example. It has no usage. + +## Development + +For developer info, see the top-level repository. diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/_ignore_me b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/_ignore_me new file mode 100644 index 000000000..2cecca682 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/_ignore_me @@ -0,0 +1 @@ +This should be ignored by the loader, but may be included in a chart. diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml new file mode 100644 index 000000000..79e0d65db --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +name: alpine +description: Deploy a basic Alpine Linux pod +version: 0.1.0 +home: https://helm.sh/helm diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md new file mode 100644 index 000000000..b30b949dd --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/README.md @@ -0,0 +1,9 @@ +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.toml` file contains the default values for the +`alpine-pod.yaml` template. + +You can install this example using `helm install ./alpine`. diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml new file mode 100644 index 000000000..1c9dd5fa4 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +name: mast1 +description: A Helm chart for Kubernetes +version: 0.1.0 +home: "" diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml new file mode 100644 index 000000000..42c39c262 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast1/values.yaml @@ -0,0 +1,4 @@ +# Default values for mast1. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name = "value" diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/charts/mast2-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..61cb62051110b55f3d08213dc81dcf0b1c2d8e53 GIT binary patch literal 252 zcmVDc zVQyr3R8em|NM&qo0PNJUs=_c72H?(liabH@pWIst-7YSIyL+rhEHrIN(t?QZE=F{y zgNRfS&$pa5Ly`mMk2OB%pV`*9knW7FlL-Joo@KED7*{C$d;N~z z37$S{+}wvSU9}|VtF|fRpv9Ve>8dWo|9?5B+RE}Y9CFh-x#(Bq8Vck^V=NUiPLCKa z8z5CF#JgK!4>;$4Fm+FUst4d+{(+nP|0&J+e}(;l^U4@w-{=?s0RR8vgVbLD3;+OM Cs&R<` literal 0 HcmV?d00001 diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml new file mode 100644 index 000000000..21ae20aad --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/templates/alpine-pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{.Release.Name}}-{{.Chart.Name}} + labels: + app.kubernetes.io/managed-by: {{.Release.Service}} + app.kubernetes.io/name: {{.Chart.Name}} + helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" +spec: + restartPolicy: {{default "Never" .restart_policy}} + containers: + - name: waiter + image: "alpine:3.9" + command: ["/bin/sleep","9000"] diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml new file mode 100644 index 000000000..6c2aab7ba --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/alpine/values.yaml @@ -0,0 +1,2 @@ +# The pod name +name: "my-alpine" diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz b/pkg/chart/loader/testdata/frobnitz_with_symlink/charts/mariner-4.3.2.tgz new file mode 100644 index 0000000000000000000000000000000000000000..3190136b050e62c628b3c817fd963ac9dc4a9e25 GIT binary patch literal 967 zcmV;&133I2iwFR+9h6)E1MQb_y%a`Bd>#= zhbqf2w!b6}wZ9@rvIhtwzm?~C&+QLm+G2!l%`$_aUgS(@pdjdX3a%E}VXVc7`)dg( zL%IRN2}c1D3xoMi2w@WuWOMZ?5i&3FelBVyq_Ce_8fREdP%NDf<&d!wu3{&VUQNs{N%vK$Ha~k^gB2!0bO7r0ic0 zbqCp*X#j?=|H@GNONsuE)&Idbh>2MX(Z}|+=@*sLod*wS?A8Ugp#mMPuMO0NnZmos9_rr z3xpDL+otj~lRh?B4hHFTl+d5-8NBXmUXB~EyF^bx7m*+!*g>obczvGF|8xkWsHN8; z%#+wiWP{=2pC*98@$VNzzsll&G#D7&11-;D>HT0x|DV2?6}a~*p46@R|2l??e_8dX z@Bb>D3t~VC_*wjq2Dy!6J-_5ME%%J+xmsbK5a#qO>ZV?Wt`d|TDdrB^B&LqFr@lYdUA zs&4-JAg3&uc4dA0gv*bXU9QePa9^8wR{HovA)j@)JOAIkak0Jl)aKqA_3XLM#?H=V z-{tlG=xy^os=1Z><53;&+C4=zp|%rwv!)UyY=%k_t%Y|wNRQl`C6N_Z&S;S+~wb1=)2Uh_4I81`y>DO zoLPSt=btB&x{CUK`0DA&){efW_O36RxnsYZNT0r;JbTLR{H4M3C$8(Cee==aQ~Gbq p$`5v3?NB{4-j0XQHf literal 0 HcmV?d00001 diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/docs/README.md b/pkg/chart/loader/testdata/frobnitz_with_symlink/docs/README.md new file mode 100644 index 000000000..d40747caf --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/docs/README.md @@ -0,0 +1 @@ +This is a placeholder for documentation. diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/icon.svg b/pkg/chart/loader/testdata/frobnitz_with_symlink/icon.svg new file mode 100644 index 000000000..892130606 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/icon.svg @@ -0,0 +1,8 @@ + + + Example icon + + + diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/ignore/me.txt b/pkg/chart/loader/testdata/frobnitz_with_symlink/ignore/me.txt new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/templates/template.tpl b/pkg/chart/loader/testdata/frobnitz_with_symlink/templates/template.tpl new file mode 100644 index 000000000..c651ee6a0 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/templates/template.tpl @@ -0,0 +1 @@ +Hello {{.Name | default "world"}} diff --git a/pkg/chart/loader/testdata/frobnitz_with_symlink/values.yaml b/pkg/chart/loader/testdata/frobnitz_with_symlink/values.yaml new file mode 100644 index 000000000..61f501258 --- /dev/null +++ b/pkg/chart/loader/testdata/frobnitz_with_symlink/values.yaml @@ -0,0 +1,6 @@ +# A values file contains configuration. + +name: "Some Name" + +section: + name: "Name in a section" From 6a91263e38a5184fbe590869023cb61de028913a Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Tue, 29 Oct 2019 11:13:03 -0600 Subject: [PATCH 032/279] fix(releaseutil): Removes API version checks from kind sorter The sorting method for manifests contained a check to see if the API version existed. This violates separation of concerns as the sorter should just sort and leave validation to other parts of the code. Signed-off-by: Taylor Thomas --- pkg/releaseutil/manifest_sorter.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/releaseutil/manifest_sorter.go index 68ba1bf5e..5f4b4e8d9 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/releaseutil/manifest_sorter.go @@ -129,10 +129,6 @@ func (file *manifestFile) sort(result *result) error { return errors.Wrapf(err, "YAML parse error on %s", file.path) } - if entry.Version != "" && !file.apis.Has(entry.Version) { - return errors.Errorf("apiVersion %q in %s is not available", entry.Version, file.path) - } - if !hasAnyAnnotation(entry) { result.generic = append(result.generic, Manifest{ Name: file.path, From b6f5762d46a38641f05354e8ebc502b57790ffe1 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Tue, 29 Oct 2019 12:10:58 -0600 Subject: [PATCH 033/279] fix(chartutil): Add the v1 apiextensions to the default scheme Signed-off-by: Taylor Thomas --- pkg/chartutil/capabilities.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index 97e4cc945..f46350bb1 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -18,6 +18,7 @@ package chartutil import ( "k8s.io/client-go/kubernetes/scheme" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" ) @@ -75,9 +76,11 @@ func (v VersionSet) Has(apiVersion string) bool { } func allKnownVersions() VersionSet { - // Otherwise `helm template` fails validating due to an error like the below: - // Error: apiVersion "apiextensions.k8s.io/v1beta1" in mychart/templates/crd.yaml is not available + // We should register the built in extension APIs as well so CRDs are + // supported in the default version set. This has caused problems with `helm + // template` in the past, so let's be safe apiextensionsv1beta1.AddToScheme(scheme.Scheme) + apiextensionsv1.AddToScheme(scheme.Scheme) groups := scheme.Scheme.PrioritizedVersionsAllGroups() vs := make(VersionSet, 0, len(groups)) From afda6b49408bad8f7a7a5faa9eeda016c8763400 Mon Sep 17 00:00:00 2001 From: Lam Le Date: Tue, 29 Oct 2019 13:40:30 -0700 Subject: [PATCH 034/279] Porting fix from commit f5986db184cf6d16dcd48760ac749a20236fb845 This port fixes the bug #6820 for helm3 which was fixed in helm2 with the pull request 4850 https://github.com/helm/helm/pull/4850 Signed-off-by: Lam Le --- pkg/repo/index.go | 9 +++++++++ pkg/repo/index_test.go | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkg/repo/index.go b/pkg/repo/index.go index b3703304f..a7fea673b 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -169,6 +169,15 @@ func (i IndexFile) Get(name, version string) (*ChartVersion, error) { } } + // when customer input exact version, check whether have exact match one first + if len(version) != 0 { + for _, ver := range vs { + if version == ver.Version { + return ver, nil + } + } + } + for _, ver := range vs { test, err := semver.NewVersion(ver.Version) if err != nil { diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index d0596c219..bc0b45e2c 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -20,6 +20,7 @@ import ( "io/ioutil" "net/http" "os" + "strings" "testing" "helm.sh/helm/v3/pkg/cli" @@ -40,14 +41,17 @@ func TestIndexFile(t *testing.T) { i.Add(&chart.Metadata{Name: "cutter", Version: "0.1.1"}, "cutter-0.1.1.tgz", "http://example.com/charts", "sha256:1234567890abc") i.Add(&chart.Metadata{Name: "cutter", Version: "0.1.0"}, "cutter-0.1.0.tgz", "http://example.com/charts", "sha256:1234567890abc") i.Add(&chart.Metadata{Name: "cutter", Version: "0.2.0"}, "cutter-0.2.0.tgz", "http://example.com/charts", "sha256:1234567890abc") + i.Add(&chart.Metadata{Name: "setter", Version: "0.1.9+alpha"}, "setter-0.1.9+alpha.tgz", "http://example.com/charts", "sha256:1234567890abc") + i.Add(&chart.Metadata{Name: "setter", Version: "0.1.9+beta"}, "setter-0.1.9+beta.tgz", "http://example.com/charts", "sha256:1234567890abc") + i.SortEntries() if i.APIVersion != APIVersionV1 { t.Error("Expected API version v1") } - if len(i.Entries) != 2 { - t.Errorf("Expected 2 charts. Got %d", len(i.Entries)) + if len(i.Entries) != 3 { + t.Errorf("Expected 3 charts. Got %d", len(i.Entries)) } if i.Entries["clipper"][0].Name != "clipper" { @@ -55,13 +59,23 @@ func TestIndexFile(t *testing.T) { } if len(i.Entries["cutter"]) != 3 { - t.Error("Expected two cutters.") + t.Error("Expected three cutters.") } // Test that the sort worked. 0.2 should be at the first index for Cutter. if v := i.Entries["cutter"][0].Version; v != "0.2.0" { t.Errorf("Unexpected first version: %s", v) } + + cv, err := i.Get("setter", "0.1.9") + if err == nil && !strings.Contains(cv.Metadata.Version, "0.1.9") { + t.Errorf("Unexpected version: %s", cv.Metadata.Version) + } + + cv, err = i.Get("setter", "0.1.9+alpha") + if err != nil || cv.Metadata.Version != "0.1.9+alpha" { + t.Errorf("Expected version: 0.1.9+alpha") + } } func TestLoadIndex(t *testing.T) { From 1c64d8fb8164406e63bf91e263b11485d43a8324 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 29 Oct 2019 13:46:36 -0700 Subject: [PATCH 035/279] fix(version): lift "unreleased" status Signed-off-by: Matthew Fisher --- cmd/helm/testdata/output/version-short.txt | 2 +- cmd/helm/testdata/output/version-template.txt | 2 +- cmd/helm/testdata/output/version.txt | 2 +- internal/version/version.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/helm/testdata/output/version-short.txt b/cmd/helm/testdata/output/version-short.txt index 5e7749489..d9fb9c736 100644 --- a/cmd/helm/testdata/output/version-short.txt +++ b/cmd/helm/testdata/output/version-short.txt @@ -1 +1 @@ -v3.0+unreleased +v3.0 diff --git a/cmd/helm/testdata/output/version-template.txt b/cmd/helm/testdata/output/version-template.txt index c12e29c2d..776c1919b 100644 --- a/cmd/helm/testdata/output/version-template.txt +++ b/cmd/helm/testdata/output/version-template.txt @@ -1 +1 @@ -Version: v3.0+unreleased \ No newline at end of file +Version: v3.0 \ No newline at end of file diff --git a/cmd/helm/testdata/output/version.txt b/cmd/helm/testdata/output/version.txt index 0d9b536e6..4b493d31c 100644 --- a/cmd/helm/testdata/output/version.txt +++ b/cmd/helm/testdata/output/version.txt @@ -1 +1 @@ -version.BuildInfo{Version:"v3.0+unreleased", GitCommit:"", GitTreeState:"", GoVersion:""} +version.BuildInfo{Version:"v3.0", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/internal/version/version.go b/internal/version/version.go index 131a2b130..22439d11b 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -33,7 +33,7 @@ var ( version = "v3.0" // metadata is extra build time data - metadata = "unreleased" + metadata = "" // gitCommit is the git sha1 gitCommit = "" // gitTreeState is the state of the git tree From 1e58f484ff590d9f06e131226787eb55fb8f2d1f Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 29 Oct 2019 17:23:04 -0400 Subject: [PATCH 036/279] fix(comp): helm plugin 'remove' is now 'uninstall' Signed-off-by: Marc Khouzam --- cmd/helm/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 54b4ef59a..fac0dc062 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -286,7 +286,7 @@ __helm_custom_func() __helm_list_repos return ;; - helm_plugin_remove | helm_plugin_update) + helm_plugin_uninstall | helm_plugin_update) __helm_list_plugins return ;; From 065dfb0e5b45f782e060a91118bc2f7fcd8c5d70 Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Wed, 30 Oct 2019 10:22:39 +0100 Subject: [PATCH 037/279] [Makefile] Support reproducible builds Circleci is used to build the release artifacts and embeds build paths into the binary release. To reproduce the release binaries we then need to also build in the same path as a result. $ strings linux-amd64/helm | grep "home/circleci" | wc -l 174 Go 1.13 introduces `-trimpath` which strips the build path from all compiled binaries. This should enable people to reproduce the distributed helm binaries. https://reproducible-builds.org/docs/source-date-epoch/ https://golang.org/doc/go1.13#go-command Signed-off-by: Morten Linderud --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b52464ba9..4322139c5 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ TAGS := TESTS := . TESTFLAGS := LDFLAGS := -w -s -GOFLAGS := +GOFLAGS := -trimpath SRC := $(shell find . -type f -name '*.go' -print) # Required for globs to work correctly From 73db724c6c920b2503ad9bea2489cd60b9cfa952 Mon Sep 17 00:00:00 2001 From: Kamalashree Nagaraj Date: Wed, 30 Oct 2019 22:03:26 +0530 Subject: [PATCH 038/279] feat(helm): add linting support for '.tar.gz' tarballs for helm charts (#6829) When 'helm3 lint .tar.gz' is run, this will lint Chart.yaml in the package Closes #6535 Signed-off-by: Kamalashree N --- .../testcharts/compressedchart-0.1.0.tar.gz | Bin 0 -> 477 bytes pkg/action/lint.go | 2 +- pkg/action/lint_test.go | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz diff --git a/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz b/cmd/helm/testdata/testcharts/compressedchart-0.1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..3c9c24d76063d6a904405b2d6a7a84cb087f1ce4 GIT binary patch literal 477 zcmV<30V4h%iwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PL4vi_<_5!26s}F{UjHhD>x0Xejw~|-egB1QU=&JEdrHEIt>CEtv%dd}n=<=92zSKn;o(8OM@#S> zYFc5(0#_R!xxRXQ%zfa$rtiOMiLGgzk94**j`?3M7Jt0|r`i8O7{f;tq39Bbhr@%1 zO-l}zo#EQJ1_D-Jv7w}jF??!Gg4BiJqa;WzF+; Date: Wed, 30 Oct 2019 12:25:35 -0700 Subject: [PATCH 039/279] fix(kube): return error when object cannot be patched Signed-off-by: Matthew Fisher --- pkg/kube/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 06df8490e..2a5661306 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -401,7 +401,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, // send patch to server obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch, nil) if err != nil { - log.Printf("Cannot patch %s: %q (%v)", kind, target.Name, err) + return errors.Wrapf(err, "cannot patch %q with kind %s", target.Name, kind) } } From 2e1c54855eaf823124e3d4e9e95e6d61b80cfcb4 Mon Sep 17 00:00:00 2001 From: Jeff Bachtel Date: Wed, 30 Oct 2019 14:25:34 -0600 Subject: [PATCH 040/279] Add namespace option to example kubectl command Signed-off-by: Jeff Bachtel --- pkg/chartutil/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 6f0b38c05..c67cde04f 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -324,7 +324,7 @@ const defaultNotes = `1. Get the application URL by running these commands: {{- else if contains "ClusterIP" .Values.service.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include ".name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 {{- end }} ` From 9ecbc4d001c7e89ca26b6b56b0e961ca977a2331 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Wed, 30 Oct 2019 15:25:54 -0600 Subject: [PATCH 041/279] Revert "[Makefile] Support reproducible builds" Signed-off-by: Taylor Thomas --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4322139c5..b52464ba9 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ TAGS := TESTS := . TESTFLAGS := LDFLAGS := -w -s -GOFLAGS := -trimpath +GOFLAGS := SRC := $(shell find . -type f -name '*.go' -print) # Required for globs to work correctly From bf012282c846a1173f4ddc987756c2aa4dda9172 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 30 Oct 2019 13:09:43 -0700 Subject: [PATCH 042/279] fix(action): strip file extensions from name Signed-off-by: Matthew Fisher --- pkg/action/install.go | 4 ++ pkg/action/install_test.go | 97 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/pkg/action/install.go b/pkg/action/install.go index 606226500..8f1b5528b 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -564,6 +564,10 @@ func (i *Install) NameAndChart(args []string) (string, string, error) { if base == "." || base == "" { base = "chart" } + // if present, strip out the file extension from the name + if idx := strings.Index(base, "."); idx != -1 { + base = base[0:idx] + } return fmt.Sprintf("%s-%d", base, time.Now().Unix()), args[0], nil } diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 406574995..bb36b843d 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -33,6 +33,7 @@ import ( kubefake "helm.sh/helm/v3/pkg/kube/fake" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v3/pkg/time" ) type nameTemplateTestCase struct { @@ -469,3 +470,99 @@ func TestInstallReleaseOutputDir(t *testing.T) { _, err = os.Stat(filepath.Join(dir, "hello/templates/empty")) is.True(os.IsNotExist(err)) } + +func TestNameAndChart(t *testing.T) { + is := assert.New(t) + instAction := installAction(t) + chartName := "./foo" + + name, chrt, err := instAction.NameAndChart([]string{chartName}) + if err != nil { + t.Fatal(err) + } + is.Equal(instAction.ReleaseName, name) + is.Equal(chartName, chrt) + + instAction.GenerateName = true + _, _, err = instAction.NameAndChart([]string{"foo", chartName}) + if err == nil { + t.Fatal("expected an error") + } + is.Equal("cannot set --generate-name and also specify a name", err.Error()) + + instAction.GenerateName = false + instAction.NameTemplate = "{{ . }}" + _, _, err = instAction.NameAndChart([]string{"foo", chartName}) + if err == nil { + t.Fatal("expected an error") + } + is.Equal("cannot set --name-template and also specify a name", err.Error()) + + instAction.NameTemplate = "" + instAction.ReleaseName = "" + _, _, err = instAction.NameAndChart([]string{chartName}) + if err == nil { + t.Fatal("expected an error") + } + is.Equal("must either provide a name or specify --generate-name", err.Error()) +} + +func TestNameAndChartGenerateName(t *testing.T) { + is := assert.New(t) + instAction := installAction(t) + + instAction.ReleaseName = "" + instAction.GenerateName = true + + tests := []struct { + Name string + Chart string + ExpectedName string + }{ + { + "local filepath", + "./chart", + fmt.Sprintf("chart-%d", time.Now().Unix()), + }, + { + "dot filepath", + ".", + fmt.Sprintf("chart-%d", time.Now().Unix()), + }, + { + "empty filepath", + "", + fmt.Sprintf("chart-%d", time.Now().Unix()), + }, + { + "packaged chart", + "chart.tgz", + fmt.Sprintf("chart-%d", time.Now().Unix()), + }, + { + "packaged chart with .tar.gz extension", + "chart.tar.gz", + fmt.Sprintf("chart-%d", time.Now().Unix()), + }, + { + "packaged chart with local extension", + "./chart.tgz", + fmt.Sprintf("chart-%d", time.Now().Unix()), + }, + } + + for _, tc := range tests { + tc := tc + t.Run(tc.Name, func(t *testing.T) { + t.Parallel() + + name, chrt, err := instAction.NameAndChart([]string{tc.Chart}) + if err != nil { + t.Fatal(err) + } + + is.Equal(tc.ExpectedName, name) + is.Equal(tc.Chart, chrt) + }) + } +} From 0275c6b838a7d5b9e12f9b49c6a5c4411268d754 Mon Sep 17 00:00:00 2001 From: Rimas Mocevicius Date: Thu, 31 Oct 2019 15:13:01 +0200 Subject: [PATCH 043/279] feat(v3): Add shorthand for --all-namespace flag in list command (#6848) * feat(v3): add an extra short flag for Signed-off-by: rimas * change flag to Signed-off-by: rimas --- cmd/helm/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index a3003e219..7e04e64a9 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -100,7 +100,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") f.BoolVar(&client.Failed, "failed", false, "show failed releases") f.BoolVar(&client.Pending, "pending", false, "show pending releases") - f.BoolVar(&client.AllNamespaces, "all-namespaces", false, "list releases across all namespaces") + f.BoolVarP(&client.AllNamespaces, "all-namespaces", "A", false, "list releases across all namespaces") f.IntVarP(&client.Limit, "max", "m", 256, "maximum number of releases to fetch") f.IntVar(&client.Offset, "offset", 0, "next release name in the list, used to offset from start value") f.StringVarP(&client.Filter, "filter", "f", "", "a regular expression (Perl compatible). Any releases that match the expression will be included in the results") From de438b5e6838bf385c2a6cb3fb8fc66441f785d8 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 30 Oct 2019 13:36:20 -0400 Subject: [PATCH 044/279] Updating the usage language for search repo Signed-off-by: Matt Farina --- cmd/helm/search_repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index 1bc279050..68d0135c7 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -50,7 +50,7 @@ Examples: # Search for release versions matching the keyword "nginx", including pre-release versions $ helm search repo nginx --devel - # Search for the latest patch release for nginx-ingress 1.x + # Search for the latest stable release for nginx-ingress with a major version of 1 $ helm search repo nginx-ingress --version ^1.0.0 Repositories are managed with 'helm repo' commands. From 432fd9c110bf75de46cfc8db4748ad0a0fdc28fd Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Thu, 31 Oct 2019 09:26:22 -0600 Subject: [PATCH 045/279] fix(cmd): Updates description for template validation flag This is a follow up to discussion in #6663 that clarifies exactly what the validate flag is doing. It isn't meant to be a generic schema validator, but rather validates the manifests against the current cluster as if it was going to be installing them. Signed-off-by: Taylor Thomas --- cmd/helm/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 1c6d88ee8..5312d798f 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -119,7 +119,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { addInstallFlags(f, client, valueOpts) f.StringArrayVarP(&showFiles, "show-only", "s", []string{}, "only show manifests rendered from the given templates") f.StringVar(&client.OutputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") - f.BoolVar(&validate, "validate", false, "establish a connection to Kubernetes for schema validation") + f.BoolVar(&validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. This is the same validation performed on an install") f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") return cmd From f16d3e295ca2dee5aeab0bd36c09400e74dd3f4d Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 31 Oct 2019 13:56:48 -0400 Subject: [PATCH 046/279] fix(comp): Protect against user's aliases If a user has aliases commands that we use in the completion script such as grep, cut, tail, it may cause the script to misbehave. By escaping the commands, we tell the shell not to use any aliases. Signed-off-by: Marc Khouzam --- cmd/helm/root.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index fac0dc062..80a443972 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -64,12 +64,12 @@ __helm_override_flags_to_kubectl_flags() # --kubeconfig, -n, --namespace stay the same for kubectl # --kube-context becomes --context for kubectl __helm_debug "${FUNCNAME[0]}: flags to convert: $1" - echo "$1" | sed s/kube-context/context/ + echo "$1" | \sed s/kube-context/context/ } __helm_get_repos() { - eval $(__helm_binary_name) repo list 2>/dev/null | tail +2 | cut -f1 + eval $(__helm_binary_name) repo list 2>/dev/null | \tail +2 | \cut -f1 } __helm_get_contexts() @@ -125,7 +125,7 @@ __helm_zsh_comp_nospace() { # We only do this if there is a single choice left for completion # to reduce the times the user could be presented with the fake completion choice. - out=($(echo ${in[*]} | tr " " "\n" | \grep "^${cur}")) + out=($(echo ${in[*]} | \tr " " "\n" | \grep "^${cur}")) __helm_debug "${FUNCNAME[0]}: out is ${out[*]}" [ ${#out[*]} -eq 1 ] && out+=("${out}.") @@ -145,7 +145,7 @@ __helm_list_charts() for repo in $(__helm_get_repos); do if [[ "${cur}" =~ ^${repo}/.* ]]; then # We are doing completion from within a repo - out=$(eval $(__helm_binary_name) search repo ${cur} 2>/dev/null | cut -f1 | \grep ^${cur}) + out=$(eval $(__helm_binary_name) search repo ${cur} 2>/dev/null | \cut -f1 | \grep ^${cur}) nospace=0 elif [[ ${repo} =~ ^${cur}.* ]]; then # We are completing a repo name @@ -236,7 +236,7 @@ __helm_list_plugins() __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" local out # Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3) - if out=$(eval $(__helm_binary_name) plugin list 2>/dev/null | tail +2 | cut -f1); then + if out=$(eval $(__helm_binary_name) plugin list 2>/dev/null | \tail +2 | \cut -f1); then COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) fi } From 668f51bfdf8171bfaf8d369752ff938ed630d655 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 1 Nov 2019 14:44:26 -0700 Subject: [PATCH 047/279] fix(chart): add JSON tags to chart object Go capitalizes field names by default. Signed-off-by: Matthew Fisher --- pkg/chart/chart.go | 12 ++++++------ pkg/chart/file.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index f36cf8236..2b667d456 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -27,18 +27,18 @@ const APIVersionV2 = "v2" // optionally parameterizable templates, and zero or more charts (dependencies). type Chart struct { // Metadata is the contents of the Chartfile. - Metadata *Metadata + Metadata *Metadata `json:"metadata"` // LocK is the contents of Chart.lock. - Lock *Lock + Lock *Lock `json:"lock"` // Templates for this chart. - Templates []*File + Templates []*File `json:"templates"` // Values are default config for this template. - Values map[string]interface{} + Values map[string]interface{} `json:"values"` // Schema is an optional JSON schema for imposing structure on Values - Schema []byte + Schema []byte `json:"schema"` // Files are miscellaneous files in a chart archive, // e.g. README, LICENSE, etc. - Files []*File + Files []*File `json:"files"` parent *Chart dependencies []*Chart diff --git a/pkg/chart/file.go b/pkg/chart/file.go index 45f64efe8..9dd7c08d5 100644 --- a/pkg/chart/file.go +++ b/pkg/chart/file.go @@ -21,7 +21,7 @@ package chart // base directory. type File struct { // Name is the path-like name of the template. - Name string + Name string `json:"name"` // Data is the template as byte data. - Data []byte + Data []byte `json:"data"` } From c9b127c3ee2fd6832c02c645600fc0caff7827c2 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 31 Oct 2019 12:05:41 -0700 Subject: [PATCH 048/279] fix(getter): set up TLS options during .Get() Signed-off-by: Matthew Fisher --- internal/tlsutil/tlsutil_test.go | 2 +- pkg/getter/httpgetter.go | 33 ++++--- pkg/getter/httpgetter_test.go | 86 +++++++++++----- .../testdata/output/httpgetter-servername.txt | 1 - testdata/ca.pem | 35 ------- testdata/crt.pem | 98 ++++++++++++++----- testdata/generate.sh | 4 + testdata/key.pem | 74 +++++--------- testdata/openssl.conf | 42 ++++++++ testdata/rootca.crt | 19 ++++ testdata/rootca.key | 27 +++++ 11 files changed, 268 insertions(+), 153 deletions(-) delete mode 100644 pkg/getter/testdata/output/httpgetter-servername.txt delete mode 100644 testdata/ca.pem create mode 100755 testdata/generate.sh create mode 100644 testdata/openssl.conf create mode 100644 testdata/rootca.crt create mode 100644 testdata/rootca.key diff --git a/internal/tlsutil/tlsutil_test.go b/internal/tlsutil/tlsutil_test.go index a4b3c9c22..c2a477272 100644 --- a/internal/tlsutil/tlsutil_test.go +++ b/internal/tlsutil/tlsutil_test.go @@ -25,7 +25,7 @@ import ( const tlsTestDir = "../../testdata" const ( - testCaCertFile = "ca.pem" + testCaCertFile = "rootca.crt" testCertFile = "crt.pem" testKeyFile = "key.pem" ) diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index 320013541..a36ab0321 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -29,8 +29,7 @@ import ( // HTTPGetter is the efault HTTP(/S) backend handler type HTTPGetter struct { - client *http.Client - opts options + opts options } //Get performs a Get from repo.Getter and returns the body. @@ -60,7 +59,12 @@ func (g *HTTPGetter) get(href string) (*bytes.Buffer, error) { req.SetBasicAuth(g.opts.username, g.opts.password) } - resp, err := g.client.Do(req) + client, err := g.httpClient() + if err != nil { + return nil, err + } + + resp, err := client.Do(req) if err != nil { return buf, err } @@ -81,28 +85,31 @@ func NewHTTPGetter(options ...Option) (Getter, error) { opt(&client.opts) } - if client.opts.certFile != "" && client.opts.keyFile != "" { - tlsConf, err := tlsutil.NewClientTLS(client.opts.certFile, client.opts.keyFile, client.opts.caFile) + return &client, nil +} + +func (g *HTTPGetter) httpClient() (*http.Client, error) { + if g.opts.certFile != "" && g.opts.keyFile != "" { + tlsConf, err := tlsutil.NewClientTLS(g.opts.certFile, g.opts.keyFile, g.opts.caFile) if err != nil { - return &client, errors.Wrap(err, "can't create TLS config for client") + return nil, errors.Wrap(err, "can't create TLS config for client") } tlsConf.BuildNameToCertificate() - sni, err := urlutil.ExtractHostname(client.opts.url) + sni, err := urlutil.ExtractHostname(g.opts.url) if err != nil { - return &client, err + return nil, err } tlsConf.ServerName = sni - client.client = &http.Client{ + client := &http.Client{ Transport: &http.Transport{ TLSClientConfig: tlsConf, Proxy: http.ProxyFromEnvironment, }, } - } else { - client.client = http.DefaultClient - } - return &client, nil + return client, nil + } + return http.DefaultClient, nil } diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 93bfd96b1..0c2c55ea3 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -24,7 +24,9 @@ import ( "strings" "testing" - "helm.sh/helm/v3/internal/test" + "github.com/pkg/errors" + + "helm.sh/helm/v3/internal/tlsutil" "helm.sh/helm/v3/internal/version" "helm.sh/helm/v3/pkg/cli" ) @@ -35,46 +37,25 @@ func TestHTTPGetter(t *testing.T) { t.Fatal(err) } - if hg, ok := g.(*HTTPGetter); !ok { + if _, ok := g.(*HTTPGetter); !ok { t.Fatal("Expected NewHTTPGetter to produce an *HTTPGetter") - } else if hg.client != http.DefaultClient { - t.Fatal("Expected NewHTTPGetter to return a default HTTP client.") } - // Test with SSL: cd := "../../testdata" join := filepath.Join - ca, pub, priv := join(cd, "ca.pem"), join(cd, "crt.pem"), join(cd, "key.pem") - g, err = NewHTTPGetter( - WithURL("http://example.com"), - WithTLSClientConfig(pub, priv, ca), - ) - if err != nil { - t.Fatal(err) - } - - hg, ok := g.(*HTTPGetter) - if !ok { - t.Fatal("Expected NewHTTPGetter to produce an *HTTPGetter") - } + ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem") - transport, ok := hg.client.Transport.(*http.Transport) - if !ok { - t.Errorf("Expected NewHTTPGetter to set up an HTTP transport") - } - - test.AssertGoldenString(t, transport.TLSClientConfig.ServerName, "output/httpgetter-servername.txt") - - // Test other options + // Test with options g, err = NewHTTPGetter( WithBasicAuth("I", "Am"), WithUserAgent("Groot"), + WithTLSClientConfig(pub, priv, ca), ) if err != nil { t.Fatal(err) } - hg, ok = g.(*HTTPGetter) + hg, ok := g.(*HTTPGetter) if !ok { t.Fatal("expected NewHTTPGetter to produce an *HTTPGetter") } @@ -90,6 +71,18 @@ func TestHTTPGetter(t *testing.T) { if hg.opts.userAgent != "Groot" { t.Errorf("Expected NewHTTPGetter to contain %q as the user agent, got %q", "Groot", hg.opts.userAgent) } + + if hg.opts.certFile != pub { + t.Errorf("Expected NewHTTPGetter to contain %q as the public key file, got %q", pub, hg.opts.certFile) + } + + if hg.opts.keyFile != priv { + t.Errorf("Expected NewHTTPGetter to contain %q as the private key file, got %q", priv, hg.opts.keyFile) + } + + if hg.opts.caFile != ca { + t.Errorf("Expected NewHTTPGetter to contain %q as the CA file, got %q", ca, hg.opts.caFile) + } } func TestDownload(t *testing.T) { @@ -149,3 +142,42 @@ func TestDownload(t *testing.T) { t.Errorf("Expected %q, got %q", expect, got.String()) } } + +func TestDownloadTLS(t *testing.T) { + cd := "../../testdata" + ca, pub, priv := filepath.Join(cd, "rootca.crt"), filepath.Join(cd, "crt.pem"), filepath.Join(cd, "key.pem") + + tlsSrv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) + tlsConf, err := tlsutil.NewClientTLS(pub, priv, ca) + if err != nil { + t.Fatal(errors.Wrap(err, "can't create TLS config for client")) + } + tlsConf.BuildNameToCertificate() + tlsConf.ServerName = "helm.sh" + tlsSrv.TLS = tlsConf + tlsSrv.StartTLS() + defer tlsSrv.Close() + + u, _ := url.ParseRequestURI(tlsSrv.URL) + g, err := NewHTTPGetter( + WithURL(u.String()), + WithTLSClientConfig(pub, priv, ca), + ) + if err != nil { + t.Fatal(err) + } + + if _, err := g.Get(u.String()); err != nil { + t.Error(err) + } + + // now test with TLS config being passed along in .Get (see #6635) + g, err = NewHTTPGetter() + if err != nil { + t.Fatal(err) + } + + if _, err := g.Get(u.String(), WithURL(u.String()), WithTLSClientConfig(pub, priv, ca)); err != nil { + t.Error(err) + } +} diff --git a/pkg/getter/testdata/output/httpgetter-servername.txt b/pkg/getter/testdata/output/httpgetter-servername.txt deleted file mode 100644 index caa12a8fb..000000000 --- a/pkg/getter/testdata/output/httpgetter-servername.txt +++ /dev/null @@ -1 +0,0 @@ -example.com \ No newline at end of file diff --git a/testdata/ca.pem b/testdata/ca.pem deleted file mode 100644 index 79d854a8d..000000000 --- a/testdata/ca.pem +++ /dev/null @@ -1,35 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIGADCCA+igAwIBAgIJALbFKeU+io3AMA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV -BAYTAlVTMQswCQYDVQQIEwJDTzEQMA4GA1UEBxMHQm91bGRlcjEPMA0GA1UEChMG -VGlsbGVyMQ8wDQYDVQQLEwZUaWxsZXIxDTALBgNVBAMTBEhlbG0wHhcNMTcwNDA0 -MTYwNDQ5WhcNMTgwNDA0MTYwNDQ5WjBdMQswCQYDVQQGEwJVUzELMAkGA1UECBMC -Q08xEDAOBgNVBAcTB0JvdWxkZXIxDzANBgNVBAoTBlRpbGxlcjEPMA0GA1UECxMG -VGlsbGVyMQ0wCwYDVQQDEwRIZWxtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC -CgKCAgEAyFOriVMm3vTeVerwMuBEIt07EJFzAn+5R1eqdNEJ0k08/ZPKPLnhkg+/ -sRZuzah4lbszbAb7frtqtXKT8u28/tsQofCt5M9VZLK21yS4QX1kBS3CvN9mfw4r -S+yzoP/7oFPydwVhSsOZ3kRUrU7jyxZjFMPCLJU5O1WTRA/PEKagjf5Y63q0jhU7 -/VDPazeUKSvfyPW9HxVMLkWYK6hLb2sDoopbeV5L/wPDb66sLuIPcGw25SprzDqq -9OtM2pMG89h1cDhXeH8NJPOVzCkkalqwl+Ytl2alh9HWT8cb0nJ+TKhFtvTpM60U -Ku+H+zLTIaHBIUxKrNiTowBQe4JcHmyYp+IJnZv/l4kH5CkWIX3SIcOACSbLlzWB -QjBCWDtgmT4bdCDtnQF6eTVdMOy76/Yyzj9xLKUEr/fNqE4CtZMEfJdELHsX9hpC -Dq031NgKNZvMd+llv259QWFVltZ+GOctCaT4TlTWRiFYl0ysYnsZ5HbA6eKt810l -rpjtnrKCBenzrHLRCP+BGcfhGlisiutaclUwwgKow8/OV4+9Eg4RTeIhzWIIcfDI -UDgkecNcTPK2VZt4Kj6D2vvWJHqUNpiL1FVekki7FrhkoXR5BOvHfoDqpvl+BTyb -AfBmPyVx9/0zoAdYfpRsMUjVeWtS/oS9UDt2UJojSa1hMhd8pIECAwEAAaOBwjCB -vzAdBgNVHQ4EFgQU7NrQViMsDpfYfVZITtwOuT2J6HYwgY8GA1UdIwSBhzCBhIAU -7NrQViMsDpfYfVZITtwOuT2J6HahYaRfMF0xCzAJBgNVBAYTAlVTMQswCQYDVQQI -EwJDTzEQMA4GA1UEBxMHQm91bGRlcjEPMA0GA1UEChMGVGlsbGVyMQ8wDQYDVQQL -EwZUaWxsZXIxDTALBgNVBAMTBEhlbG2CCQC2xSnlPoqNwDAMBgNVHRMEBTADAQH/ -MA0GCSqGSIb3DQEBCwUAA4ICAQCs+RwppSZugKN+LZ226wf+A86+BEFXNyVQ5all -YgBA4Oiai3O3XGMpNmm60TbumjzVq8PrNNuQxR2VfK/N7qLLJMktIVBntRsiQnTR -Yw/EuhcuvYOhJ7P8RwifkhusZTLI6eQhES5bmUYuXmp887qkr/dN1XmiubTKLDTE -fZAhOVAvA55YgJzEvBkVAXpT5tzrOakjo+PM6NoUcEWQsh3z1RRgFowUi3aKjM7k -J38h5iCJCLlo5Av+bhdw/rP+qw7d6DgKemrxC91qyk48BhTXp3qR3XLmuqjtQq6u -xMPgKNs6/fornWbvCX+vQq9Hncm7X4ZHBdoaWAs5P9lpACuR77/Ad30rY026bM4m -br8VQxWU2qlTt8vfp8jIuiylJP/YU9aMsKc8lIue19As+Llw9t9Zdq3z/Q3xul7N -hXLa/NJeban9iTNgjzPWigSGpaXIFxYZ3fl0flYkMG2KzhuYttHVuWyIJ8WLpsPN -Os9SIkekZipwsCdtL65fCLj5DjAmX6LwnxVf6Z5K9hsOEM+uZvq0qsrLjndxmbrG -+Br+p4jxH8kkUNdoNVlbg1F+0+sgtD9drgSLM4cZ9wVWUl64qbDpQR+/pVlSepiQ -kPTthsGtcrW8sTSMlLY4XpCLcS/hwO4jwNCB+8bLsz/6p9vCDMIkb5zkhjPc/Awe -mlK3dw== ------END CERTIFICATE----- diff --git a/testdata/crt.pem b/testdata/crt.pem index 226b3a71b..715cd0f65 100644 --- a/testdata/crt.pem +++ b/testdata/crt.pem @@ -1,29 +1,73 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 55:31:53:9b:41:72:05:dc:90:49:bd:48:13:7c:59:9e:5a:53:5e:86 + Signature Algorithm: sha256WithRSAEncryption + Issuer: C=US, ST=CO, L=Boulder, O=Helm, CN=helm.sh + Validity + Not Before: Nov 1 22:51:49 2019 GMT + Not After : Oct 29 22:51:49 2029 GMT + Subject: C=US, ST=CO, L=Boulder, O=Helm, CN=helm.sh + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public-Key: (2048 bit) + Modulus: + 00:c8:89:55:0d:0b:f1:da:e6:c0:70:7d:d3:27:cd: + b8:a8:81:8b:7c:a4:89:e5:d1:b1:78:01:1d:df:44: + 88:0b:fc:d6:81:35:3d:d1:3b:5e:8f:bb:93:b3:7e: + 28:db:ed:ff:a0:13:3a:70:a3:fe:94:6b:0b:fe:fb: + 63:00:b0:cb:dc:81:cd:80:dc:d0:2f:bf:b2:4f:9a: + 81:d4:22:dc:97:c8:8f:27:86:59:91:fa:92:05:75: + c4:cc:6b:f5:a9:6b:74:1e:f5:db:a9:f8:bf:8c:a2: + 25:fd:a0:cc:79:f4:25:57:74:a9:23:9b:e2:b7:22: + 7a:14:7a:3d:ea:f1:7e:32:6b:57:6c:2e:c6:4f:75: + 54:f9:6b:54:d2:ca:eb:54:1c:af:39:15:9b:d0:7c: + 0f:f8:55:51:04:ea:da:fa:7b:8b:63:0f:ac:39:b1: + f6:4b:8e:4e:f6:ea:e9:7b:e6:ba:5e:5a:8e:91:ef: + dc:b1:7d:52:3f:73:83:52:46:83:48:49:ff:f2:2d: + ca:54:f2:36:bb:49:cc:59:99:c0:9e:cf:8e:78:55: + 6c:ed:7d:7e:83:b8:59:2c:7d:f8:1a:81:f0:7d:f5: + 27:f2:db:ae:d4:31:54:38:fe:47:b2:ee:16:20:0f: + f1:db:2d:28:bf:6f:38:eb:11:bb:9a:d4:b2:5a:3a: + 4a:7f + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Alternative Name: + DNS:helm.sh, IP Address:127.0.0.1 + Signature Algorithm: sha256WithRSAEncryption + 4e:17:27:3d:36:4e:6c:2b:f7:d4:28:33:7e:05:26:7a:42:a0: + 2c:44:57:04:a0:de:df:40:fb:af:70:27:e6:55:20:f1:f8:c0: + 50:63:ab:b8:f1:31:5d:1e:f4:ca:8d:65:0b:d4:5e:5b:77:2f: + 2a:af:74:5f:18:2d:92:29:7f:2d:97:fb:ec:aa:e3:1e:db:b3: + 8d:01:aa:82:1a:f6:28:a8:b3:ee:15:9f:9a:f5:76:37:30:f2: + 3b:38:13:b2:d4:14:94:c6:38:fa:f9:6e:94:e8:1f:11:0b:b0: + 69:1a:b3:f9:f1:27:b4:d2:f5:64:54:7c:8f:e7:83:31:f6:0d: + a7:0e:0e:66:d8:33:2f:e0:a1:93:56:92:58:bf:50:da:56:8e: + db:42:22:f5:0c:6f:f8:4c:ef:f5:7c:2d:a6:b8:60:e4:bb:df: + a3:6c:c2:6b:99:0b:d3:0a:ad:7c:f4:74:72:9a:52:5e:81:d9: + a2:a2:dd:68:38:fb:b7:54:7f:f6:aa:ee:53:de:3d:3a:0e:86: + 53:ad:af:72:db:fb:6b:18:ce:ac:e4:64:70:13:68:da:be:e1: + 6b:46:dd:a0:72:96:9b:3f:ba:cf:11:6e:98:03:0a:69:83:9e: + 37:25:c9:36:b9:68:4f:73:ca:c6:32:5c:be:46:64:bb:a8:cc: + 71:25:8f:be -----BEGIN CERTIFICATE----- -MIIFCDCCAvCgAwIBAgIJAMADBPQSkgPMMA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV -BAYTAlVTMQswCQYDVQQIEwJDTzEQMA4GA1UEBxMHQm91bGRlcjEPMA0GA1UEChMG -VGlsbGVyMQ8wDQYDVQQLEwZUaWxsZXIxDTALBgNVBAMTBEhlbG0wHhcNMTcwNDA0 -MTYwNzM4WhcNMTgwNDA0MTYwNzM4WjARMQ8wDQYDVQQDEwZjbGllbnQwggIiMA0G -CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDnyxxZtTKZLOYyEDmo1pY8m6A1tot1 -UuiSxtwp4rNYIaVyCbpdKrNr68q6dRs40vEWGfH415OzFjK3RpbzdSqeB4U+toUl -bIYjf9N4/ZrAjqBO+Xd+JKUkhKcZIbMJHb2kOzqOL7LSWlKcyGCY/x7Tj4qdka9R -QiXB7zVUEqcTa13A+/rdrPWgzK/xGIYh7cCehOixxXSmfcCHR573BDC5j6s9KozA -T84obBgEgsVgu1+d+n1D+cqAr7ppSZTMWs/f+DwwJG/VWblIYsCuN3yNHLaYsL9M -MTw1ogulcRmFNyw9CSXdyVCxGjh/++sQ2f47TpadI+IzknrBkfPL7+zt2IyaORch -uGsdX+IwQl3aZjayMx7YjYSSbQIfpSF9y4KVPz4RHEUn10hsX/8qXPzitbXVLh7p -b9lUMGPHchTm/dd+oZAbL1TUIJQOJn2vGDMKsuBswBg12YNdhAp55EDZx54CCiM2 -sRtlVNTpkatr7Rvd5CDFuLAzwHnrEKTy5EOUrS9aYzqKaGOrMI+k1OCTp3LwLdPX -d7OV9+ZuSLHX6gvF4uAucK8HLp3Visj0GeWL7OzpTv2imjNX5C1wPH7UR6UsF+dg -bzqZOP63e5WR1eEqth5ieE+5jQ8nxvPF//qKHQNlgbD93Y3B3UfmjrnP1chgqFn9 -IAXWFsyZ7I8bXQIDAQABoxcwFTATBgNVHSUEDDAKBggrBgEFBQcDAjANBgkqhkiG -9w0BAQsFAAOCAgEAPIXMQOAgb2VlfS59HrvpdqbIapIfs/xBgPKlNfwNO3UpSYyq -XVK1xekLI+mEE639YP/oSc7HX2OrJi3SX5Ofzs0s9h+BNTXPqw1ju+G34cF8MKc0 -acynThdcI4eZGc2fKSAIw6RN7iIln74Sf4MNmEuQu6Dnq4QkZKAWtnY7Uq5ooFJS -JA+Joqif8SvEvMgq02XdUhjijlBAanxI/xp64k37k18+pHAxcS22HzrjwDQ4ELqY -gBq9g20JYXoUxjBFUfj+cxBx+LBKfPVTpcbicI4wwP4a2BA6LDUHgcnSMhle1zeq -pHuOIOT6XqYLhO0Yr7WRG9Yzuxs0GV4TH+FlDpDHWL8XG0gjDUZ/2viPlKBr+FoN -inW8jqQ2NYMzYF9zHNzXVGK+5oyH4Y7r/8WxQLfdSR/5S1DXPLSkzkYbduHf9UmF -Dvh6NrCGU0UxypA1NvF5o11cnTQ22GPywVSc0ILKWDRlu8DiGq71bYQu8hTTkTnb -2hOr5JHcGaloms7WM3q0hc2PIhwYXw2V3b9I9lbnvv3Y/yKPNN7IzU5No6siRuIH -paj83V0flMWj1EqJMDxk9ECHgDyl/1ftgJVx1G/f/+UnXoRdR2kFqVVeJTeSIZi7 -dSsAOIMN/weZMZF55Q61vgUgYXKp4g2/Zk8BJn0cx9pjEMIw/pc7Eq1x/R8= +MIIDRDCCAiygAwIBAgIUVTFTm0FyBdyQSb1IE3xZnlpTXoYwDQYJKoZIhvcNAQEL +BQAwTTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNPMRAwDgYDVQQHDAdCb3VsZGVy +MQ0wCwYDVQQKDARIZWxtMRAwDgYDVQQDDAdoZWxtLnNoMB4XDTE5MTEwMTIyNTE0 +OVoXDTI5MTAyOTIyNTE0OVowTTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNPMRAw +DgYDVQQHDAdCb3VsZGVyMQ0wCwYDVQQKDARIZWxtMRAwDgYDVQQDDAdoZWxtLnNo +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIlVDQvx2ubAcH3TJ824 +qIGLfKSJ5dGxeAEd30SIC/zWgTU90Ttej7uTs34o2+3/oBM6cKP+lGsL/vtjALDL +3IHNgNzQL7+yT5qB1CLcl8iPJ4ZZkfqSBXXEzGv1qWt0HvXbqfi/jKIl/aDMefQl +V3SpI5vityJ6FHo96vF+MmtXbC7GT3VU+WtU0srrVByvORWb0HwP+FVRBOra+nuL +Yw+sObH2S45O9urpe+a6XlqOke/csX1SP3ODUkaDSEn/8i3KVPI2u0nMWZnAns+O +eFVs7X1+g7hZLH34GoHwffUn8tuu1DFUOP5Hsu4WIA/x2y0ov2846xG7mtSyWjpK +fwIDAQABoxwwGjAYBgNVHREEETAPggdoZWxtLnNohwR/AAABMA0GCSqGSIb3DQEB +CwUAA4IBAQBOFyc9Nk5sK/fUKDN+BSZ6QqAsRFcEoN7fQPuvcCfmVSDx+MBQY6u4 +8TFdHvTKjWUL1F5bdy8qr3RfGC2SKX8tl/vsquMe27ONAaqCGvYoqLPuFZ+a9XY3 +MPI7OBOy1BSUxjj6+W6U6B8RC7BpGrP58Se00vVkVHyP54Mx9g2nDg5m2DMv4KGT +VpJYv1DaVo7bQiL1DG/4TO/1fC2muGDku9+jbMJrmQvTCq189HRymlJegdmiot1o +OPu3VH/2qu5T3j06DoZTra9y2/trGM6s5GRwE2javuFrRt2gcpabP7rPEW6YAwpp +g543Jck2uWhPc8rGMly+RmS7qMxxJY++ -----END CERTIFICATE----- diff --git a/testdata/generate.sh b/testdata/generate.sh new file mode 100755 index 000000000..9751ef304 --- /dev/null +++ b/testdata/generate.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +openssl req -new -config openssl.conf -key key.pem -out key.csr +openssl ca -config openssl.conf -create_serial -batch -in key.csr -out crt.pem -key rootca.key -cert rootca.crt diff --git a/testdata/key.pem b/testdata/key.pem index 8b2cde82e..691e55087 100644 --- a/testdata/key.pem +++ b/testdata/key.pem @@ -1,51 +1,27 @@ -----BEGIN RSA PRIVATE KEY----- -MIIJKQIBAAKCAgEA58scWbUymSzmMhA5qNaWPJugNbaLdVLoksbcKeKzWCGlcgm6 -XSqza+vKunUbONLxFhnx+NeTsxYyt0aW83UqngeFPraFJWyGI3/TeP2awI6gTvl3 -fiSlJISnGSGzCR29pDs6ji+y0lpSnMhgmP8e04+KnZGvUUIlwe81VBKnE2tdwPv6 -3az1oMyv8RiGIe3AnoToscV0pn3Ah0ee9wQwuY+rPSqMwE/OKGwYBILFYLtfnfp9 -Q/nKgK+6aUmUzFrP3/g8MCRv1Vm5SGLArjd8jRy2mLC/TDE8NaILpXEZhTcsPQkl -3clQsRo4f/vrENn+O06WnSPiM5J6wZHzy+/s7diMmjkXIbhrHV/iMEJd2mY2sjMe -2I2Ekm0CH6UhfcuClT8+ERxFJ9dIbF//Klz84rW11S4e6W/ZVDBjx3IU5v3XfqGQ -Gy9U1CCUDiZ9rxgzCrLgbMAYNdmDXYQKeeRA2ceeAgojNrEbZVTU6ZGra+0b3eQg -xbiwM8B56xCk8uRDlK0vWmM6imhjqzCPpNTgk6dy8C3T13ezlffmbkix1+oLxeLg -LnCvBy6d1YrI9Bnli+zs6U79opozV+QtcDx+1EelLBfnYG86mTj+t3uVkdXhKrYe -YnhPuY0PJ8bzxf/6ih0DZYGw/d2Nwd1H5o65z9XIYKhZ/SAF1hbMmeyPG10CAwEA -AQKCAgEAuFqW5dJzt9g6Db9R3LMvMm0kcxQIvvt99p8rJDUmJwY7rAOIsejwYvla -eAoD6KH9FXL1PNFYq6sQEyyVinS5vI6Gr2ZDZ4x0828LJsOtfVDyt106aJ2EqxLG -Q/rFho6c8i4ZWFUfiKZF5mSIT6c5QVJ9EO153ssZdLFoXMGpGIzgOEkxMXYKtiWW -Gc9Df2C1Pl6/JATDzldd9TpFeHlgt3VI4JEi+SF/+i5eu9e2XEUqu18qmhHluYwK -WwsmyZHAm4W3eSLBv5JpBuVkEiwXZ7Ralf6dZ2ARXybO1HqrrYRALxtDfq5K+1C7 -dy9JulFnHoxWxgxwMExkTehjWuQsL0vEqYEGfa9q3yz61uYB7Np3bKadhke4BftP -zsHciIcJJk1cwqAJMcE968SWLuARm5SK6UacVHujp0pB78kpz3VjWwICXKU5zVuh -BXkb5fTDAQB+8KklYSrg0XP9lav9fwmCrZtHosq88M8HPPW7vrx1Wr5cxKiEbJK2 -MeJxrhnTCQamHMWw/9zkWRCwLpMKTXc/6u7BtnacjDASqaJ+F+ZF9PHab6vBOdXK -zx5YLAKVGpVu8bZM7fduYJxOAIDtkA1RqA8cPkwUOA0zJMPeBO/mJYOYnDhS/456 -CYvNGjbQjgXxLmsXnVezt7cd+QsH45WNHV7qMTaC30r3//VKTwECggEBAPvPYIhI -EHH8rCCctD1pHQJtPFpbREukmycKGX9QRZG5ZyZcxrr6tde+zlSRQwk2/fxVZ4x2 -m6qCgB91gD+stNkASSsgeP9XSpX15DY9+7Wj6/PGlgPOaX9/lx0hadRXCgCNvsbc -ECy870NJKFSxXHVaab+9AqQginOJLYYoGOxlEbs0eXXeAvl5BGFi2hdDSjeb6P6R -/H/MMMoLeAZLGGRpncNHiDpBQ+h4k/5dgBSV1pMgfW+n/zYu3FnyYKnoXTsjx5eM -Sk+mEH5A/wwOrAA007vSUjDcTpKw1AVCic72/59MrR4C/oUMj0omP1GirLsYv6fx -dd3UiK/itP82vbECggEBAOumeDvH5zl2cepzuv+gx9vg17/r4yCzt0qTpStmakjT -d7xVurBxeNets3w0Tkcti2zJU3nUBPcFmYNmGvq5VB1mnmbo0DgDaxB4ZluBnadk -XOg9ItJrLyW6eeYKeLSvE5Q2cC6u8mfYWAfhT5WdGIX6gg1yOdSwP292qRtG4fdk -YZ5GYQQ9XRuPVHNOgdcXGxrx84aoH6W2Tp+CjIqekZvX5BKOA3p+8du0COetJ9yF -nB0RIDElF87UBFuAP4hNk1gDop3Xl6n4Wh+a1xFaQmUH12Q8ErXmxtAzlBsqFYeT -6U60wQMr0xF2I9irCH+V74wnoPFIkIcbwxbDfh24h20CggEAe9UGzt5JoBS2/S6z -AIRBrODVTkYVtvFTD4bK9S4fmENJ87aqUGdcp6WAyFvLUKvHiaDiVFQ7x0V4BoB9 -OlMPeKvIT7ofZsqhtk9/FCG1OCVNsstVGLgYb4fqY3v8FF1dYNpUGG0+UxHyw+8l -M0kpg9ibqpwjwVzzWU/7oD71ysMFTj/G/2zXn6GgwtefEtOXmvNESHS4bIyY7bNo -KggiDbdWyyLRXnycDaXGec+3Xeg15pKSvScrvZSb7mvgl43a02uMCv4FyVeMQtpp -0p8gfNV9zp7mpnqg9Uiaa5/GL46ONOO7OsgULI/5o2hduSK7uSK5lbiL0zRip8Rg -aCWecQKCAQEAx75ohcuxbBzA/IkyhcHEBtW0KyMId8y93cH+rCX4i1hsUsCcKTlV -xAOhcvNnMqAhYYnZbxfPSY9+i0l+Lu3upak5NWO8Mu56zxAvOvtIJf5FXjmMDa36 -3dENyHcxz33ja6slNfzmzi0smSlbaycpBU/M8xbSfD0U2CdNuihAG5IDyMRBMfXN -uTGp1L9EAYy9Vf6mfIp/oNhCFqTy+gDkzaOW2D92JVv7KE6XicFVW3AJXv4IOoAF -iTRfqSuxLpkK/vy912tKTDGOOuHl0Pif9MFLytO8zGEcPpipvsjSTQSMK0G9pTF9 -jHyGb/6ximwOC8//dOYcU9mtaNs2SH0ElQKCAQA3w+4zTnrD/VCK0dGJxaPUn6Kq -eaK71lEWfSA2kkKEItaEsRYwfzX6LSJyDgjpvZg5LIIVyxd0h8Q4Apw2LNbZqWVt -wBgi0H1SttHJ62z9IO8EEKHB1suGbtsPRDM4IoqgsPYD0GZ4fhgJzoy2Z3qvMlWB -/pz0+P1sCGaghEiwPOLbv+1uZXDOWVi2qaQq9uceldqitWSOFjiJFEOH3SdA0XDo -drA8S5vFWe3dgCIcHRmTGbOG3eID16Q2Zq636U7eM6Q2UZ3G+EwrefuG8q6DeYJ6 -7LcdWpKduPf3s/Jx23Otc8CNmAEixDkRFY0Glv/8e17rgUpLhiQsUIyqoTap +MIIEpgIBAAKCAQEAyIlVDQvx2ubAcH3TJ824qIGLfKSJ5dGxeAEd30SIC/zWgTU9 +0Ttej7uTs34o2+3/oBM6cKP+lGsL/vtjALDL3IHNgNzQL7+yT5qB1CLcl8iPJ4ZZ +kfqSBXXEzGv1qWt0HvXbqfi/jKIl/aDMefQlV3SpI5vityJ6FHo96vF+MmtXbC7G +T3VU+WtU0srrVByvORWb0HwP+FVRBOra+nuLYw+sObH2S45O9urpe+a6XlqOke/c +sX1SP3ODUkaDSEn/8i3KVPI2u0nMWZnAns+OeFVs7X1+g7hZLH34GoHwffUn8tuu +1DFUOP5Hsu4WIA/x2y0ov2846xG7mtSyWjpKfwIDAQABAoIBAQC/XB1m58EQzCVS +sx7t2qedVJEQjcpxHdql0xr4VOMl3U2r2mx03pxrt+lH3NmMlN3bmL2pgzSJ2GSI +Gsbsf8jpUIwTraKUDe9PevbswZ+Sz3Wbl96dKGhzAWCcWWEBHGKgsKe+2Hmg75Il +Jm446btAaziDnFuJukKYi9XN/kgYPxi914O8yz2KtCIVHEHHkl1FcSqjpghPtzU3 +hm1Nv/7tW2r5IrxCGRNJQTg6l4A4mdqif1u75ZUMcbp8dTaJ2/iYBIKIsh7sFMqy +TG6ZN0p3G92ijo7rtznxXS9rIE2rcg6qhusdK8eqhV0KHOqH2nkB4jWbw1NwKFzV +2jXm4S5RAoGBAPIExNBpE30c++Wl4ITuzODd99CczFj527ZBxUdT/H/IszR7adtJ +gHnayzzycul3GnCVMEGBUBp7q09OkcacA7MqS3/Zjn2zrpViz2iluP6jl0qfs2Sp +HaePLBKz9oFVi5m17ZYYnG7etSPVzcLaEi23ws5286HToXeqfUuGd+DlAoGBANQf +FJzQ0EbNu5QcNnQqwfAahvSqc+imPL0HuQWKEMvN3UXXU7Nn8bqba/JGVhgD7/5u +3g2DyyIou6gnocN669CqY8hm0jEboggD4pC8LVj+Iot25UzoNeNuHfqeu7wAlWWL +zjfC3UpSbh1O4H8i5chpFxe9N7syzOXBI5IVPBuTAoGBAITrrZSxQSzj8E0uj2Mz +LH8MKgD/PRRZFhzBfrIwJGuiNRpL9dWkRtWmHx14IziqW3Ed3wT7Gp2Q8oN6KYIl +SbrrLdAoEqRjPS16uWNGMZZZDszDbWmJoGnYrmIPSQG7lBJ14uke1zvlQSNPV9T+ +pCFL3cg7eI+WhgYNMwd58PkpAoGBAKTXFlyaxRAQtrFtjz+NLrMY2kFt6K8l6FN5 +meXdGhpW+5pXsBreLvK17xgSYrs87BbML1FPVt9Pyiztx36ymmjI0MweYz94Wt1h +r4KMSa07qLq6hYzTc3Uu0Ks/CWMbDP4hu/qHOxKTpjCuaDVEeE7ao/B1wcZ+vs3Y +3nyadeBzAoGBAJAZl50nHPwXpEIsHO3nC1ff51cVoV3+gpcCgQ270rLEa2Uv8+Zc +8rXD/LgcLzZ6Fvp0I3jv1mXlN8W0OruZS71lCM/zBd++E04HMxcvuv4lfqzcW+3E +V0ZBn2ErSTF9yKvGedRJk+vbCi7cy38WaA+z59ct/gpiw2Z3q6w85jlF -----END RSA PRIVATE KEY----- diff --git a/testdata/openssl.conf b/testdata/openssl.conf new file mode 100644 index 000000000..9b27e445b --- /dev/null +++ b/testdata/openssl.conf @@ -0,0 +1,42 @@ +[ca] +default_ca = CA_default + +[CA_default] +dir = ./ +database = $dir/index.txt +new_certs_dir = ./ +serial = $dir/serial +private_key = ./rootca.key +certificate = ./rootca.crt +default_days = 3650 +default_md = sha256 +policy = policy_anything +copy_extensions = copyall + +[policy_anything] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +[ req ] +default_bits = 2048 +distinguished_name = req_distinguished_name +req_extensions = v3_req + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +stateOrProvinceName = State or Province Name (full name) +localityName = Locality Name (eg, city) +organizationName = Organization Name (eg, company) +commonName = Common Name (e.g. server FQDN or YOUR name) + +[ v3_req ] +subjectAltName = @alternate_names + +[alternate_names] +DNS.1 = helm.sh +IP.1 = 127.0.0.1 diff --git a/testdata/rootca.crt b/testdata/rootca.crt new file mode 100644 index 000000000..892104365 --- /dev/null +++ b/testdata/rootca.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDITCCAgkCFAasUT/De3J4aee7b1VEESf+3ndyMA0GCSqGSIb3DQEBCwUAME0x +CzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDTzEQMA4GA1UEBwwHQm91bGRlcjENMAsG +A1UECgwESGVsbTEQMA4GA1UEAwwHaGVsbS5zaDAeFw0xOTExMDEyMjM2MzZaFw0y +MjA4MjEyMjM2MzZaME0xCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDTzEQMA4GA1UE +BwwHQm91bGRlcjENMAsGA1UECgwESGVsbTEQMA4GA1UEAwwHaGVsbS5zaDCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMinBcDJwiG3OVb1bCWQqTAOS3s6 +QwWkEXkoYyFFpCNvqEzQPtp+OkfD6gczc0ByGQibDLBApEQhq17inqtAxIUrTgXP +ym3l+0/U7ejuTka3ue84slkw2lVobfVEvJWGro+93GzbxvVNNYGJcD2BKJqmCCxD +I6tdTEL855kzgQUAvGITzDUxABU9+f06CW/9AlZlmBIuwrzRVjFNjflBrcm1PIUG +upMCu8zaWat8o1TnLCDKizw1JJzCgCnMxGXfzeAd1MGUG/rOFkBImHf39Jakp/7L +Icq+2FDE+0vNai0lpUpxPVTp8dcug8U3//bL3q0OqROA7Ks4wc0URGH71W8CAwEA +ATANBgkqhkiG9w0BAQsFAAOCAQEAMJqzeg6cBbUkrh9a6+qa66IFR1Mf3wVB1c61 +JN6Z70kjgSdOZ/NexxxSu347fIPyKGkmokbnE1MJVEETPmzhpuTkQDcq7KT4IcQF +S+H4l0lNn09thIlIiAJmpQrNOlrHVtpLCFB4+YnsqqFKPlcO/dGy9U26L4xfn6+n +24/o7pNEu44GnktXPjfcbajaPUSKHxeYibjdftoUEYX/79ROu7E1QnNXj7mXymw0 +rqOgIlyCUGw8WvRR8RzR6m+1lnwOc+nxFKXzTt0LqOQt9sHI1V71WrxgDE+Lck+W +fybfsgodM2Y7VXnH4A4xoKeOHxW1YcqIKt0ribt8602lD1pYBg== +-----END CERTIFICATE----- diff --git a/testdata/rootca.key b/testdata/rootca.key new file mode 100644 index 000000000..e3c1ce51e --- /dev/null +++ b/testdata/rootca.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAyKcFwMnCIbc5VvVsJZCpMA5LezpDBaQReShjIUWkI2+oTNA+ +2n46R8PqBzNzQHIZCJsMsECkRCGrXuKeq0DEhStOBc/KbeX7T9Tt6O5ORre57ziy +WTDaVWht9US8lYauj73cbNvG9U01gYlwPYEomqYILEMjq11MQvznmTOBBQC8YhPM +NTEAFT35/ToJb/0CVmWYEi7CvNFWMU2N+UGtybU8hQa6kwK7zNpZq3yjVOcsIMqL +PDUknMKAKczEZd/N4B3UwZQb+s4WQEiYd/f0lqSn/sshyr7YUMT7S81qLSWlSnE9 +VOnx1y6DxTf/9sverQ6pE4DsqzjBzRREYfvVbwIDAQABAoIBAHwyTbBP8baWx4oY +rNDvoplZL8VdgaCbNimNIxa0GW3Jrh2lhFIPcZl8HX5JjVvlg7M87XSm/kYhpQY9 +NUMA+uMGs+uK+1xcztpSDNRxtMe27wKwUEw+ndXhprX6ztOqop/cP/StcI/jM2wz +muKm8HAQttxWzlxCinKoQd4k8AYcnqc728FSODP7EsdDgiU6BhBZDqjgmqggye0y +niog+JBPDgwTgGodJWtSYuP/G2iJDUvm7bGU2gftXTJstrATLftGKX8XOgJMmDx9 +8OgDtU21LzggarOQ/iwUKX2MEfYnP8kgGLgu5nNonJCHWYGeCZoxIn70rs3WoBsU +5+FzmHkCgYEA7MFYixlTSxXfen1MwctuZ9YiwoneSLfjmBb+LP0Pfa2r0CVMPaXM +OexroIY14h64nunb7y3YifGk01RXzCBpEF5KhsZuYXAl3lGxbjbTjncU5/11Dim+ +W9g+T4zDimlK2tuweAjMfWz6XG2inZ3xvK73mGkEsUnqhWQKXBRf7VsCgYEA2PZp +KAwbpRFSYFwcZoRm81fLijZ5NbmOJtND6oG1LZVaVSYuvljvjQzeVfL4+Iju6FzT +zbnEfVsatu0cTs6jMy0yJUl6wRbHlH/G6Ra8UxSvUUEFe1Xap33RmjkK+atzALQi +pZPCIfLr+f9qQWrPMdZwzRnws0u2pKepSdXR0H0CgYB9chDdWyTkIwnPmDakdIri +X/b5Bx4Nf8oLGxvAcLHVkMD5v9l+zKvCgT+hxZslXcvK//S17Z/Pr4b7JrSChyXE +M4HfmaKA5HBcNQMDd+9ujDA6n/R29a1UcubJNbeiThoIjuEZKOhZCPY7JShFxZuB +s1+jlPmUiqrF1PUcRvtxAwKBgQDGpuelmWB+hRutyujeHQC+cnaU+EeHH3y+o9Wd +lGG1ePia2jkWZAwCU/QHMk8wEQDelJAB38O/G3mcYAH5Tk4zf4BYj6zrutXGbDBO +H1kToO7dMPG5+eQYU6Vk1jHsZEUKMeU/QckQmIHkBy7c8tT/Rt9FjCjNodd7b2Ab +kMFpaQKBgQDggmgsPFSZmo+yYDZucueXqfc8cbSWd9K1UruKMaPOsyoUWJNYARHA +cpHTpaIjDth8MUp2zLIZnPUSDkSgEAOcRH4C5CxmgSkmeJdlEEzWMF2yugczlYGO +l9SOX07w4/WJCZFeRWTqRGWs7X6iL8um0P9yFelw3SZt33ON+1fRPg== +-----END RSA PRIVATE KEY----- From 444d006fe27bdea5ade0333fdb78c2141de2f175 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 1 Nov 2019 16:01:02 -0700 Subject: [PATCH 049/279] fix(version): implement `helm version -c`, mark as hidden Signed-off-by: Matthew Fisher --- cmd/helm/testdata/output/version-client-shorthand.txt | 1 + cmd/helm/testdata/output/version-client.txt | 1 + cmd/helm/version.go | 2 ++ cmd/helm/version_test.go | 8 ++++++++ 4 files changed, 12 insertions(+) create mode 100644 cmd/helm/testdata/output/version-client-shorthand.txt create mode 100644 cmd/helm/testdata/output/version-client.txt diff --git a/cmd/helm/testdata/output/version-client-shorthand.txt b/cmd/helm/testdata/output/version-client-shorthand.txt new file mode 100644 index 000000000..0d9b536e6 --- /dev/null +++ b/cmd/helm/testdata/output/version-client-shorthand.txt @@ -0,0 +1 @@ +version.BuildInfo{Version:"v3.0+unreleased", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/output/version-client.txt b/cmd/helm/testdata/output/version-client.txt new file mode 100644 index 000000000..0d9b536e6 --- /dev/null +++ b/cmd/helm/testdata/output/version-client.txt @@ -0,0 +1 @@ +version.BuildInfo{Version:"v3.0+unreleased", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/version.go b/cmd/helm/version.go index 8c0c11484..3067f7289 100644 --- a/cmd/helm/version.go +++ b/cmd/helm/version.go @@ -61,6 +61,8 @@ func newVersionCmd(out io.Writer) *cobra.Command { f := cmd.Flags() f.BoolVar(&o.short, "short", false, "print the version number") f.StringVar(&o.template, "template", "", "template for version string format") + f.BoolP("client", "c", true, "display client version information") + f.MarkHidden("client") return cmd } diff --git a/cmd/helm/version_test.go b/cmd/helm/version_test.go index 89b89093e..134401948 100644 --- a/cmd/helm/version_test.go +++ b/cmd/helm/version_test.go @@ -32,6 +32,14 @@ func TestVersion(t *testing.T) { name: "template", cmd: "version --template='Version: {{.Version}}'", golden: "output/version-template.txt", + }, { + name: "client", + cmd: "version --client", + golden: "output/version-client.txt", + }, { + name: "client shorthand", + cmd: "version -c", + golden: "output/version-client-shorthand.txt", }} runTestCmd(t, tests) } From 7f7e90b4078d412e2ff36d8220409ff8497c93a1 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Sat, 2 Nov 2019 00:18:21 +0100 Subject: [PATCH 050/279] Consider namespace when comparing resources Fixes #6857 Signed-off-by: Fabian Ruff --- pkg/action/upgrade.go | 2 +- pkg/kube/client.go | 2 +- pkg/kube/resource.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 31fcc1471..d0495a864 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -415,5 +415,5 @@ func recreate(cfg *Configuration, resources kube.ResourceList) error { func objectKey(r *resource.Info) string { gvk := r.Object.GetObjectKind().GroupVersionKind() - return fmt.Sprintf("%s/%s/%s", gvk.GroupVersion().String(), gvk.Kind, r.Name) + return fmt.Sprintf("%s/%s/%s/%s", gvk.GroupVersion().String(), gvk.Kind, r.Namespace, r.Name) } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 2a5661306..ab1f600ff 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -167,7 +167,7 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } kind := info.Mapping.GroupVersionKind.Kind - c.Log("Created a new %s called %q\n", kind, info.Name) + c.Log("Created a new %s called %q in %s\n", kind, info.Name, info.Namespace) return nil } diff --git a/pkg/kube/resource.go b/pkg/kube/resource.go index 0f2d94f3a..ee8f83a25 100644 --- a/pkg/kube/resource.go +++ b/pkg/kube/resource.go @@ -81,5 +81,5 @@ func (r ResourceList) Intersect(rs ResourceList) ResourceList { // isMatchingInfo returns true if infos match on Name and GroupVersionKind. func isMatchingInfo(a, b *resource.Info) bool { - return a.Name == b.Name && a.Mapping.GroupVersionKind.Kind == b.Mapping.GroupVersionKind.Kind + return a.Name == b.Name && a.Namespace == b.Namespace && a.Mapping.GroupVersionKind.Kind == b.Mapping.GroupVersionKind.Kind } From 4226c45dfd7419874583a37b79124afdd55129ec Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Mon, 4 Nov 2019 15:19:48 -0700 Subject: [PATCH 051/279] fix(cmd): Standardizes all output to use lower snake_case names After discussing similar changes in #6866, we decided to make sure all JSON and YAML output uses lower snake case names as is generally standard Signed-off-by: Taylor Thomas --- cmd/helm/list.go | 14 +++++++------- cmd/helm/repo_list.go | 4 ++-- cmd/helm/search_hub.go | 8 ++++---- cmd/helm/search_repo.go | 8 ++++---- cmd/helm/testdata/output/search-output-json.txt | 2 +- cmd/helm/testdata/output/search-output-yaml.txt | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 7e04e64a9..32501530d 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -110,13 +110,13 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } type releaseElement struct { - Name string - Namespace string - Revision string - Updated string - Status string - Chart string - AppVersion string + Name string `json:"name"` + Namespace string `json:"namespace"` + Revision string `json:"revision"` + Updated string `json:"updated"` + Status string `json:"status"` + Chart string `json:"chart"` + AppVersion string `json:"app_version"` } type releaseListWriter struct { diff --git a/cmd/helm/repo_list.go b/cmd/helm/repo_list.go index 10d8976fe..2ff6162d1 100644 --- a/cmd/helm/repo_list.go +++ b/cmd/helm/repo_list.go @@ -51,8 +51,8 @@ func newRepoListCmd(out io.Writer) *cobra.Command { } type repositoryElement struct { - Name string - URL string + Name string `json:"name"` + URL string `json:"url"` } type repoListWriter struct { diff --git a/cmd/helm/search_hub.go b/cmd/helm/search_hub.go index e4c149f4a..89139ec16 100644 --- a/cmd/helm/search_hub.go +++ b/cmd/helm/search_hub.go @@ -84,10 +84,10 @@ func (o *searchHubOptions) run(out io.Writer, args []string) error { } type hubChartElement struct { - URL string - Version string - AppVersion string - Description string + URL string `json:"url"` + Version string `json:"version"` + AppVersion string `json:"app_version"` + Description string `json:"description"` } type hubSearchWriter struct { diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index 68d0135c7..063a72a27 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -191,10 +191,10 @@ func (o *searchRepoOptions) buildIndex(out io.Writer) (*search.Index, error) { } type repoChartElement struct { - Name string - Version string - AppVersion string - Description string + Name string `json:"name"` + Version string `json:"version"` + AppVersion string `json:"app_version"` + Description string `json:"description"` } type repoSearchWriter struct { diff --git a/cmd/helm/testdata/output/search-output-json.txt b/cmd/helm/testdata/output/search-output-json.txt index d462a12c1..9b211e1b5 100644 --- a/cmd/helm/testdata/output/search-output-json.txt +++ b/cmd/helm/testdata/output/search-output-json.txt @@ -1 +1 @@ -[{"Name":"testing/mariadb","Version":"0.3.0","AppVersion":"","Description":"Chart for MariaDB"}] +[{"name":"testing/mariadb","version":"0.3.0","app_version":"","description":"Chart for MariaDB"}] diff --git a/cmd/helm/testdata/output/search-output-yaml.txt b/cmd/helm/testdata/output/search-output-yaml.txt index 5034d8ce0..122b7f345 100644 --- a/cmd/helm/testdata/output/search-output-yaml.txt +++ b/cmd/helm/testdata/output/search-output-yaml.txt @@ -1,4 +1,4 @@ -- AppVersion: 2.3.4 - Description: Deploy a basic Alpine Linux pod - Name: testing/alpine - Version: 0.2.0 +- app_version: 2.3.4 + description: Deploy a basic Alpine Linux pod + name: testing/alpine + version: 0.2.0 From d683a431e241a37c40042ad168f04460e9306eaf Mon Sep 17 00:00:00 2001 From: yuxiaobo Date: Tue, 5 Nov 2019 09:55:48 +0800 Subject: [PATCH 052/279] Correct spelling mistakes Signed-off-by: yuxiaobo --- cmd/helm/create.go | 2 +- cmd/helm/root.go | 2 +- cmd/helm/search/search.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/helm/create.go b/cmd/helm/create.go index e9f71d0a7..e8ff757cf 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -91,7 +91,7 @@ func (o *createOptions) run(out io.Writer) error { if o.starter != "" { // Create from the starter lstarter := filepath.Join(o.starterDir, o.starter) - // If path is absolute, we dont want to prefix it with helm starters folder + // If path is absolute, we don't want to prefix it with helm starters folder if filepath.IsAbs(o.starter) { lstarter = o.starter } diff --git a/cmd/helm/root.go b/cmd/helm/root.go index fac0dc062..f0a034d45 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -175,7 +175,7 @@ __helm_list_charts() # 1- There are other completions found (if there are no completions, # the shell will do file completion itself) # 2- If there is some input from the user (or else we will end up - # lising the entire content of the current directory which will + # listing the entire content of the current directory which will # be too many choices for the user to find the real repos) if [ $wantFiles -eq 1 ] && [ -n "${out[*]}" ] && [ -n "${cur}" ]; then for file in $(\ls); do diff --git a/cmd/helm/search/search.go b/cmd/helm/search/search.go index 855da4a3d..fc7f30596 100644 --- a/cmd/helm/search/search.go +++ b/cmd/helm/search/search.go @@ -51,7 +51,7 @@ type Index struct { const sep = "\v" -// NewIndex creats a new Index. +// NewIndex creates a new Index. func NewIndex() *Index { return &Index{lines: map[string]string{}, charts: map[string]*repo.ChartVersion{}} } From bd1f4a443e95ea4eda88affad96577b63c0d6622 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 30 Oct 2019 14:22:26 -0700 Subject: [PATCH 053/279] fix(show): restore comments from raw values Signed-off-by: Matthew Fisher --- pkg/action/show.go | 9 +++++---- pkg/chart/chart.go | 7 ++++++- pkg/chart/chart_test.go | 25 +++++++++++++++++++++++++ pkg/chart/loader/load.go | 1 + pkg/chart/loader/load_test.go | 4 ++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/pkg/action/show.go b/pkg/action/show.go index 3733b28fd..b29107d4e 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -24,6 +24,7 @@ import ( "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" + "helm.sh/helm/v3/pkg/chartutil" ) type ShowOutputFormat string @@ -76,11 +77,11 @@ func (s *Show) Run(chartpath string) (string, error) { if s.OutputFormat == ShowAll { fmt.Fprintln(&out, "---") } - b, err := yaml.Marshal(chrt.Values) - if err != nil { - return "", err + for _, f := range chrt.Raw { + if f.Name == chartutil.ValuesfileName { + fmt.Fprintln(&out, string(f.Data)) + } } - fmt.Fprintf(&out, "%s\n", b) } if s.OutputFormat == ShowReadme || s.OutputFormat == ShowAll { diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 2b667d456..c3e99eae6 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -26,13 +26,18 @@ const APIVersionV2 = "v2" // Chart is a helm package that contains metadata, a default config, zero or more // optionally parameterizable templates, and zero or more charts (dependencies). type Chart struct { + // Raw contains the raw contents of the files originally contained in the chart archive. + // + // This should not be used except in special cases like `helm show values`, + // where we want to display the raw values, comments and all. + Raw []*File `json:"-"` // Metadata is the contents of the Chartfile. Metadata *Metadata `json:"metadata"` // LocK is the contents of Chart.lock. Lock *Lock `json:"lock"` // Templates for this chart. Templates []*File `json:"templates"` - // Values are default config for this template. + // Values are default config for this chart. Values map[string]interface{} `json:"values"` // Schema is an optional JSON schema for imposing structure on Values Schema []byte `json:"schema"` diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go index 8b656d393..724e52933 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -16,6 +16,7 @@ limitations under the License. package chart import ( + "encoding/json" "testing" "github.com/stretchr/testify/assert" @@ -49,3 +50,27 @@ func TestCRDs(t *testing.T) { is.Equal("crds/foo.yaml", crds[0].Name) is.Equal("crds/foo/bar/baz.yaml", crds[1].Name) } + +func TestSaveChartNoRawData(t *testing.T) { + chrt := Chart{ + Raw: []*File{ + { + Name: "fhqwhgads.yaml", + Data: []byte("Everybody to the Limit"), + }, + }, + } + + is := assert.New(t) + data, err := json.Marshal(chrt) + if err != nil { + t.Fatal(err) + } + + res := &Chart{} + if err := json.Unmarshal(data, res); err != nil { + t.Fatal(err) + } + + is.Equal([]*File(nil), res.Raw) +} diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index f04c0e9b3..3c38519bc 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -74,6 +74,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { subcharts := make(map[string][]*BufferedFile) for _, f := range files { + c.Raw = append(c.Raw, &chart.File{Name: f.Name, Data: f.Data}) switch { case f.Name == "Chart.yaml": if c.Metadata == nil { diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index 96b4dc608..6576002eb 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -179,6 +179,10 @@ icon: https://example.com/64x64.png t.Error("Expected chart values to be populated with default values") } + if len(c.Raw) != 5 { + t.Errorf("Expected %d files, got %d", 5, len(c.Raw)) + } + if !bytes.Equal(c.Schema, []byte("type: Values")) { t.Error("Expected chart schema to be populated with default values") } From 3e09e2fa2831ab0b51678171b7934cf9e6b4f8a7 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 6 Nov 2019 09:36:29 -0500 Subject: [PATCH 054/279] fix(cli): Sort output of helm env Before this change, running 'helm env' multiple times would generate a different order for the output each time. This is because Go purposely loops over hash maps in a random order. This commit sorts the environment variables by alphabetical order before generating the output. Signed-off-by: Marc Khouzam --- cmd/helm/env.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/helm/env.go b/cmd/helm/env.go index 1b9cb4012..2687272ba 100644 --- a/cmd/helm/env.go +++ b/cmd/helm/env.go @@ -19,6 +19,7 @@ package main import ( "fmt" "io" + "sort" "helm.sh/helm/v3/pkg/cli" @@ -55,8 +56,18 @@ type envOptions struct { } func (o *envOptions) run(out io.Writer) error { - for k, v := range o.settings.EnvVars() { - fmt.Printf("%s=\"%s\"\n", k, v) + envVars := o.settings.EnvVars() + + // Sort the variables by alphabetical order. + // This allows for a constant output across calls to 'helm env'. + var keys []string + for k := range envVars { + keys = append(keys, k) + } + sort.Strings(keys) + + for _, k := range keys { + fmt.Printf("%s=\"%s\"\n", k, envVars[k]) } return nil } From 8231b17c319c872687521cf4555e845afac00b96 Mon Sep 17 00:00:00 2001 From: Marc Brugger Date: Thu, 7 Nov 2019 16:30:01 +0100 Subject: [PATCH 055/279] print gvk information on existing resource conflict Signed-off-by: Marc Brugger --- pkg/action/validate.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/action/validate.go b/pkg/action/validate.go index 526a4c7fc..30a1d1197 100644 --- a/pkg/action/validate.go +++ b/pkg/action/validate.go @@ -33,7 +33,8 @@ func existingResourceConflict(resources kube.ResourceList) error { } helper := resource.NewHelper(info.Client, info.Mapping) - if _, err := helper.Get(info.Namespace, info.Name, info.Export); err != nil { + existing, err := helper.Get(info.Namespace, info.Name, info.Export) + if err != nil { if apierrors.IsNotFound(err) { return nil } @@ -41,7 +42,7 @@ func existingResourceConflict(resources kube.ResourceList) error { return errors.Wrap(err, "could not get information about the resource") } - return fmt.Errorf("existing resource conflict: kind: %s, namespace: %s, name: %s", info.Mapping.GroupVersionKind.Kind, info.Namespace, info.Name) + return fmt.Errorf("existing resource conflict: namespace: %s, name: %s, existing: [gvk: %s, ] / new: [gvk: %s]", info.Namespace, info.Name, existing.GetObjectKind().GroupVersionKind(), info.Mapping.GroupVersionKind) }) return err } From 865c46c014cdb7622f97ae287ee92fb8a280f3a9 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 7 Nov 2019 16:16:36 -0700 Subject: [PATCH 056/279] fix: stop discovery errors from halting chart rendering. (#6908) This blocks a particular error (caused by upstream discovery client), printing a warning instead of failing. It's not a great solution, but is a stop-gap until Client-Go gets fixed. Closes #6361 Signed-off-by: Matt Butcher --- pkg/action/action.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 48d6bf742..f74a25e41 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -109,9 +109,19 @@ func (c *Configuration) getCapabilities() (*chartutil.Capabilities, error) { if err != nil { return nil, errors.Wrap(err, "could not get server version from Kubernetes") } + // Issue #6361: + // Client-Go emits an error when an API service is registered but unimplemented. + // We trap that error here and print a warning. But since the discovery client continues + // building the API object, it is correctly populated with all valid APIs. + // See https://github.com/kubernetes/kubernetes/issues/72051#issuecomment-521157642 apiVersions, err := GetVersionSet(dc) if err != nil { - return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") + if discovery.IsGroupDiscoveryFailedError(err) { + c.Log("WARNING: The Kubernetes server has an orphaned API service. Server reports: %s", err) + c.Log("WARNING: To fix this, kubectl delete apiservice ") + } else { + return nil, errors.Wrap(err, "could not get apiVersions from Kubernetes") + } } c.Capabilities = &chartutil.Capabilities{ From aa6104e442ef8b574ae88efd8b5c41004437ac88 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 8 Nov 2019 07:32:50 -0800 Subject: [PATCH 057/279] fix(tlsutil): accept only a CA certificate for validation Signed-off-by: Matthew Fisher --- internal/tlsutil/tls.go | 16 ++++++---- internal/tlsutil/tlsutil_test.go | 51 ++++++++++++++++++++++++++++++++ pkg/getter/httpgetter.go | 2 +- pkg/getter/httpgetter_test.go | 10 +++++++ 4 files changed, 72 insertions(+), 7 deletions(-) diff --git a/internal/tlsutil/tls.go b/internal/tlsutil/tls.go index dc123e1e5..ed7795dbe 100644 --- a/internal/tlsutil/tls.go +++ b/internal/tlsutil/tls.go @@ -26,13 +26,16 @@ import ( // NewClientTLS returns tls.Config appropriate for client auth. func NewClientTLS(certFile, keyFile, caFile string) (*tls.Config, error) { - cert, err := CertFromFilePair(certFile, keyFile) - if err != nil { - return nil, err - } - config := tls.Config{ - Certificates: []tls.Certificate{*cert}, + config := tls.Config{} + + if certFile != "" && keyFile != "" { + cert, err := CertFromFilePair(certFile, keyFile) + if err != nil { + return nil, err + } + config.Certificates = []tls.Certificate{*cert} } + if caFile != "" { cp, err := CertPoolFromFile(caFile) if err != nil { @@ -40,6 +43,7 @@ func NewClientTLS(certFile, keyFile, caFile string) (*tls.Config, error) { } config.RootCAs = cp } + return &config, nil } diff --git a/internal/tlsutil/tlsutil_test.go b/internal/tlsutil/tlsutil_test.go index c2a477272..a737226fd 100644 --- a/internal/tlsutil/tlsutil_test.go +++ b/internal/tlsutil/tlsutil_test.go @@ -81,3 +81,54 @@ func testfile(t *testing.T, file string) (path string) { } return path } + +func TestNewClientTLS(t *testing.T) { + certFile := testfile(t, testCertFile) + keyFile := testfile(t, testKeyFile) + caCertFile := testfile(t, testCaCertFile) + + cfg, err := NewClientTLS(certFile, keyFile, caCertFile) + if err != nil { + t.Error(err) + } + + if got := len(cfg.Certificates); got != 1 { + t.Fatalf("expecting 1 client certificates, got %d", got) + } + if cfg.InsecureSkipVerify { + t.Fatalf("insecure skip verify mistmatch, expecting false") + } + if cfg.RootCAs == nil { + t.Fatalf("mismatch tls RootCAs, expecting non-nil") + } + + cfg, err = NewClientTLS("", "", caCertFile) + if err != nil { + t.Error(err) + } + + if got := len(cfg.Certificates); got != 0 { + t.Fatalf("expecting 0 client certificates, got %d", got) + } + if cfg.InsecureSkipVerify { + t.Fatalf("insecure skip verify mistmatch, expecting false") + } + if cfg.RootCAs == nil { + t.Fatalf("mismatch tls RootCAs, expecting non-nil") + } + + cfg, err = NewClientTLS(certFile, keyFile, "") + if err != nil { + t.Error(err) + } + + if got := len(cfg.Certificates); got != 1 { + t.Fatalf("expecting 1 client certificates, got %d", got) + } + if cfg.InsecureSkipVerify { + t.Fatalf("insecure skip verify mistmatch, expecting false") + } + if cfg.RootCAs != nil { + t.Fatalf("mismatch tls RootCAs, expecting nil") + } +} diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index a36ab0321..89abfb1cf 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -89,7 +89,7 @@ func NewHTTPGetter(options ...Option) (Getter, error) { } func (g *HTTPGetter) httpClient() (*http.Client, error) { - if g.opts.certFile != "" && g.opts.keyFile != "" { + if (g.opts.certFile != "" && g.opts.keyFile != "") || g.opts.caFile != "" { tlsConf, err := tlsutil.NewClientTLS(g.opts.certFile, g.opts.keyFile, g.opts.caFile) if err != nil { return nil, errors.Wrap(err, "can't create TLS config for client") diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 0c2c55ea3..b20085574 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -180,4 +180,14 @@ func TestDownloadTLS(t *testing.T) { if _, err := g.Get(u.String(), WithURL(u.String()), WithTLSClientConfig(pub, priv, ca)); err != nil { t.Error(err) } + + // test with only the CA file (see also #6635) + g, err = NewHTTPGetter() + if err != nil { + t.Fatal(err) + } + + if _, err := g.Get(u.String(), WithURL(u.String()), WithTLSClientConfig("", "", ca)); err != nil { + t.Error(err) + } } From 9ed2a28eded7678ccc26f2079fa815eefb489683 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 8 Nov 2019 07:39:57 -0800 Subject: [PATCH 058/279] ref(tlsutil): remove ServerConfig dead code from Tiller days Signed-off-by: Matthew Fisher --- internal/tlsutil/cfg.go | 29 ++--------------------------- internal/tlsutil/tlsutil_test.go | 21 --------------------- 2 files changed, 2 insertions(+), 48 deletions(-) diff --git a/internal/tlsutil/cfg.go b/internal/tlsutil/cfg.go index f40258739..8b9d4329f 100644 --- a/internal/tlsutil/cfg.go +++ b/internal/tlsutil/cfg.go @@ -27,18 +27,14 @@ import ( // Options represents configurable options used to create client and server TLS configurations. type Options struct { CaCertFile string - // If either the KeyFile or CertFile is empty, ClientConfig() will not load them, - // preventing Helm from authenticating to Tiller. They are required to be non-empty - // when calling ServerConfig, otherwise an error is returned. + // If either the KeyFile or CertFile is empty, ClientConfig() will not load them. KeyFile string CertFile string // Client-only options InsecureSkipVerify bool - // Server-only options - ClientAuth tls.ClientAuthType } -// ClientConfig retusn a TLS configuration for use by a Helm client. +// ClientConfig returns a TLS configuration for use by a Helm client. func ClientConfig(opts Options) (cfg *tls.Config, err error) { var cert *tls.Certificate var pool *x509.CertPool @@ -60,24 +56,3 @@ func ClientConfig(opts Options) (cfg *tls.Config, err error) { cfg = &tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify, Certificates: []tls.Certificate{*cert}, RootCAs: pool} return cfg, nil } - -// ServerConfig returns a TLS configuration for use by the Tiller server. -func ServerConfig(opts Options) (cfg *tls.Config, err error) { - var cert *tls.Certificate - var pool *x509.CertPool - - if cert, err = CertFromFilePair(opts.CertFile, opts.KeyFile); err != nil { - if os.IsNotExist(err) { - return nil, errors.Wrapf(err, "could not load x509 key pair (cert: %q, key: %q)", opts.CertFile, opts.KeyFile) - } - return nil, errors.Wrapf(err, "could not read x509 key pair (cert: %q, key: %q)", opts.CertFile, opts.KeyFile) - } - if opts.ClientAuth >= tls.VerifyClientCertIfGiven && opts.CaCertFile != "" { - if pool, err = CertPoolFromFile(opts.CaCertFile); err != nil { - return nil, err - } - } - - cfg = &tls.Config{MinVersion: tls.VersionTLS12, ClientAuth: opts.ClientAuth, Certificates: []tls.Certificate{*cert}, ClientCAs: pool} - return cfg, nil -} diff --git a/internal/tlsutil/tlsutil_test.go b/internal/tlsutil/tlsutil_test.go index c2a477272..811d64aa0 100644 --- a/internal/tlsutil/tlsutil_test.go +++ b/internal/tlsutil/tlsutil_test.go @@ -17,7 +17,6 @@ limitations under the License. package tlsutil import ( - "crypto/tls" "path/filepath" "testing" ) @@ -54,26 +53,6 @@ func TestClientConfig(t *testing.T) { } } -func TestServerConfig(t *testing.T) { - opts := Options{ - CaCertFile: testfile(t, testCaCertFile), - CertFile: testfile(t, testCertFile), - KeyFile: testfile(t, testKeyFile), - ClientAuth: tls.RequireAndVerifyClientCert, - } - - cfg, err := ServerConfig(opts) - if err != nil { - t.Fatalf("error building tls server config: %v", err) - } - if got := cfg.MinVersion; got != tls.VersionTLS12 { - t.Errorf("expecting TLS version 1.2, got %d", got) - } - if got := cfg.ClientCAs; got == nil { - t.Errorf("expecting non-nil CA pool") - } -} - func testfile(t *testing.T, file string) (path string) { var err error if path, err = filepath.Abs(filepath.Join(tlsTestDir, file)); err != nil { From 30e8ed2f3df9e776b5a5937d92e8ff45c54f984f Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 8 Nov 2019 17:22:47 -0500 Subject: [PATCH 059/279] fix(cli): helm list was ignoring some errors If the cluster is not reachable, helm list would not report that error. Signed-off-by: Marc Khouzam --- cmd/helm/list.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 32501530d..83edfe156 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -77,12 +77,15 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client.SetStateMask() results, err := client.Run() + if err != nil { + return err + } if client.Short { for _, res := range results { fmt.Fprintln(out, res.Name) } - return err + return nil } return outfmt.Write(out, newReleaseListWriter(results)) From 693bce93a073d1086f86cb119f96b306bbb2bc80 Mon Sep 17 00:00:00 2001 From: sayboras Date: Sat, 9 Nov 2019 19:56:45 +1100 Subject: [PATCH 060/279] Used timeout instead of deadline Signed-off-by: sayboras --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 601d98661..2c3b6234d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - deadline: 2m + timeout: 2m linters: disable-all: true From 4d1c11f05bf732bf914d5529493fc77d5134d1c9 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 12 Nov 2019 09:36:08 -0800 Subject: [PATCH 061/279] fix(ci): pin golangci-lint to v1.21.0 Signed-off-by: Matthew Fisher --- .circleci/bootstrap.sh | 20 ++++++++++++++++++++ .circleci/config.yml | 4 ++++ Makefile | 8 ++------ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100755 .circleci/bootstrap.sh diff --git a/.circleci/bootstrap.sh b/.circleci/bootstrap.sh new file mode 100755 index 000000000..79d194077 --- /dev/null +++ b/.circleci/bootstrap.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -euo pipefail + +curl -sSL https://github.com/golangci/golangci-lint/releases/download/v$GOLANGCI_LINT_VERSION/golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64.tar.gz | tar xz +sudo mv golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64/golangci-lint /usr/local/bin/golangci-lint +rm -rf golangci-lint-$GOLANGCI_LINT_VERSION-linux-amd64 diff --git a/.circleci/config.yml b/.circleci/config.yml index db7182adb..ef19b8ee7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,9 +9,13 @@ jobs: environment: GOCACHE: "/tmp/go/cache" + GOLANGCI_LINT_VERSION: "1.21.0" steps: - checkout + - run: + name: install test dependencies + command: .circleci/bootstrap.sh - run: name: test style command: make test-style diff --git a/Makefile b/Makefile index b52464ba9..e48a20fd5 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ GOPATH = $(shell go env GOPATH) DEP = $(GOPATH)/bin/dep GOX = $(GOPATH)/bin/gox GOIMPORTS = $(GOPATH)/bin/goimports -GOLANGCI_LINT = $(GOPATH)/bin/golangci-lint ACCEPTANCE_DIR:=$(GOPATH)/src/helm.sh/acceptance-testing # To specify the subset of acceptance tests to run. '.' means all tests @@ -81,8 +80,8 @@ test-coverage: @ ./scripts/coverage.sh .PHONY: test-style -test-style: $(GOLANGCI_LINT) - GO111MODULE=on $(GOLANGCI_LINT) run +test-style: + GO111MODULE=on golangci-lint run @scripts/validate-license.sh .PHONY: test-acceptance @@ -118,9 +117,6 @@ format: $(GOIMPORTS) $(GOX): (cd /; GO111MODULE=on go get -u github.com/mitchellh/gox) -$(GOLANGCI_LINT): - (cd /; GO111MODULE=on go get -u github.com/golangci/golangci-lint/cmd/golangci-lint) - $(GOIMPORTS): (cd /; GO111MODULE=on go get -u golang.org/x/tools/cmd/goimports) From b30467c2e52ffebd0b4708ca318d34251ab5a692 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 12 Nov 2019 08:34:58 -0800 Subject: [PATCH 062/279] fix(strvals): port #3912, #4142, #4682, and #5151 to Helm 3 Signed-off-by: Matthew Fisher --- pkg/strvals/parser.go | 30 ++++++++++-- pkg/strvals/parser_test.go | 95 +++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 6 deletions(-) diff --git a/pkg/strvals/parser.go b/pkg/strvals/parser.go index eaadbfb07..03adbd3cb 100644 --- a/pkg/strvals/parser.go +++ b/pkg/strvals/parser.go @@ -84,7 +84,7 @@ func ParseFile(s string, reader RunesValueReader) (map[string]interface{}, error return vals, err } -// ParseIntoString parses a strvals line nad merges the result into dest. +// ParseIntoString parses a strvals line and merges the result into dest. // // This method always returns a string as the value. func ParseIntoString(s string, dest map[string]interface{}) error { @@ -108,6 +108,9 @@ type RunesValueReader func([]rune) (interface{}, error) // parser is a simple parser that takes a strvals line and parses it into a // map representation. +// +// where sc is the source of the original data being parsed +// where data is the final parsed data from the parses with correct types type parser struct { sc *bytes.Buffer data map[string]interface{} @@ -285,7 +288,13 @@ func (t *parser) listItem(list []interface{}, i int) ([]interface{}, error) { // We have a nested object. Send to t.key inner := map[string]interface{}{} if len(list) > i { - inner = list[i].(map[string]interface{}) + var ok bool + inner, ok = list[i].(map[string]interface{}) + if !ok { + // We have indices out of order. Initialize empty value. + list[i] = map[string]interface{}{} + inner = list[i].(map[string]interface{}) + } } // Recurse @@ -367,6 +376,11 @@ func inMap(k rune, m map[rune]bool) bool { func typedVal(v []rune, st bool) interface{} { val := string(v) + + if st { + return val + } + if strings.EqualFold(val, "true") { return true } @@ -375,8 +389,16 @@ func typedVal(v []rune, st bool) interface{} { return false } - // If this value does not start with zero, and not returnString, try parsing it to an int - if !st && len(val) != 0 && val[0] != '0' { + if strings.EqualFold(val, "null") { + return nil + } + + if strings.EqualFold(val, "0") { + return int64(0) + } + + // If this value does not start with zero, try parsing it to an int + if len(val) != 0 && val[0] != '0' { if iv, err := strconv.ParseInt(val, 10, 64); err == nil { return iv } diff --git a/pkg/strvals/parser_test.go b/pkg/strvals/parser_test.go index ff8d58587..7f38efa52 100644 --- a/pkg/strvals/parser_test.go +++ b/pkg/strvals/parser_test.go @@ -75,12 +75,32 @@ func TestParseSet(t *testing.T) { expect: map[string]interface{}{"long_int_string": "1234567890"}, err: false, }, + { + str: "boolean=true", + expect: map[string]interface{}{"boolean": "true"}, + err: false, + }, + { + str: "is_null=null", + expect: map[string]interface{}{"is_null": "null"}, + err: false, + }, + { + str: "zero=0", + expect: map[string]interface{}{"zero": "0"}, + err: false, + }, } tests := []struct { str string expect map[string]interface{} err bool }{ + { + "name1=null,f=false,t=true", + map[string]interface{}{"name1": nil, "f": false, "t": true}, + false, + }, { "name1=value1", map[string]interface{}{"name1": "value1"}, @@ -108,10 +128,23 @@ func TestParseSet(t *testing.T) { str: "leading_zeros=00009", expect: map[string]interface{}{"leading_zeros": "00009"}, }, + { + str: "zero_int=0", + expect: map[string]interface{}{"zero_int": 0}, + }, { str: "long_int=1234567890", expect: map[string]interface{}{"long_int": 1234567890}, }, + { + str: "boolean=true", + expect: map[string]interface{}{"boolean": true}, + }, + { + str: "is_null=null", + expect: map[string]interface{}{"is_null": nil}, + err: false, + }, { str: "name1,name2=", err: true, @@ -270,6 +303,30 @@ func TestParseSet(t *testing.T) { str: "nested[1][1]=1", expect: map[string]interface{}{"nested": []interface{}{nil, []interface{}{nil, 1}}}, }, + { + str: "name1.name2[0].foo=bar,name1.name2[1].foo=bar", + expect: map[string]interface{}{ + "name1": map[string]interface{}{ + "name2": []map[string]interface{}{{"foo": "bar"}, {"foo": "bar"}}, + }, + }, + }, + { + str: "name1.name2[1].foo=bar,name1.name2[0].foo=bar", + expect: map[string]interface{}{ + "name1": map[string]interface{}{ + "name2": []map[string]interface{}{{"foo": "bar"}, {"foo": "bar"}}, + }, + }, + }, + { + str: "name1.name2[1].foo=bar", + expect: map[string]interface{}{ + "name1": map[string]interface{}{ + "name2": []map[string]interface{}{nil, {"foo": "bar"}}, + }, + }, + }, } for _, tt := range tests { @@ -331,12 +388,13 @@ func TestParseInto(t *testing.T) { "inner2": "value2", }, } - input := "outer.inner1=value1,outer.inner3=value3" + input := "outer.inner1=value1,outer.inner3=value3,outer.inner4=4" expect := map[string]interface{}{ "outer": map[string]interface{}{ "inner1": "value1", "inner2": "value2", "inner3": "value3", + "inner4": 4, }, } @@ -357,6 +415,39 @@ func TestParseInto(t *testing.T) { t.Errorf("%s: Expected:\n%s\nGot:\n%s", input, y1, y2) } } +func TestParseIntoString(t *testing.T) { + got := map[string]interface{}{ + "outer": map[string]interface{}{ + "inner1": "overwrite", + "inner2": "value2", + }, + } + input := "outer.inner1=1,outer.inner3=3" + expect := map[string]interface{}{ + "outer": map[string]interface{}{ + "inner1": "1", + "inner2": "value2", + "inner3": "3", + }, + } + + if err := ParseIntoString(input, got); err != nil { + t.Fatal(err) + } + + y1, err := yaml.Marshal(expect) + if err != nil { + t.Fatal(err) + } + y2, err := yaml.Marshal(got) + if err != nil { + t.Fatalf("Error serializing parsed value: %s", err) + } + + if string(y1) != string(y2) { + t.Errorf("%s: Expected:\n%s\nGot:\n%s", input, y1, y2) + } +} func TestParseIntoFile(t *testing.T) { got := map[string]interface{}{} @@ -367,7 +458,7 @@ func TestParseIntoFile(t *testing.T) { rs2v := func(rs []rune) (interface{}, error) { v := string(rs) if v != "path1" { - t.Errorf("%s: RunesValueReader: Expected value path1, got %s", input, v) + t.Errorf("%s: runesToVal: Expected value path1, got %s", input, v) return "", nil } return "value1", nil From 17553db485f6165c15aa17c6dfcc7589edb025ee Mon Sep 17 00:00:00 2001 From: Hang Park Date: Wed, 13 Nov 2019 02:33:27 +0900 Subject: [PATCH 063/279] fix(pkg/downloader): add failing test for build with repo alias Signed-off-by: Hang Park --- pkg/downloader/manager_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index 0c5c08615..d6cae4e51 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -181,7 +181,8 @@ func TestGetRepoNames(t *testing.T) { } } -// This function is the skeleton test code of failing tests for #6416 and bugs due to #5874. +// This function is the skeleton test code of failing tests for #6416 and #6871 and bugs due to #5874. +// // This function is used by below tests that ensures success of build operation // with optional fields, alias, condition, tags, and even with ranged version. // Parent chart includes local-subchart 0.1.0 subchart from a fake repository, by default. @@ -283,3 +284,11 @@ func TestBuild_WithTags(t *testing.T) { Tags: []string{"tag1", "tag2"}, }) } + +// Failing test for #6871 +func TestBuild_WithRepositoryAlias(t *testing.T) { + // Dependency repository is aliased in Chart.yaml + checkBuildWithOptionalFields(t, "with-repository-alias", chart.Dependency{ + Repository: "@test", + }) +} From 0987c6f7b91bffc360a8c604b9dfb87b845cc919 Mon Sep 17 00:00:00 2001 From: Hang Park Date: Wed, 13 Nov 2019 02:35:48 +0900 Subject: [PATCH 064/279] fix(pkg/downloader): resolve repo alias before checking digests on build `Update()` gets repo names before resolving a lock file by calling `resolveRepoNames(req)`. But that method changes aliased repo URLs into the actual URLs. That makes digests from `helm update` and `helm build` be different for each other. To make them in sync, setting actual (resolved) repo URLs into the loaded chart during `helm build` is necessary. Thus, this commit adds an extra step in the `Build()` implementation. For comments, this commit also changes the name of `getRepoNames()` into `resolveRepoNames()` to avoid misunderstanding since getters are expected to not mutate their input data in general. Signed-off-by: Hang Park --- pkg/downloader/manager.go | 12 +++++++++--- pkg/downloader/manager_test.go | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 407e7ffe4..4e9d691d8 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -79,7 +79,12 @@ func (m *Manager) Build() error { return m.Update() } + // Check that all of the repos we're dependent on actually exist. req := c.Metadata.Dependencies + if _, err := m.resolveRepoNames(req); err != nil { + return err + } + if sum, err := resolver.HashReq(req, lock.Dependencies); err != nil || sum != lock.Digest { return errors.New("Chart.lock is out of sync with Chart.yaml") } @@ -120,7 +125,7 @@ func (m *Manager) Update() error { // Check that all of the repos we're dependent on actually exist and // the repo index names. - repoNames, err := m.getRepoNames(req) + repoNames, err := m.resolveRepoNames(req) if err != nil { return err } @@ -372,8 +377,9 @@ Loop: return nil } -// getRepoNames returns the repo names of the referenced deps which can be used to fetch the cahced index file. -func (m *Manager) getRepoNames(deps []*chart.Dependency) (map[string]string, error) { +// resolveRepoNames returns the repo names of the referenced deps which can be used to fetch the cached index file +// and replaces aliased repository URLs into resolved URLs in dependencies. +func (m *Manager) resolveRepoNames(deps []*chart.Dependency) (map[string]string, error) { rf, err := loadRepoConfig(m.RepositoryConfig) if err != nil { if os.IsNotExist(err) { diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index d6cae4e51..6e32b3e85 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -161,7 +161,7 @@ func TestGetRepoNames(t *testing.T) { } for _, tt := range tests { - l, err := m.getRepoNames(tt.req) + l, err := m.resolveRepoNames(tt.req) if err != nil { if tt.err { continue From e91feed1a3c34ec15ff2bff4d07ee5e275a6d7b4 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 12 Nov 2019 13:12:45 -0800 Subject: [PATCH 065/279] fix(install): log the error when recording the release Signed-off-by: Matthew Fisher --- pkg/action/install.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 8f1b5528b..65c10f636 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -301,7 +301,9 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. // // One possible strategy would be to do a timed retry to see if we can get // this stored in the future. - i.recordRelease(rel) + if err := i.recordRelease(rel); err != nil { + i.cfg.Log("failed to record the release: %s", err) + } return rel, nil } From a9b178758c6c3c3f36f6bbd7a1b4359efae27366 Mon Sep 17 00:00:00 2001 From: flynnduism Date: Tue, 12 Nov 2019 14:27:30 -0800 Subject: [PATCH 066/279] fix(reame): update links to docs Signed-off-by: flynnduism --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9af358e10..fbabf7e44 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,12 @@ If you want to use a package manager: To rapidly get Helm up and running, start with the [Quick Start Guide](https://docs.helm.sh/using_helm/#quickstart-guide). -See the [installation guide](https://docs.helm.sh/using_helm/#installing-helm) for more options, +See the [installation guide](https://helm.sh/docs/intro/install/) for more options, including installing pre-releases. ## Docs -Get started with the [Quick Start guide](https://docs.helm.sh/using_helm/#quickstart-guide) or plunge into the [complete documentation](https://docs.helm.sh) +Get started with the [Quick Start guide](https://helm.sh/docs/intro/quickstart/) or plunge into the [complete documentation](https://helm.sh/docs) ## Roadmap From 06a5eb2272f26fcdb2bd5abf5abe45d7078b5e50 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 12 Nov 2019 18:11:56 -0800 Subject: [PATCH 067/279] fix(get): install Helm v2.16.1 This is a temporary fix. This prevents the get script from installing Helm 3 as soon as it's released, potentially causing disruption to users that were expecting a Helm 2 release. A `get-helm-3` script is also supplied, which is identical to the previous `get` script. That way, Helm 3 users also have an equivalent way to install Helm 3. Signed-off-by: Matthew Fisher --- scripts/get | 6 +- scripts/get-helm-3 | 245 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 2 deletions(-) create mode 100755 scripts/get-helm-3 diff --git a/scripts/get b/scripts/get index 3f645f807..a264f8f76 100755 --- a/scripts/get +++ b/scripts/get @@ -187,7 +187,7 @@ testVersion() { help () { echo "Accepted cli arguments are:" echo -e "\t[--help|-h ] ->> prints this help" - echo -e "\t[--version|-v ] . When not defined it defaults to latest" + echo -e "\t[--version|-v ]" echo -e "\te.g. --version v2.4.0 or -v latest" echo -e "\t[--no-sudo] ->> install without sudo" } @@ -213,7 +213,9 @@ while [[ $# -gt 0 ]]; do '--version'|-v) shift if [[ $# -ne 0 ]]; then - export DESIRED_VERSION="${1}" + # FIXME(bacongobbler): hard code the desired version for the time being. + # A better fix would be to filter for Helm 2 release pages. + export DESIRED_VERSION="${1:="v2.16.1"}" else echo -e "Please provide the desired version. e.g. --version v2.4.0 or -v latest" exit 0 diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 new file mode 100755 index 000000000..3f645f807 --- /dev/null +++ b/scripts/get-helm-3 @@ -0,0 +1,245 @@ +#!/usr/bin/env bash + +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The install script is based off of the MIT-licensed script from glide, +# the package manager for Go: https://github.com/Masterminds/glide.sh/blob/master/get + +PROJECT_NAME="helm" +TILLER_NAME="tiller" + +: ${USE_SUDO:="true"} +: ${HELM_INSTALL_DIR:="/usr/local/bin"} + +# initArch discovers the architecture for this system. +initArch() { + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5";; + armv6*) ARCH="armv6";; + armv7*) ARCH="arm";; + aarch64) ARCH="arm64";; + x86) ARCH="386";; + x86_64) ARCH="amd64";; + i686) ARCH="386";; + i386) ARCH="386";; + esac +} + +# initOS discovers the operating system for this system. +initOS() { + OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') + + case "$OS" in + # Minimalist GNU for Windows + mingw*) OS='windows';; + esac +} + +# runs the given command as root (detects if we are root already) +runAsRoot() { + local CMD="$*" + + if [ $EUID -ne 0 -a $USE_SUDO = "true" ]; then + CMD="sudo $CMD" + fi + + $CMD +} + +# verifySupported checks that the os/arch combination is supported for +# binary builds. +verifySupported() { + local supported="darwin-386\ndarwin-amd64\nlinux-386\nlinux-amd64\nlinux-arm\nlinux-arm64\nlinux-ppc64le\nwindows-386\nwindows-amd64" + if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then + echo "No prebuilt binary for ${OS}-${ARCH}." + echo "To build from source, go to https://github.com/helm/helm" + exit 1 + fi + + if ! type "curl" > /dev/null && ! type "wget" > /dev/null; then + echo "Either curl or wget is required" + exit 1 + fi +} + +# checkDesiredVersion checks if the desired version is available. +checkDesiredVersion() { + if [ "x$DESIRED_VERSION" == "x" ]; then + # Get tag from release URL + local latest_release_url="https://github.com/helm/helm/releases/latest" + if type "curl" > /dev/null; then + TAG=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) + elif type "wget" > /dev/null; then + TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") + fi + else + TAG=$DESIRED_VERSION + fi +} + +# checkHelmInstalledVersion checks which version of helm is installed and +# if it needs to be changed. +checkHelmInstalledVersion() { + if [[ -f "${HELM_INSTALL_DIR}/${PROJECT_NAME}" ]]; then + local version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version -c | grep '^Client' | cut -d'"' -f2) + if [[ "$version" == "$TAG" ]]; then + echo "Helm ${version} is already ${DESIRED_VERSION:-latest}" + return 0 + else + echo "Helm ${TAG} is available. Changing from version ${version}." + return 1 + fi + else + return 1 + fi +} + +# downloadFile downloads the latest binary package and also the checksum +# for that binary. +downloadFile() { + HELM_DIST="helm-$TAG-$OS-$ARCH.tar.gz" + DOWNLOAD_URL="https://get.helm.sh/$HELM_DIST" + CHECKSUM_URL="$DOWNLOAD_URL.sha256" + HELM_TMP_ROOT="$(mktemp -dt helm-installer-XXXXXX)" + HELM_TMP_FILE="$HELM_TMP_ROOT/$HELM_DIST" + HELM_SUM_FILE="$HELM_TMP_ROOT/$HELM_DIST.sha256" + echo "Downloading $DOWNLOAD_URL" + if type "curl" > /dev/null; then + curl -SsL "$CHECKSUM_URL" -o "$HELM_SUM_FILE" + elif type "wget" > /dev/null; then + wget -q -O "$HELM_SUM_FILE" "$CHECKSUM_URL" + fi + if type "curl" > /dev/null; then + curl -SsL "$DOWNLOAD_URL" -o "$HELM_TMP_FILE" + elif type "wget" > /dev/null; then + wget -q -O "$HELM_TMP_FILE" "$DOWNLOAD_URL" + fi +} + +# installFile verifies the SHA256 for the file, then unpacks and +# installs it. +installFile() { + HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" + local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') + local expected_sum=$(cat ${HELM_SUM_FILE}) + if [ "$sum" != "$expected_sum" ]; then + echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." + exit 1 + fi + + mkdir -p "$HELM_TMP" + tar xf "$HELM_TMP_FILE" -C "$HELM_TMP" + HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME" + TILLER_TMP_BIN="$HELM_TMP/$OS-$ARCH/$TILLER_NAME" + echo "Preparing to install $PROJECT_NAME and $TILLER_NAME into ${HELM_INSTALL_DIR}" + runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR" + echo "$PROJECT_NAME installed into $HELM_INSTALL_DIR/$PROJECT_NAME" + if [ -x "$TILLER_TMP_BIN" ]; then + runAsRoot cp "$TILLER_TMP_BIN" "$HELM_INSTALL_DIR" + echo "$TILLER_NAME installed into $HELM_INSTALL_DIR/$TILLER_NAME" + else + echo "info: $TILLER_NAME binary was not found in this release; skipping $TILLER_NAME installation" + fi +} + +# fail_trap is executed if an error occurs. +fail_trap() { + result=$? + if [ "$result" != "0" ]; then + if [[ -n "$INPUT_ARGUMENTS" ]]; then + echo "Failed to install $PROJECT_NAME with the arguments provided: $INPUT_ARGUMENTS" + help + else + echo "Failed to install $PROJECT_NAME" + fi + echo -e "\tFor support, go to https://github.com/helm/helm." + fi + cleanup + exit $result +} + +# testVersion tests the installed client to make sure it is working. +testVersion() { + set +e + HELM="$(which $PROJECT_NAME)" + if [ "$?" = "1" ]; then + echo "$PROJECT_NAME not found. Is $HELM_INSTALL_DIR on your "'$PATH?' + exit 1 + fi + set -e + echo "Run '$PROJECT_NAME init' to configure $PROJECT_NAME." +} + +# help provides possible cli installation arguments +help () { + echo "Accepted cli arguments are:" + echo -e "\t[--help|-h ] ->> prints this help" + echo -e "\t[--version|-v ] . When not defined it defaults to latest" + echo -e "\te.g. --version v2.4.0 or -v latest" + echo -e "\t[--no-sudo] ->> install without sudo" +} + +# cleanup temporary files to avoid https://github.com/helm/helm/issues/2977 +cleanup() { + if [[ -d "${HELM_TMP_ROOT:-}" ]]; then + rm -rf "$HELM_TMP_ROOT" + fi +} + +# Execution + +#Stop execution on any error +trap "fail_trap" EXIT +set -e + +# Parsing input arguments (if any) +export INPUT_ARGUMENTS="${@}" +set -u +while [[ $# -gt 0 ]]; do + case $1 in + '--version'|-v) + shift + if [[ $# -ne 0 ]]; then + export DESIRED_VERSION="${1}" + else + echo -e "Please provide the desired version. e.g. --version v2.4.0 or -v latest" + exit 0 + fi + ;; + '--no-sudo') + USE_SUDO="false" + ;; + '--help'|-h) + help + exit 0 + ;; + *) exit 1 + ;; + esac + shift +done +set +u + +initArch +initOS +verifySupported +checkDesiredVersion +if ! checkHelmInstalledVersion; then + downloadFile + installFile +fi +testVersion +cleanup From ecb55c1de7bcc0063b2cf956a0e2172fcd75bc59 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Tue, 12 Nov 2019 19:41:01 -0700 Subject: [PATCH 068/279] fix(wait): Adds support for waiting on v1 apiextensions for CRDs This was a missed update when we updated the k8s libraries. I validated that this works for CRD installs with v1beta1 and v1 Signed-off-by: Taylor Thomas --- pkg/action/install.go | 2 +- pkg/kube/wait.go | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 8f1b5528b..4019dbc54 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -126,7 +126,7 @@ func (i *Install) installCRDs(crds []*chart.File) error { i.cfg.Log("CRD %s is already present. Skipping.", crdName) continue } - return errors.Wrapf(err, "failed to instal CRD %s", obj.Name) + return errors.Wrapf(err, "failed to install CRD %s", obj.Name) } totalItems = append(totalItems, res...) } diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 7198917c4..f0005a61e 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -27,6 +27,7 @@ import ( batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" + apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -114,6 +115,17 @@ func (w *waiter) waitForResources(created ResourceList) error { if err := scheme.Scheme.Convert(v.Object, crd, nil); err != nil { return false, err } + if !w.crdBetaReady(*crd) { + return false, nil + } + case *apiextv1.CustomResourceDefinition: + if err := v.Get(); err != nil { + return false, err + } + crd := &apiextv1.CustomResourceDefinition{} + if err := scheme.Scheme.Convert(v.Object, crd, nil); err != nil { + return false, err + } if !w.crdReady(*crd) { return false, nil } @@ -229,7 +241,10 @@ func (w *waiter) daemonSetReady(ds *appsv1.DaemonSet) bool { return true } -func (w *waiter) crdReady(crd apiextv1beta1.CustomResourceDefinition) bool { +// Because the v1 extensions API is not available on all supported k8s versions +// yet and because Go doesn't support generics, we need to have a duplicate +// function to support the v1beta1 types +func (w *waiter) crdBetaReady(crd apiextv1beta1.CustomResourceDefinition) bool { for _, cond := range crd.Status.Conditions { switch cond.Type { case apiextv1beta1.Established: @@ -249,6 +264,26 @@ func (w *waiter) crdReady(crd apiextv1beta1.CustomResourceDefinition) bool { return false } +func (w *waiter) crdReady(crd apiextv1.CustomResourceDefinition) bool { + for _, cond := range crd.Status.Conditions { + switch cond.Type { + case apiextv1.Established: + if cond.Status == apiextv1.ConditionTrue { + return true + } + case apiextv1.NamesAccepted: + if cond.Status == apiextv1.ConditionFalse { + // This indicates a naming conflict, but it's probably not the + // job of this function to fail because of that. Instead, + // we treat it as a success, since the process should be able to + // continue. + return true + } + } + } + return false +} + func (w *waiter) statefulSetReady(sts *appsv1.StatefulSet) bool { // If the update strategy is not a rolling update, there will be nothing to wait for if sts.Spec.UpdateStrategy.Type != appsv1.RollingUpdateStatefulSetStrategyType { From 3e77ca22c71e182860b0ef9508d229e25d8f4140 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 12 Nov 2019 19:56:34 -0800 Subject: [PATCH 069/279] fix(get): hard code DESIRED_VERSION when unset Signed-off-by: Matthew Fisher --- scripts/get | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/get b/scripts/get index a264f8f76..711635ee3 100755 --- a/scripts/get +++ b/scripts/get @@ -78,13 +78,16 @@ verifySupported() { # checkDesiredVersion checks if the desired version is available. checkDesiredVersion() { if [ "x$DESIRED_VERSION" == "x" ]; then + # FIXME(bacongobbler): hard code the desired version for the time being. + # A better fix would be to filter for Helm 2 release pages. + TAG="v2.16.1" # Get tag from release URL - local latest_release_url="https://github.com/helm/helm/releases/latest" - if type "curl" > /dev/null; then - TAG=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) - elif type "wget" > /dev/null; then - TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") - fi + # local latest_release_url="https://github.com/helm/helm/releases/latest" + # if type "curl" > /dev/null; then + # TAG=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) + # elif type "wget" > /dev/null; then + # TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") + # fi else TAG=$DESIRED_VERSION fi @@ -213,9 +216,7 @@ while [[ $# -gt 0 ]]; do '--version'|-v) shift if [[ $# -ne 0 ]]; then - # FIXME(bacongobbler): hard code the desired version for the time being. - # A better fix would be to filter for Helm 2 release pages. - export DESIRED_VERSION="${1:="v2.16.1"}" + export DESIRED_VERSION="${1}" else echo -e "Please provide the desired version. e.g. --version v2.4.0 or -v latest" exit 0 From c9da1eaae780488ba34c7bb66c5bff518c6c06ee Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 12 Nov 2019 20:06:09 -0800 Subject: [PATCH 070/279] fix(get-helm-3): remove tiller checks, fixup version check Signed-off-by: Matthew Fisher --- scripts/get-helm-3 | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 index 3f645f807..c1655a68e 100755 --- a/scripts/get-helm-3 +++ b/scripts/get-helm-3 @@ -18,7 +18,6 @@ # the package manager for Go: https://github.com/Masterminds/glide.sh/blob/master/get PROJECT_NAME="helm" -TILLER_NAME="tiller" : ${USE_SUDO:="true"} : ${HELM_INSTALL_DIR:="/usr/local/bin"} @@ -94,7 +93,7 @@ checkDesiredVersion() { # if it needs to be changed. checkHelmInstalledVersion() { if [[ -f "${HELM_INSTALL_DIR}/${PROJECT_NAME}" ]]; then - local version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version -c | grep '^Client' | cut -d'"' -f2) + local version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version --template="{{ .Version }}") if [[ "$version" == "$TAG" ]]; then echo "Helm ${version} is already ${DESIRED_VERSION:-latest}" return 0 @@ -143,16 +142,9 @@ installFile() { mkdir -p "$HELM_TMP" tar xf "$HELM_TMP_FILE" -C "$HELM_TMP" HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME" - TILLER_TMP_BIN="$HELM_TMP/$OS-$ARCH/$TILLER_NAME" - echo "Preparing to install $PROJECT_NAME and $TILLER_NAME into ${HELM_INSTALL_DIR}" + echo "Preparing to install $PROJECT_NAME into ${HELM_INSTALL_DIR}" runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR" echo "$PROJECT_NAME installed into $HELM_INSTALL_DIR/$PROJECT_NAME" - if [ -x "$TILLER_TMP_BIN" ]; then - runAsRoot cp "$TILLER_TMP_BIN" "$HELM_INSTALL_DIR" - echo "$TILLER_NAME installed into $HELM_INSTALL_DIR/$TILLER_NAME" - else - echo "info: $TILLER_NAME binary was not found in this release; skipping $TILLER_NAME installation" - fi } # fail_trap is executed if an error occurs. @@ -180,15 +172,14 @@ testVersion() { exit 1 fi set -e - echo "Run '$PROJECT_NAME init' to configure $PROJECT_NAME." } # help provides possible cli installation arguments help () { echo "Accepted cli arguments are:" echo -e "\t[--help|-h ] ->> prints this help" - echo -e "\t[--version|-v ] . When not defined it defaults to latest" - echo -e "\te.g. --version v2.4.0 or -v latest" + echo -e "\t[--version|-v ] . When not defined it fetches the latest release from GitHub" + echo -e "\te.g. --version v3.0.0 or -v canary" echo -e "\t[--no-sudo] ->> install without sudo" } @@ -215,7 +206,7 @@ while [[ $# -gt 0 ]]; do if [[ $# -ne 0 ]]; then export DESIRED_VERSION="${1}" else - echo -e "Please provide the desired version. e.g. --version v2.4.0 or -v latest" + echo -e "Please provide the desired version. e.g. --version v3.0.0 or -v canary" exit 0 fi ;; From 8889625af63a93d08909af0c2cfdbddbcd7204db Mon Sep 17 00:00:00 2001 From: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> Date: Wed, 13 Nov 2019 18:29:48 +0100 Subject: [PATCH 071/279] fix: change error message to contain correct field name When reporting an incompatible Kubernetes version, due to a version constraint from the kubeVersion field, the error message should report with the correct field name. Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> --- pkg/action/install.go | 2 +- pkg/action/install_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 4019dbc54..11862c57a 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -420,7 +420,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values if ch.Metadata.KubeVersion != "" { if !chartutil.IsCompatibleRange(ch.Metadata.KubeVersion, caps.KubeVersion.String()) { - return hs, b, "", errors.Errorf("chart requires kubernetesVersion: %s which is incompatible with Kubernetes %s", ch.Metadata.KubeVersion, caps.KubeVersion.String()) + return hs, b, "", errors.Errorf("chart requires kubeVersion: %s which is incompatible with Kubernetes %s", ch.Metadata.KubeVersion, caps.KubeVersion.String()) } } diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index bb36b843d..4637a4b10 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -306,7 +306,7 @@ func TestInstallRelease_KubeVersion(t *testing.T) { vals = map[string]interface{}{} _, err = instAction.Run(buildChart(withKube(">=99.0.0")), vals) is.Error(err) - is.Contains(err.Error(), "chart requires kubernetesVersion") + is.Contains(err.Error(), "chart requires kubeVersion") } func TestInstallRelease_Wait(t *testing.T) { From d2ab24c7bffd9a518d37ae6cdd1c5c5456b9fe0b Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Sun, 17 Nov 2019 00:02:05 +0000 Subject: [PATCH 072/279] Add s390x build target Signed-off-by: Dean Coakley --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e48a20fd5..0185b249a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BINDIR := $(CURDIR)/bin 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 linux/s390x windows/amd64 BINNAME ?= helm GOPATH = $(shell go env GOPATH) From 44f72c4c0a55c8af25a88b363c3567408869aaa0 Mon Sep 17 00:00:00 2001 From: Jonathan Meyers Date: Mon, 18 Nov 2019 13:29:21 +0700 Subject: [PATCH 073/279] homebrew renamed formula to just helm from kubernetes-helm Signed-off-by: Jonathan Meyers --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9af358e10..06a53cf4d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Unpack the `helm` binary and add it to your PATH and you are good to go! If you want to use a package manager: -- [Homebrew](https://brew.sh/) users can use `brew install kubernetes-helm`. +- [Homebrew](https://brew.sh/) users can use `brew install helm`. - [Chocolatey](https://chocolatey.org/) users can use `choco install kubernetes-helm`. - [Scoop](https://scoop.sh/) users can use `scoop install helm`. - [GoFish](https://gofi.sh/) users can use `gofish install helm`. From 27c1ea63c70368d92ca101eac2efc569e3717520 Mon Sep 17 00:00:00 2001 From: Jonathan Meyers Date: Mon, 18 Nov 2019 13:34:41 +0700 Subject: [PATCH 074/279] Signed-off-by: Jonathan Meyers --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06a53cf4d..ff8842962 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Unpack the `helm` binary and add it to your PATH and you are good to go! If you want to use a package manager: -- [Homebrew](https://brew.sh/) users can use `brew install helm`. +- [Homebrew](https://brew.sh/) users can use `brew installhelm`. - [Chocolatey](https://chocolatey.org/) users can use `choco install kubernetes-helm`. - [Scoop](https://scoop.sh/) users can use `scoop install helm`. - [GoFish](https://gofi.sh/) users can use `gofish install helm`. From f65ce9167e08e9677940dce4bc5529db4dcf1665 Mon Sep 17 00:00:00 2001 From: Jonathan Meyers Date: Mon, 18 Nov 2019 13:35:01 +0700 Subject: [PATCH 075/279] Signed-off-by: Jonathan Meyers --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff8842962..06a53cf4d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Unpack the `helm` binary and add it to your PATH and you are good to go! If you want to use a package manager: -- [Homebrew](https://brew.sh/) users can use `brew installhelm`. +- [Homebrew](https://brew.sh/) users can use `brew install helm`. - [Chocolatey](https://chocolatey.org/) users can use `choco install kubernetes-helm`. - [Scoop](https://scoop.sh/) users can use `scoop install helm`. - [GoFish](https://gofi.sh/) users can use `gofish install helm`. From 8a8463e08d8a52b59fd20739ec3aa98be5bf1177 Mon Sep 17 00:00:00 2001 From: Scott Morgan Date: Tue, 19 Nov 2019 17:18:45 -0600 Subject: [PATCH 076/279] fix(lint): Remove requirement that directory name and chart name match Signed-off-by: Scott Morgan --- pkg/lint/rules/chartfile.go | 8 -------- pkg/lint/rules/chartfile_test.go | 18 ------------------ 2 files changed, 26 deletions(-) diff --git a/pkg/lint/rules/chartfile.go b/pkg/lint/rules/chartfile.go index 35bb81571..70cb83bc5 100644 --- a/pkg/lint/rules/chartfile.go +++ b/pkg/lint/rules/chartfile.go @@ -46,7 +46,6 @@ func Chartfile(linter *support.Linter) { } linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartName(chartFile)) - linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartNameDirMatch(linter.ChartDir, chartFile)) // Chart metadata linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartAPIVersion(chartFile)) @@ -82,13 +81,6 @@ func validateChartName(cf *chart.Metadata) error { return nil } -func validateChartNameDirMatch(chartDir string, cf *chart.Metadata) error { - if cf.Name != filepath.Base(chartDir) { - return errors.Errorf("directory name (%s) and chart name (%s) must be the same", filepath.Base(chartDir), cf.Name) - } - return nil -} - func validateChartAPIVersion(cf *chart.Metadata) error { if cf.APIVersion == "" { return errors.New("apiVersion is required. The value must be either \"v1\" or \"v2\"") diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index ff2a63583..f99299737 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -73,24 +73,6 @@ func TestValidateChartName(t *testing.T) { } } -func TestValidateChartNameDirMatch(t *testing.T) { - err := validateChartNameDirMatch(goodChartDir, goodChart) - if err != nil { - t.Errorf("validateChartNameDirMatch to return no error, gor a linter error") - } - // It has not name - err = validateChartNameDirMatch(badChartDir, badChart) - if err == nil { - t.Errorf("validatechartnamedirmatch to return a linter error, got no error") - } - - // Wrong path - err = validateChartNameDirMatch(badChartDir, goodChart) - if err == nil { - t.Errorf("validatechartnamedirmatch to return a linter error, got no error") - } -} - func TestValidateChartVersion(t *testing.T) { var failTest = []struct { Version string From eb833ccead99ecec15f3c192ad41bb041e284953 Mon Sep 17 00:00:00 2001 From: Scott Morgan Date: Wed, 20 Nov 2019 07:35:11 -0600 Subject: [PATCH 077/279] remove unused variable Signed-off-by: Scott Morgan --- pkg/lint/rules/chartfile_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index f99299737..fe306f653 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -30,18 +30,15 @@ import ( ) const ( - badChartDir = "testdata/badchartfile" - goodChartDir = "testdata/goodone" + badChartDir = "testdata/badchartfile" ) var ( badChartFilePath = filepath.Join(badChartDir, "Chart.yaml") - goodChartFilePath = filepath.Join(goodChartDir, "Chart.yaml") nonExistingChartFilePath = filepath.Join(os.TempDir(), "Chart.yaml") ) var badChart, _ = chartutil.LoadChartfile(badChartFilePath) -var goodChart, _ = chartutil.LoadChartfile(goodChartFilePath) // Validation functions Test func TestValidateChartYamlNotDirectory(t *testing.T) { From 32ce016054648f20168a2d7f4ff4b954686e0689 Mon Sep 17 00:00:00 2001 From: Scott Morgan Date: Wed, 20 Nov 2019 08:26:12 -0600 Subject: [PATCH 078/279] fix(lint): Remove requirement that directory name and chart name match Signed-off-by: Scott Morgan --- pkg/lint/lint_test.go | 15 ++++++--------- pkg/lint/rules/chartfile_test.go | 18 +++++++----------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/pkg/lint/lint_test.go b/pkg/lint/lint_test.go index b770704c6..2a982d088 100644 --- a/pkg/lint/lint_test.go +++ b/pkg/lint/lint_test.go @@ -35,12 +35,12 @@ const goodChartDir = "rules/testdata/goodone" func TestBadChart(t *testing.T) { m := All(badChartDir, values, namespace, strict).Messages - if len(m) != 8 { + if len(m) != 7 { t.Errorf("Number of errors %v", len(m)) t.Errorf("All didn't fail with expected errors, got %#v", m) } // There should be one INFO, 2 WARNINGs and one ERROR messages, check for them - var i, w, e, e2, e3, e4, e5, e6 bool + var i, w, e, e2, e3, e4, e5 bool for _, msg := range m { if msg.Severity == support.InfoSev { if strings.Contains(msg.Err.Error(), "icon is recommended") { @@ -59,24 +59,21 @@ func TestBadChart(t *testing.T) { if strings.Contains(msg.Err.Error(), "name is required") { e2 = true } - if strings.Contains(msg.Err.Error(), "directory name (badchartfile) and chart name () must be the same") { - e3 = true - } if strings.Contains(msg.Err.Error(), "apiVersion is required. The value must be either \"v1\" or \"v2\"") { - e4 = true + e3 = true } if strings.Contains(msg.Err.Error(), "chart type is not valid in apiVersion") { - e5 = true + e4 = true } if strings.Contains(msg.Err.Error(), "dependencies are not valid in the Chart file with apiVersion") { - e6 = true + e5 = true } } } - if !e || !e2 || !e3 || !e4 || !e5 || !e6 || !w || !i { + if !e || !e2 || !e3 || !e4 || !e5 || !w || !i { t.Errorf("Didn't find all the expected errors, got %#v", m) } } diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index fe306f653..d032dd12f 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -188,36 +188,32 @@ func TestChartfile(t *testing.T) { Chartfile(&linter) msgs := linter.Messages - if len(msgs) != 7 { - t.Errorf("Expected 7 errors, got %d", len(msgs)) + if len(msgs) != 6 { + t.Errorf("Expected 6 errors, got %d", len(msgs)) } if !strings.Contains(msgs[0].Err.Error(), "name is required") { t.Errorf("Unexpected message 0: %s", msgs[0].Err) } - if !strings.Contains(msgs[1].Err.Error(), "directory name (badchartfile) and chart name () must be the same") { + if !strings.Contains(msgs[1].Err.Error(), "apiVersion is required. The value must be either \"v1\" or \"v2\"") { t.Errorf("Unexpected message 1: %s", msgs[1].Err) } - if !strings.Contains(msgs[2].Err.Error(), "apiVersion is required. The value must be either \"v1\" or \"v2\"") { + if !strings.Contains(msgs[2].Err.Error(), "version '0.0.0.0' is not a valid SemVer") { t.Errorf("Unexpected message 2: %s", msgs[2].Err) } - if !strings.Contains(msgs[3].Err.Error(), "version '0.0.0.0' is not a valid SemVer") { + if !strings.Contains(msgs[3].Err.Error(), "icon is recommended") { t.Errorf("Unexpected message 3: %s", msgs[3].Err) } - if !strings.Contains(msgs[4].Err.Error(), "icon is recommended") { + if !strings.Contains(msgs[4].Err.Error(), "chart type is not valid in apiVersion") { t.Errorf("Unexpected message 4: %s", msgs[4].Err) } - if !strings.Contains(msgs[5].Err.Error(), "chart type is not valid in apiVersion") { + if !strings.Contains(msgs[5].Err.Error(), "dependencies are not valid in the Chart file with apiVersion") { t.Errorf("Unexpected message 5: %s", msgs[5].Err) } - if !strings.Contains(msgs[6].Err.Error(), "dependencies are not valid in the Chart file with apiVersion") { - t.Errorf("Unexpected message 6: %s", msgs[6].Err) - } - } From 6473234f43cbec7603124d684cb630dfdc4b1419 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sun, 24 Nov 2019 22:25:10 -0500 Subject: [PATCH 079/279] fix(plugin): Add missing -n known flag Signed-off-by: Marc Khouzam --- cmd/helm/load_plugins.go | 2 +- cmd/helm/plugin_test.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index 53e082e96..d68cf46ee 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -127,7 +127,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { func manuallyProcessArgs(args []string) ([]string, []string) { known := []string{} unknown := []string{} - kvargs := []string{"--kube-context", "--namespace", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config"} + kvargs := []string{"--kube-context", "--namespace", "-n", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config"} knownArg := func(a string) bool { for _, pre := range kvargs { if strings.HasPrefix(a, pre+"=") { diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index 7bc8fe70c..3fd3a4197 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -30,14 +30,27 @@ func TestManuallyProcessArgs(t *testing.T) { "--debug", "--foo", "bar", "--kubeconfig=/home/foo", + "--kubeconfig", "/home/foo", + "--kube-context=test1", "--kube-context", "test1", + "-n=test2", "-n", "test2", + "--namespace=test2", + "--namespace", "test2", "--home=/tmp", "command", } expectKnown := []string{ - "--debug", "--kubeconfig=/home/foo", "--kube-context", "test1", "-n", "test2", + "--debug", + "--kubeconfig=/home/foo", + "--kubeconfig", "/home/foo", + "--kube-context=test1", + "--kube-context", "test1", + "-n=test2", + "-n", "test2", + "--namespace=test2", + "--namespace", "test2", } expectUnknown := []string{ From 5179f8d698d30b243fd9aa646fac76224510b28b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sun, 24 Nov 2019 22:50:22 -0500 Subject: [PATCH 080/279] fix(plugin): Avoid duplication of flag list Signed-off-by: Marc Khouzam --- cmd/helm/load_plugins.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index d68cf46ee..ed99a5164 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -136,11 +136,21 @@ func manuallyProcessArgs(args []string) ([]string, []string) { } return false } + + isKnown := func(v string) string { + for _, i := range kvargs { + if i == v { + return v + } + } + return "" + } + for i := 0; i < len(args); i++ { switch a := args[i]; a { case "--debug": known = append(known, a) - case "--kube-context", "--namespace", "-n", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config": + case isKnown(a): known = append(known, a, args[i+1]) i++ default: From e3f49085ccb7b8f35e988554392d5f7ec5e066ad Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Mon, 25 Nov 2019 12:38:57 +0100 Subject: [PATCH 081/279] chart_downloader: add test to verify that http opts are used correctly. (#7055) Signed-off-by: Andreas Stenius --- pkg/downloader/chart_downloader_test.go | 61 +++++++++++++++++++ pkg/downloader/testdata/repositories.yaml | 7 ++- .../repository/testing-ca-file-index.yaml | 14 +++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 pkg/downloader/testdata/repository/testing-ca-file-index.yaml diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index 80249e240..abecf81eb 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -80,6 +80,67 @@ func TestResolveChartRef(t *testing.T) { } } +func TestResolveChartOpts(t *testing.T) { + tests := []struct { + name, ref, version string + expect []getter.Option + }{ + { + name: "repo with CA-file", + ref: "testing-ca-file/foo", + expect: []getter.Option{ + getter.WithURL("https://example.com/foo-1.2.3.tgz"), + getter.WithTLSClientConfig("cert", "key", "ca"), + }, + }, + } + + c := ChartDownloader{ + Out: os.Stderr, + RepositoryConfig: repoConfig, + RepositoryCache: repoCache, + Getters: getter.All(&cli.EnvSettings{ + RepositoryConfig: repoConfig, + RepositoryCache: repoCache, + }), + } + + // snapshot options + snapshot_opts := c.Options + + for _, tt := range tests { + // reset chart downloader options for each test case + c.Options = snapshot_opts + + expect, err := getter.NewHTTPGetter(tt.expect...) + if err != nil { + t.Errorf("%s: failed to setup http client: %s", tt.name, err) + continue + } + + u, err := c.ResolveChartVersion(tt.ref, tt.version) + if err != nil { + t.Errorf("%s: failed with error %s", tt.name, err) + continue + } + + got, err := getter.NewHTTPGetter( + append( + c.Options, + getter.WithURL(u.String()), + )... + ) + if err != nil { + t.Errorf("%s: failed to create http client: %s", tt.name, err) + continue + } + + if got != expect { + t.Errorf("%s: expected %s, got %s", tt.name, expect, got) + } + } +} + func TestVerifyChart(t *testing.T) { v, err := VerifyChart("testdata/signtest-0.1.0.tgz", "testdata/helm-test-key.pub") if err != nil { diff --git a/pkg/downloader/testdata/repositories.yaml b/pkg/downloader/testdata/repositories.yaml index 374d95c8a..430865269 100644 --- a/pkg/downloader/testdata/repositories.yaml +++ b/pkg/downloader/testdata/repositories.yaml @@ -15,4 +15,9 @@ repositories: - name: testing-relative url: "http://example.com/helm" - name: testing-relative-trailing-slash - url: "http://example.com/helm/" \ No newline at end of file + url: "http://example.com/helm/" + - name: testing-ca-file + url: "https://example.com" + certFile: "cert" + keyFile: "key" + caFile: "ca" diff --git a/pkg/downloader/testdata/repository/testing-ca-file-index.yaml b/pkg/downloader/testdata/repository/testing-ca-file-index.yaml new file mode 100644 index 000000000..17cdde1c6 --- /dev/null +++ b/pkg/downloader/testdata/repository/testing-ca-file-index.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +entries: + foo: + - name: foo + description: Foo Chart + home: https://helm.sh/helm + keywords: [] + maintainers: [] + sources: + - https://github.com/helm/charts + urls: + - https://example.com/foo-1.2.3.tgz + version: 1.2.3 + checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d From d6c13616fa7beff70931255cce62ab336ce1531d Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Mon, 25 Nov 2019 13:10:15 +0100 Subject: [PATCH 082/279] chart_downloader: add TLS client config to options from repo config. (#7055) Signed-off-by: Andreas Stenius --- pkg/downloader/chart_downloader.go | 2 ++ pkg/downloader/chart_downloader_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index 8e251bc89..9b9293455 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -214,6 +214,8 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er c.Options = append(c.Options, getter.WithBasicAuth(r.Config.Username, r.Config.Password)) } + c.Options = append(c.Options, getter.WithTLSClientConfig(r.Config.CertFile, r.Config.KeyFile, r.Config.CAFile)) + // Next, we need to load the index, and actually look up the chart. idxFile := filepath.Join(c.RepositoryCache, helmpath.CacheIndexFile(r.Config.Name)) i, err := repo.LoadIndexFile(idxFile) diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index abecf81eb..71a56d482 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -135,7 +135,7 @@ func TestResolveChartOpts(t *testing.T) { continue } - if got != expect { + if *(got.(*getter.HTTPGetter)) != *(expect.(*getter.HTTPGetter)) { t.Errorf("%s: expected %s, got %s", tt.name, expect, got) } } From d3ad6f9c78113fd4c577b31e41277796220e4c0f Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Mon, 25 Nov 2019 13:23:08 +0100 Subject: [PATCH 083/279] cli/pull: pass TLS config to chart downloader from flags. (#7055) Signed-off-by: Andreas Stenius --- pkg/action/pull.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/action/pull.go b/pkg/action/pull.go index aaf63861e..b0a3d2598 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -63,6 +63,7 @@ func (p *Pull) Run(chartRef string) (string, error) { Getters: getter.All(p.Settings), Options: []getter.Option{ getter.WithBasicAuth(p.Username, p.Password), + getter.WithTLSClientConfig(p.CertFile, p.KeyFile, p.CaFile), }, RepositoryConfig: p.Settings.RepositoryConfig, RepositoryCache: p.Settings.RepositoryCache, From 0f0aa6b43261b3f4b95fd7ee14107de2630dd446 Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Mon, 25 Nov 2019 13:37:20 +0100 Subject: [PATCH 084/279] chart_downloader: avoid overriding TLS options from command flags when not setup in repo config. Signed-off-by: Andreas Stenius --- pkg/downloader/chart_downloader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index 9b9293455..f3d4321c5 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -214,7 +214,9 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er c.Options = append(c.Options, getter.WithBasicAuth(r.Config.Username, r.Config.Password)) } - c.Options = append(c.Options, getter.WithTLSClientConfig(r.Config.CertFile, r.Config.KeyFile, r.Config.CAFile)) + if r.Config.CertFile != "" || r.Config.KeyFile != "" || r.Config.CAFile != "" { + c.Options = append(c.Options, getter.WithTLSClientConfig(r.Config.CertFile, r.Config.KeyFile, r.Config.CAFile)) + } // Next, we need to load the index, and actually look up the chart. idxFile := filepath.Join(c.RepositoryCache, helmpath.CacheIndexFile(r.Config.Name)) From 4c4328398ecc4f6eef07524f4bcddaca153b4570 Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Mon, 25 Nov 2019 14:17:24 +0100 Subject: [PATCH 085/279] chart_downloader: fix lint issue. Signed-off-by: Andreas Stenius --- pkg/downloader/chart_downloader_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index 71a56d482..e0692c8c8 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -87,7 +87,7 @@ func TestResolveChartOpts(t *testing.T) { }{ { name: "repo with CA-file", - ref: "testing-ca-file/foo", + ref: "testing-ca-file/foo", expect: []getter.Option{ getter.WithURL("https://example.com/foo-1.2.3.tgz"), getter.WithTLSClientConfig("cert", "key", "ca"), @@ -106,11 +106,11 @@ func TestResolveChartOpts(t *testing.T) { } // snapshot options - snapshot_opts := c.Options + snapshotOpts := c.Options for _, tt := range tests { // reset chart downloader options for each test case - c.Options = snapshot_opts + c.Options = snapshotOpts expect, err := getter.NewHTTPGetter(tt.expect...) if err != nil { @@ -128,7 +128,7 @@ func TestResolveChartOpts(t *testing.T) { append( c.Options, getter.WithURL(u.String()), - )... + )..., ) if err != nil { t.Errorf("%s: failed to create http client: %s", tt.name, err) From 32b4e2e5e998ee11559d132eae796f2b22fac0f7 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sun, 24 Nov 2019 23:08:13 -0500 Subject: [PATCH 086/279] fix(plugin): Avoid crash on missing flag When calling a plugin, if a global flag requiring a parameter was missing the parameter, helm would crash. For example: helm 2to3 --namespace Signed-off-by: Marc Khouzam --- cmd/helm/load_plugins.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index ed99a5164..f2fb5c01d 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -151,8 +151,11 @@ func manuallyProcessArgs(args []string) ([]string, []string) { case "--debug": known = append(known, a) case isKnown(a): - known = append(known, a, args[i+1]) + known = append(known, a) i++ + if i < len(args) { + known = append(known, args[i]) + } default: if knownArg(a) { known = append(known, a) From 48704034a9f37a23eee192b32e15249b299e0767 Mon Sep 17 00:00:00 2001 From: chloel Date: Tue, 26 Nov 2019 16:48:15 -0500 Subject: [PATCH 087/279] fix: ignore pax header files in chart validation Signed-off-by: chloel --- pkg/chart/loader/archive.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/chart/loader/archive.go b/pkg/chart/loader/archive.go index 3c50fe379..7e187a170 100644 --- a/pkg/chart/loader/archive.go +++ b/pkg/chart/loader/archive.go @@ -126,6 +126,12 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) { continue } + switch hd.Typeflag { + // We don't want to process these extension header files. + case tar.TypeXGlobalHeader, tar.TypeXHeader: + continue + } + // Archive could contain \ if generated on Windows delimiter := "/" if strings.ContainsRune(hd.Name, '\\') { From af59e32654f048d62b053afb0860a3bec77444fb Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 28 Nov 2019 13:01:20 +0100 Subject: [PATCH 088/279] docs(install): clarify the --replace flag (#7089) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(install): clarify the --replace flag The description of the `--replace` flag was unclear, as it can’t be used to replace active releases. Signed-off-by: Remco Haszing * docs(install): reword replace flag description Signed-off-by: Remco Haszing --- cmd/helm/install.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 40935db17..0c14c013b 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -130,7 +130,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { func addInstallFlags(f *pflag.FlagSet, client *action.Install, valueOpts *values.Options) { f.BoolVar(&client.DryRun, "dry-run", false, "simulate an install") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") - f.BoolVar(&client.Replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production") + f.BoolVar(&client.Replace, "replace", false, "re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production") f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") f.BoolVarP(&client.GenerateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)") From b8605c8d36960a552cdf74104f02762ef07e2713 Mon Sep 17 00:00:00 2001 From: Geoff Baskwill Date: Wed, 27 Nov 2019 19:46:34 -0500 Subject: [PATCH 089/279] test(pkg): add unit tests for tar file edge cases Adding unit tests for an issue that has come up multiple times where the archive processing code doesn't take into account the `tar.TypeXHeader` / `tar.TypeXGlobalHeader` entries that GitHub adds when creating a release archive for a chart, for example `https://github.com/org/repo/master.tar.gz`. Signed-off-by: Geoff Baskwill --- pkg/chart/loader/archive_test.go | 110 +++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 pkg/chart/loader/archive_test.go diff --git a/pkg/chart/loader/archive_test.go b/pkg/chart/loader/archive_test.go new file mode 100644 index 000000000..7d8c8b51e --- /dev/null +++ b/pkg/chart/loader/archive_test.go @@ -0,0 +1,110 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package loader + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "testing" +) + +func TestLoadArchiveFiles(t *testing.T) { + tcs := []struct { + name string + generate func(w *tar.Writer) + check func(t *testing.T, files []*BufferedFile, err error) + }{ + { + name: "empty input should return no files", + generate: func(w *tar.Writer) {}, + check: func(t *testing.T, files []*BufferedFile, err error) { + if err.Error() != "no files in chart archive" { + t.Fatalf(`expected "no files in chart archive", got [%#v]`, err) + } + }, + }, + { + name: "should ignore files with XGlobalHeader type", + generate: func(w *tar.Writer) { + // simulate the presence of a `pax_global_header` file like you would get when + // processing a GitHub release archive. + _ = w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeXGlobalHeader, + Name: "pax_global_header", + }) + + // we need to have at least one file, otherwise we'll get the "no files in chart archive" error + _ = w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeReg, + Name: "dir/empty", + }) + }, + check: func(t *testing.T, files []*BufferedFile, err error) { + if err != nil { + t.Fatalf(`got unwanted error [%#v] for tar file with pax_global_header content`, err) + } + + if len(files) != 1 { + t.Fatalf(`expected to get one file but got [%v]`, files) + } + }, + }, + { + name: "should ignore files with TypeXHeader type", + generate: func(w *tar.Writer) { + // simulate the presence of a `pax_header` file like you might get when + // processing a GitHub release archive. + _ = w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeXHeader, + Name: "pax_header", + }) + + // we need to have at least one file, otherwise we'll get the "no files in chart archive" error + _ = w.WriteHeader(&tar.Header{ + Typeflag: tar.TypeReg, + Name: "dir/empty", + }) + }, + check: func(t *testing.T, files []*BufferedFile, err error) { + if err != nil { + t.Fatalf(`got unwanted error [%#v] for tar file with pax_header content`, err) + } + + if len(files) != 1 { + t.Fatalf(`expected to get one file but got [%v]`, files) + } + }, + }, + } + + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + buf := &bytes.Buffer{} + gzw := gzip.NewWriter(buf) + tw := tar.NewWriter(gzw) + + tc.generate(tw) + + _ = tw.Close() + _ = gzw.Close() + + files, err := LoadArchiveFiles(buf) + tc.check(t, files, err) + }) + } +} From 750b870aedd35b69b9ca1e1517635fa70367a309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E7=9A=84=E6=BE=9C=E8=89=B2?= <33822635+zwwhdls@users.noreply.github.com> Date: Mon, 2 Dec 2019 22:57:51 +0800 Subject: [PATCH 090/279] fix stack overflow error (#7114) * fixed #7111 Signed-off-by: zwwhdls * update error message Signed-off-by: zwwhdls * add test case Signed-off-by: zwwhdls * fix lint error Signed-off-by: zwwhdls --- pkg/engine/engine.go | 8 ++++++++ pkg/engine/engine_test.go | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index dae0b6be7..5a7d54993 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -93,11 +93,19 @@ func warnWrap(warn string) string { // initFunMap creates the Engine's FuncMap and adds context-specific functions. func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]renderable) { funcMap := funcMap() + includedNames := make([]string, 0) // Add the 'include' function here so we can close over t. funcMap["include"] = func(name string, data interface{}) (string, error) { var buf strings.Builder + for _, n := range includedNames { + if n == name { + return "", errors.Wrapf(fmt.Errorf("unable to excute template"), "rendering template has a nested reference name: %s", name) + } + } + includedNames = append(includedNames, name) err := t.ExecuteTemplate(&buf, name, data) + includedNames = includedNames[:len(includedNames)-1] return buf.String(), err } diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index 031527dd0..f3609fcbd 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -460,6 +460,15 @@ func TestAlterFuncMap_include(t *testing.T) { }, } + // Check nested reference in include FuncMap + d := &chart.Chart{ + Metadata: &chart.Metadata{Name: "nested"}, + Templates: []*chart.File{ + {Name: "templates/quote", Data: []byte(`{{include "nested/templates/quote" . | indent 2}} dead.`)}, + {Name: "templates/_partial", Data: []byte(`{{.Release.Name}} - he`)}, + }, + } + v := chartutil.Values{ "Values": "", "Chart": c.Metadata, @@ -477,6 +486,12 @@ func TestAlterFuncMap_include(t *testing.T) { if got := out["conrad/templates/quote"]; got != expect { t.Errorf("Expected %q, got %q (%v)", expect, got, out) } + + _, err = Render(d, v) + expectErrName := "nested/templates/quote" + if err == nil { + t.Errorf("Expected err of nested reference name: %v", expectErrName) + } } func TestAlterFuncMap_require(t *testing.T) { From bf4cc97bbe7ca994894a87df63fdf7da6ee0841a Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 3 Dec 2019 08:48:44 -0500 Subject: [PATCH 091/279] fix(cli): IsReachable check for "get values" The 'helm get values' has its own Run() method in the action package. So, unlike the other 'get' variants, it needs to check for the reachability of the cluster itself. Signed-off-by: Marc Khouzam --- pkg/action/get_values.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/action/get_values.go b/pkg/action/get_values.go index 5bc3a7005..9c32db213 100644 --- a/pkg/action/get_values.go +++ b/pkg/action/get_values.go @@ -39,6 +39,10 @@ func NewGetValues(cfg *Configuration) *GetValues { // Run executes 'helm get values' against the given release. func (g *GetValues) Run(name string) (map[string]interface{}, error) { + if err := g.cfg.KubeClient.IsReachable(); err != nil { + return nil, err + } + rel, err := g.cfg.releaseContent(name, g.Version) if err != nil { return nil, err From cc33e394c7c464be1940a2f737a1f24887e4ca6f Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 28 Nov 2019 16:26:55 -0500 Subject: [PATCH 092/279] fix(tests): mapfile is not available on MacOS The mapfile command is not available on a standard MacOS install. To faciliate doing `make test` which runs validate-license.sh, let's use an array instead of mapfile. Signed-off-by: Marc Khouzam --- scripts/validate-license.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/validate-license.sh b/scripts/validate-license.sh index 00bd38ea2..dc247436f 100755 --- a/scripts/validate-license.sh +++ b/scripts/validate-license.sh @@ -27,14 +27,16 @@ find_files() { \( -name '*.go' -o -name '*.sh' \) } -mapfile -t failed_license_header < <(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License")') +# Use "|| :" to ignore the error code when grep returns empty +failed_license_header=($(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License")' || :)) if (( ${#failed_license_header[@]} > 0 )); then echo "Some source files are missing license headers." printf '%s\n' "${failed_license_header[@]}" exit 1 fi -mapfile -t failed_copyright_header < <(find_files | xargs grep -L 'Copyright The Helm Authors.') +# Use "|| :" to ignore the error code when grep returns empty +failed_copyright_header=($(find_files | xargs grep -L 'Copyright The Helm Authors.' || :)) if (( ${#failed_copyright_header[@]} > 0 )); then echo "Some source files are missing the copyright header." printf '%s\n' "${failed_copyright_header[@]}" From 01aa1bd3a299f6a456c5472394fd5138a20b87ce Mon Sep 17 00:00:00 2001 From: Graham Goudeau Date: Tue, 3 Dec 2019 14:06:55 -0500 Subject: [PATCH 093/279] Add a flag to allow template to output CRDs Signed-off-by: Graham Goudeau --- cmd/helm/template.go | 9 +++ cmd/helm/template_test.go | 5 ++ .../testdata/output/template-with-crds.txt | 72 +++++++++++++++++++ .../subpop/charts/subchart1/crds/crdA.yaml | 13 ++++ 4 files changed, 99 insertions(+) create mode 100644 cmd/helm/testdata/output/template-with-crds.txt create mode 100644 pkg/chartutil/testdata/subpop/charts/subchart1/crds/crdA.yaml diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 5312d798f..b660cc69f 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -44,6 +44,7 @@ faked locally. Additionally, none of the server-side testing of chart validity func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { var validate bool + var includeCrds bool client := action.NewInstall(cfg) valueOpts := &values.Options{} var extraAPIs []string @@ -67,7 +68,14 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { var manifests bytes.Buffer + if includeCrds { + for _, f := range rel.Chart.CRDs() { + fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", f.Name, f.Data) + } + } + fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) + if !client.DisableHooks { for _, m := range rel.Hooks { fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) @@ -120,6 +128,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.StringArrayVarP(&showFiles, "show-only", "s", []string{}, "only show manifests rendered from the given templates") f.StringVar(&client.OutputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") f.BoolVar(&validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. This is the same validation performed on an install") + f.BoolVar(&includeCrds, "include-crds", false, "include CRDs in the templated output") f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") return cmd diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 8aa2f6c06..735829432 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -79,6 +79,11 @@ func TestTemplateCmd(t *testing.T) { cmd: fmt.Sprintf("template --api-versions helm.k8s.io/test '%s'", chartPath), golden: "output/template-with-api-version.txt", }, + { + name: "template with CRDs", + cmd: fmt.Sprintf("template '%s' --include-crds", chartPath), + golden: "output/template-with-crds.txt", + }, } runTestCmd(t, tests) } diff --git a/cmd/helm/testdata/output/template-with-crds.txt b/cmd/helm/testdata/output/template-with-crds.txt new file mode 100644 index 000000000..9fa1c7e6d --- /dev/null +++ b/cmd/helm/testdata/output/template-with-crds.txt @@ -0,0 +1,72 @@ +--- +# Source: crds/crdA.yaml +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: testCRDs +spec: + group: testCRDGroups + names: + kind: TestCRD + listKind: TestCRDList + plural: TestCRDs + shortNames: + - tc + singular: authconfig + +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + helm.sh/chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app.kubernetes.io/name: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + helm.sh/chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app.kubernetes.io/name: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "RELEASE-NAME" + kube-version/major: "1" + kube-version/minor: "16" + kube-version/version: "v1.16.0" + kube-api-version/test: v1 +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app.kubernetes.io/name: subchart1 diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/crds/crdA.yaml b/pkg/chartutil/testdata/subpop/charts/subchart1/crds/crdA.yaml new file mode 100644 index 000000000..fca77fd4b --- /dev/null +++ b/pkg/chartutil/testdata/subpop/charts/subchart1/crds/crdA.yaml @@ -0,0 +1,13 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: testCRDs +spec: + group: testCRDGroups + names: + kind: TestCRD + listKind: TestCRDList + plural: TestCRDs + shortNames: + - tc + singular: authconfig From e062146db3a9a9bec0e64f5db939416441b1af38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E7=9A=84=E6=BE=9C=E8=89=B2?= <33822635+zwwhdls@users.noreply.github.com> Date: Wed, 4 Dec 2019 22:25:50 +0800 Subject: [PATCH 094/279] fix "Chart.lock is out of sync with Chart.yaml" (#7119) * fixed #7101 Signed-off-by: zwwhdls * add test case Signed-off-by: zwwhdls * fix lint error Signed-off-by: zwwhdls * rename testcase Signed-off-by: zwwhdls --- pkg/downloader/manager.go | 7 ++++ pkg/downloader/manager_test.go | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 4e9d691d8..81dd53614 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -149,6 +149,13 @@ func (m *Manager) Update() error { return err } + // downloadAll might overwrite dependency version, recalculate lock digest + newDigest, err := resolver.HashReq(req, lock.Dependencies) + if err != nil { + return err + } + lock.Digest = newDigest + // If the lock file hasn't changed, don't write a new one. oldLock := c.Lock if oldLock != nil && oldLock.Digest == lock.Digest { diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index 6e32b3e85..dd83c3dc2 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -181,6 +181,74 @@ func TestGetRepoNames(t *testing.T) { } } +func TestUpdateBeforeBuild(t *testing.T) { + // Set up a fake repo + srv, err := repotest.NewTempServer("testdata/*.tgz*") + if err != nil { + t.Fatal(err) + } + defer srv.Stop() + if err := srv.LinkIndices(); err != nil { + t.Fatal(err) + } + dir := func(p ...string) string { + return filepath.Join(append([]string{srv.Root()}, p...)...) + } + + // Save dep + d := &chart.Chart{ + Metadata: &chart.Metadata{ + Name: "dep-chart", + Version: "0.1.0", + APIVersion: "v1", + }, + } + if err := chartutil.SaveDir(d, dir()); err != nil { + t.Fatal(err) + } + // Save a chart + c := &chart.Chart{ + Metadata: &chart.Metadata{ + Name: "with-dependency", + Version: "0.1.0", + APIVersion: "v1", + Dependencies: []*chart.Dependency{{ + Name: d.Metadata.Name, + Version: ">=0.1.0", + Repository: "file://../dep-chart", + }}, + }, + } + if err := chartutil.SaveDir(c, dir()); err != nil { + t.Fatal(err) + } + + // Set-up a manager + b := bytes.NewBuffer(nil) + g := getter.Providers{getter.Provider{ + Schemes: []string{"http", "https"}, + New: getter.NewHTTPGetter, + }} + m := &Manager{ + ChartPath: dir(c.Metadata.Name), + Out: b, + Getters: g, + RepositoryConfig: dir("repositories.yaml"), + RepositoryCache: dir(), + } + + // Update before Build. see issue: https://github.com/helm/helm/issues/7101 + err = m.Update() + if err != nil { + t.Fatal(err) + } + + err = m.Build() + if err != nil { + t.Fatal(err) + } +} + // This function is the skeleton test code of failing tests for #6416 and #6871 and bugs due to #5874. // // This function is used by below tests that ensures success of build operation From a61c930de399e64fdafe5337a9c16a8625843758 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 4 Dec 2019 10:23:10 -0500 Subject: [PATCH 095/279] Fixing the code of conduct pointer When the v3 branch was started the code of conduct pointed to the Kubernetes one which pointed to the CNCF. Helm moved to be a CNCF project and the v2 code of conduct was pointed directly at the CNCF one. This was missed on the v3 branch. This updates the pointer. Signed-off-by: Matt Farina --- code-of-conduct.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-of-conduct.md b/code-of-conduct.md index 0d15c00cf..91ccaf035 100644 --- a/code-of-conduct.md +++ b/code-of-conduct.md @@ -1,3 +1,3 @@ -# Kubernetes Community Code of Conduct +# Community Code of Conduct -Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) +Helm follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). From 2a66e1a0e1f9b820309cd658aecf10896ac65ca5 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Wed, 4 Dec 2019 22:43:42 +0530 Subject: [PATCH 096/279] use sigs.k8s.io/yaml instead of gopkg.in/yaml.v2 this is for consistency as everywhere we use sigs.k8s.io/yaml package Signed-off-by: Karuppiah Natarajan --- cmd/helm/repo_add.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 1c84ad8d6..e6afce3d5 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -29,7 +29,7 @@ import ( "github.com/gofrs/flock" "github.com/pkg/errors" "github.com/spf13/cobra" - "gopkg.in/yaml.v2" + "sigs.k8s.io/yaml" "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/pkg/getter" From a1dcb3c2e453f778456ed600549a384605e1a692 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 5 Dec 2019 15:48:02 -0500 Subject: [PATCH 097/279] Restoring fetch-dist and sign Make targets These make targets are used as part of the release process. They had yet to be brought over to the v3 branch from the v2 branch as they were developed after the branching happened. Signed-off-by: Matt Farina --- Makefile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e48a20fd5..611222e28 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -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 +BINDIR := $(CURDIR)/bin +DIST_DIRS := find * -type d -exec +TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 +TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-386.tar.gz linux-386.tar.gz.sha256 linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 windows-amd64.zip windows-amd64.zip.sha256 +BINNAME ?= helm GOPATH = $(shell go env GOPATH) DEP = $(GOPATH)/bin/dep @@ -138,6 +139,20 @@ dist: $(DIST_DIRS) zip -r helm-${VERSION}-{}.zip {} \; \ ) +.PHONY: fetch-dist +fetch-dist: + mkdir -p _dist + cd _dist && \ + for obj in ${TARGET_OBJS} ; do \ + curl -sSL -o helm-${VERSION}-$${obj} https://get.helm.sh/helm-${VERSION}-$${obj} ; \ + done + +.PHONY: sign +sign: + for f in _dist/*.{gz,zip,sha256} ; do \ + gpg --armor --detach-sign $${f} ; \ + done + .PHONY: checksum checksum: for f in _dist/*.{gz,zip} ; do \ From 361db773881415398ce05637f9f56bd6f2820c85 Mon Sep 17 00:00:00 2001 From: Robert Brennan Date: Thu, 5 Dec 2019 16:45:53 -0500 Subject: [PATCH 098/279] Fix godoc badge Signed-off-by: Robert Brennan --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb1e40ca6..73fd189d7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CircleCI](https://circleci.com/gh/helm/helm.svg?style=shield)](https://circleci.com/gh/helm/helm) [![Go Report Card](https://goreportcard.com/badge/github.com/helm/helm)](https://goreportcard.com/report/github.com/helm/helm) -[![GoDoc](https://godoc.org/helm.sh/helm?status.svg)](https://godoc.org/helm.sh/helm) +[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/helm.sh/helm/v3) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3131/badge)](https://bestpractices.coreinfrastructure.org/projects/3131) Helm is a tool for managing Charts. Charts are packages of pre-configured Kubernetes resources. From 36a8001e2adc0e5cf1bc3a06c75777a0b2ee15b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E7=9A=84=E6=BE=9C=E8=89=B2?= <33822635+zwwhdls@users.noreply.github.com> Date: Fri, 6 Dec 2019 17:32:12 +0800 Subject: [PATCH 099/279] fix this inconsistency in the docs (#7157) Signed-off-by: zwwhdls --- cmd/helm/package.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmd/helm/package.go b/cmd/helm/package.go index dd4bb2d17..f82c0950d 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -36,9 +36,6 @@ This command packages a chart into a versioned chart archive file. If a path is given, this will look at that path for a chart (which must contain a Chart.yaml file) and then package that directory. -If no path is given, this will look in the present working directory for a -Chart.yaml file, and (if found) build the current directory into a chart. - Versioned chart archives are used by Helm package repositories. ` From 0e42a77ae6ae266cfa299de3b3bfd204f35b9f7a Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 6 Dec 2019 09:14:39 -0700 Subject: [PATCH 100/279] improved the error message for failed package signing (#6948) Signed-off-by: Matt Butcher --- cmd/helm/package.go | 8 ++++++++ pkg/provenance/sign.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/helm/package.go b/cmd/helm/package.go index f82c0950d..9f7961f95 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -37,6 +37,14 @@ is given, this will look at that path for a chart (which must contain a Chart.yaml file) and then package that directory. Versioned chart archives are used by Helm package repositories. + +To sign a chart, use the '--sign' flag. In most cases, you should also +provide '--keyring path/to/secret/keys' and '--key keyname'. + + $ helm package --sign ./mychart --key mykey --keyring ~/.gnupg/secring.gpg + +If '--keyring' is not specified, Helm usually defaults to the public keyring +unless your environment is otherwise configured. ` func newPackageCmd(out io.Writer) *cobra.Command { diff --git a/pkg/provenance/sign.go b/pkg/provenance/sign.go index 6032eb063..5d16779f1 100644 --- a/pkg/provenance/sign.go +++ b/pkg/provenance/sign.go @@ -169,7 +169,7 @@ func (s *Signatory) DecryptKey(fn PassphraseFetcher) error { if s.Entity == nil { return errors.New("private key not found") } else if s.Entity.PrivateKey == nil { - return errors.New("provided key is not a private key") + return errors.New("provided key is not a private key. Try providing a keyring with secret keys") } // Nothing else to do if key is not encrypted. @@ -203,7 +203,7 @@ func (s *Signatory) ClearSign(chartpath string) (string, error) { if s.Entity == nil { return "", errors.New("private key not found") } else if s.Entity.PrivateKey == nil { - return "", errors.New("provided key is not a private key") + return "", errors.New("provided key is not a private key. Try providing a keyring with secret keys") } if fi, err := os.Stat(chartpath); err != nil { From e47c67c427e9831d3df20befc7fa139404829ddc Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 6 Dec 2019 09:14:51 -0700 Subject: [PATCH 101/279] fix: clarified behavior of 'list --deleted' (#6950) Signed-off-by: Matt Butcher --- cmd/helm/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 83edfe156..0da0c21d3 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -97,7 +97,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVarP(&client.ByDate, "date", "d", false, "sort by release date") f.BoolVarP(&client.SortReverse, "reverse", "r", false, "reverse the sort order") f.BoolVarP(&client.All, "all", "a", false, "show all releases, not just the ones marked deployed or failed") - f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases") + f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases (if 'helm uninstall --keep-history' was used)") f.BoolVar(&client.Superseded, "superseded", false, "show superseded releases") f.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") From cb81b07125585309d0cf5a17ce57dcd10429d8a1 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Fri, 22 Nov 2019 16:27:08 +0100 Subject: [PATCH 102/279] Reintroduce --is-upgrade to template command This change allows correct rendering of manifests for the upgrade case using `helm template`. Signed-off-by: Fabian Ruff --- cmd/helm/template.go | 1 + pkg/action/install.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index b660cc69f..a47631c0d 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -129,6 +129,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.StringVar(&client.OutputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") f.BoolVar(&validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. This is the same validation performed on an install") f.BoolVar(&includeCrds, "include-crds", false, "include CRDs in the templated output") + f.BoolVar(&client.IsUpgrade, "is-upgrade", false, "set .Release.IsUpgrade instead of .Release.IsInstall") f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") return cmd diff --git a/pkg/action/install.go b/pkg/action/install.go index 8cd270693..b08f2fb67 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -86,6 +86,8 @@ type Install struct { // APIVersions allows a manual set of supported API Versions to be passed // (for things like templating). These are ignored if ClientOnly is false APIVersions chartutil.VersionSet + // Used by helm template to render charts with .Relase.IsUpgrade. Ignored if Dry-Run is false + IsUpgrade bool } // ChartPathOptions captures common options used for controlling chart paths @@ -197,11 +199,14 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. return nil, err } + //special case for helm template --is-upgrade + isUpgrade := i.IsUpgrade && i.DryRun options := chartutil.ReleaseOptions{ Name: i.ReleaseName, Namespace: i.Namespace, Revision: 1, - IsInstall: true, + IsInstall: !isUpgrade, + IsUpgrade: isUpgrade, } valuesToRender, err := chartutil.ToRenderValues(chrt, vals, options, caps) if err != nil { @@ -237,7 +242,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. // we'll end up in a state where we will delete those resources upon // deleting the release because the manifest will be pointing at that // resource - if !i.ClientOnly { + if !i.ClientOnly && !isUpgrade { if err := existingResourceConflict(resources); err != nil { return nil, errors.Wrap(err, "rendered manifests contain a resource that already exists. Unable to continue with install") } From e3976ab7a286ecbe1038a725fbc4149b95267abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Mac=C3=ADk?= Date: Mon, 9 Dec 2019 12:56:55 +0100 Subject: [PATCH 103/279] Repair failing unit tests - failure caused by os.Stat return values for directory size on Linux. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Macík --- pkg/chartutil/expand_test.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pkg/chartutil/expand_test.go b/pkg/chartutil/expand_test.go index 0eb35aedb..9a85e3247 100644 --- a/pkg/chartutil/expand_test.go +++ b/pkg/chartutil/expand_test.go @@ -39,19 +39,6 @@ func TestExpand(t *testing.T) { t.Fatal(err) } - files, err := ioutil.ReadDir(dest) - if err != nil { - t.Fatalf("error reading output directory %s: %s", dest, err) - } - - if len(files) != 1 { - t.Fatalf("expected a single chart directory in output directory %s", dest) - } - - if !files[0].IsDir() { - t.Fatalf("expected a chart directory in output directory %s", dest) - } - expectedChartPath := filepath.Join(dest, "frobnitz") fi, err := os.Stat(expectedChartPath) if err != nil { @@ -81,8 +68,14 @@ func TestExpand(t *testing.T) { if err != nil { t.Fatal(err) } - if fi.Size() != expect.Size() { - t.Errorf("Expected %s to have size %d, got %d", fi.Name(), expect.Size(), fi.Size()) + // os.Stat can return different values for directories, based on the OS + // for Linux, for example, os.Stat alwaty returns the size of the directory + // (value-4096) regardless of the size of the contents of the directory + mode := expect.Mode() + if !mode.IsDir() { + if fi.Size() != expect.Size() { + t.Errorf("Expected %s to have size %d, got %d", fi.Name(), expect.Size(), fi.Size()) + } } } } @@ -127,8 +120,14 @@ func TestExpandFile(t *testing.T) { if err != nil { t.Fatal(err) } - if fi.Size() != expect.Size() { - t.Errorf("Expected %s to have size %d, got %d", fi.Name(), expect.Size(), fi.Size()) + // os.Stat can return different values for directories, based on the OS + // for Linux, for example, os.Stat alwaty returns the size of the directory + // (value-4096) regardless of the size of the contents of the directory + mode := expect.Mode() + if !mode.IsDir() { + if fi.Size() != expect.Size() { + t.Errorf("Expected %s to have size %d, got %d", fi.Name(), expect.Size(), fi.Size()) + } } } } From 357d265de0e72f02c493701cdbee9ecc6eb0a016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mat=C3=ADas=20de=20la=20C=C3=A1mara=20Beovide?= Date: Mon, 9 Dec 2019 13:48:31 -0300 Subject: [PATCH 104/279] fix(helm): add --description flag to helm (#7074) * fix(helm): add --description flag to 'helm install', 'helm upgrade', and 'helm uninstall' When added, this flag allow us to add a custom description to the release. E.g. '--description "my custom description"' Closes #7033 Signed-off-by: Juan Matias Kungfu de la Camara Beovide * fix(helm): fixed style issues on top of previous commit (https://github.com/helm/helm/commit/3a43a9a487270b40d42db451d4856dbec30cf72e) Closes #7033 Signed-off-by: Juan Matias Kungfu de la Camara Beovide * fix(helm): fixed wrong test issue on top of previous commit (3a43a9a) Closes #7033 Signed-off-by: Juan Matias Kungfu de la Camara Beovide --- cmd/helm/install.go | 1 + cmd/helm/uninstall.go | 1 + cmd/helm/upgrade.go | 1 + pkg/action/install.go | 7 ++++++- pkg/action/uninstall.go | 7 ++++++- pkg/action/upgrade.go | 13 +++++++++++-- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 0c14c013b..176250f84 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -135,6 +135,7 @@ func addInstallFlags(f *pflag.FlagSet, client *action.Install, valueOpts *values f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") f.BoolVarP(&client.GenerateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)") f.StringVar(&client.NameTemplate, "name-template", "", "specify template used to name the release") + f.StringVar(&client.Description, "description", "", "add a custom description") f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") f.BoolVar(&client.DependencyUpdate, "dependency-update", false, "run helm dependency update before installing the chart") f.BoolVar(&client.Atomic, "atomic", false, "if set, installation process purges chart on fail. The --wait flag will be set automatically if --atomic is used") diff --git a/cmd/helm/uninstall.go b/cmd/helm/uninstall.go index 27b5a8426..7096d7873 100644 --- a/cmd/helm/uninstall.go +++ b/cmd/helm/uninstall.go @@ -69,6 +69,7 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history") f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") + f.StringVar(&client.Description, "description", "", "add a custom description") return cmd } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index eadc3b63d..dce8ad74f 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -156,6 +156,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.IntVar(&client.MaxHistory, "history-max", 10, "limit the maximum number of revisions saved per release. Use 0 for no limit") f.BoolVar(&client.CleanupOnFail, "cleanup-on-fail", false, "allow deletion of new resources created in this upgrade when upgrade fails") f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent") + f.StringVar(&client.Description, "description", "", "add a custom description") addChartPathOptionsFlags(f, &client.ChartPathOptions) addValueOptionsFlags(f, valueOpts) bindOutputFlag(cmd, &outfmt) diff --git a/pkg/action/install.go b/pkg/action/install.go index b08f2fb67..89a343a6f 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -79,6 +79,7 @@ type Install struct { ReleaseName string GenerateName bool NameTemplate string + Description string OutputDir string Atomic bool SkipCRDs bool @@ -297,7 +298,11 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. } } - rel.SetStatus(release.StatusDeployed, "Install complete") + if len(i.Description) > 0 { + rel.SetStatus(release.StatusDeployed, i.Description) + } else { + rel.SetStatus(release.StatusDeployed, "Install complete") + } // This is a tricky case. The release has been created, but the result // cannot be recorded. The truest thing to tell the user is that the diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index fb72a845b..dfaa98472 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -37,6 +37,7 @@ type Uninstall struct { DryRun bool KeepHistory bool Timeout time.Duration + Description string } // NewUninstall creates a new Uninstall object with the given configuration. @@ -118,7 +119,11 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) } rel.Info.Status = release.StatusUninstalled - rel.Info.Description = "Uninstallation complete" + if len(u.Description) > 0 { + rel.Info.Description = u.Description + } else { + rel.Info.Description = "Uninstallation complete" + } if !u.KeepHistory { u.cfg.Log("purge requested for %s", name) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index d0495a864..cdc40eaaa 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -58,6 +58,7 @@ type Upgrade struct { Atomic bool CleanupOnFail bool SubNotes bool + Description string } // NewUpgrade creates a new Upgrade object with the given configuration. @@ -218,7 +219,11 @@ func (u *Upgrade) performUpgrade(originalRelease, upgradedRelease *release.Relea if u.DryRun { u.cfg.Log("dry run for %s", upgradedRelease.Name) - upgradedRelease.Info.Description = "Dry run complete" + if len(u.Description) > 0 { + upgradedRelease.Info.Description = u.Description + } else { + upgradedRelease.Info.Description = "Dry run complete" + } return upgradedRelease, nil } @@ -270,7 +275,11 @@ func (u *Upgrade) performUpgrade(originalRelease, upgradedRelease *release.Relea u.cfg.recordRelease(originalRelease) upgradedRelease.Info.Status = release.StatusDeployed - upgradedRelease.Info.Description = "Upgrade complete" + if len(u.Description) > 0 { + upgradedRelease.Info.Description = u.Description + } else { + upgradedRelease.Info.Description = "Upgrade complete" + } return upgradedRelease, nil } From 735bc652a6618afb7502d8154086a1535c7629ea Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 10 Dec 2019 15:33:30 -0500 Subject: [PATCH 105/279] fix(tests): Repair tests failures When the unreleased tag was removed, some tests that were added after the PR was created started failing. This fixes them. Signed-off-by: Marc Khouzam --- cmd/helm/testdata/output/version-client-shorthand.txt | 2 +- cmd/helm/testdata/output/version-client.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/testdata/output/version-client-shorthand.txt b/cmd/helm/testdata/output/version-client-shorthand.txt index 0d9b536e6..4b493d31c 100644 --- a/cmd/helm/testdata/output/version-client-shorthand.txt +++ b/cmd/helm/testdata/output/version-client-shorthand.txt @@ -1 +1 @@ -version.BuildInfo{Version:"v3.0+unreleased", GitCommit:"", GitTreeState:"", GoVersion:""} +version.BuildInfo{Version:"v3.0", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/output/version-client.txt b/cmd/helm/testdata/output/version-client.txt index 0d9b536e6..4b493d31c 100644 --- a/cmd/helm/testdata/output/version-client.txt +++ b/cmd/helm/testdata/output/version-client.txt @@ -1 +1 @@ -version.BuildInfo{Version:"v3.0+unreleased", GitCommit:"", GitTreeState:"", GoVersion:""} +version.BuildInfo{Version:"v3.0", GitCommit:"", GitTreeState:"", GoVersion:""} From 95e74c71d91cb0417db768385f88e148e4533905 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 10 Dec 2019 13:54:24 -0800 Subject: [PATCH 106/279] chore(testdata): remove stale output These testdata output are never consumed Signed-off-by: Matthew Fisher --- cmd/helm/testdata/output/search-single.txt | 2 -- cmd/helm/testdata/output/status-with-resource.txt | 9 --------- cmd/helm/testdata/output/status.yaml | 10 ---------- 3 files changed, 21 deletions(-) delete mode 100644 cmd/helm/testdata/output/search-single.txt delete mode 100644 cmd/helm/testdata/output/status-with-resource.txt delete mode 100644 cmd/helm/testdata/output/status.yaml diff --git a/cmd/helm/testdata/output/search-single.txt b/cmd/helm/testdata/output/search-single.txt deleted file mode 100644 index 936605ae1..000000000 --- a/cmd/helm/testdata/output/search-single.txt +++ /dev/null @@ -1,2 +0,0 @@ -NAME CHART VERSION APP VERSION DESCRIPTION -testing/mariadb 0.3.0 Chart for MariaDB diff --git a/cmd/helm/testdata/output/status-with-resource.txt b/cmd/helm/testdata/output/status-with-resource.txt deleted file mode 100644 index 5f6f4e663..000000000 --- a/cmd/helm/testdata/output/status-with-resource.txt +++ /dev/null @@ -1,9 +0,0 @@ -NAME: flummoxed-chickadee -LAST DEPLOYED: 2016-01-16 00:00:00 +0000 UTC -NAMESPACE: default -STATUS: deployed - -RESOURCES: -resource A -resource B - diff --git a/cmd/helm/testdata/output/status.yaml b/cmd/helm/testdata/output/status.yaml deleted file mode 100644 index a7bc12276..000000000 --- a/cmd/helm/testdata/output/status.yaml +++ /dev/null @@ -1,10 +0,0 @@ -info: - deleted: "0001-01-01T00:00:00Z" - first_deployed: "0001-01-01T00:00:00Z" - last_deployed: "2016-01-16T00:00:00Z" - resources: | - resource A - resource B - status: deployed -name: flummoxed-chickadee -namespace: default From 67e57a5fbb7b210e534157b8f67c15ffc3445453 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 29 Oct 2019 11:17:54 -0700 Subject: [PATCH 107/279] feat(install): introduce --disable-openapi-validation When enabled, during the rendering process, this feature flag will not validate rendered templates against the Kubernetes OpenAPI Schema. Signed-off-by: Matthew Fisher --- cmd/helm/install.go | 1 + pkg/action/install.go | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 176250f84..56b1bca2f 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -138,6 +138,7 @@ func addInstallFlags(f *pflag.FlagSet, client *action.Install, valueOpts *values f.StringVar(&client.Description, "description", "", "add a custom description") f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") f.BoolVar(&client.DependencyUpdate, "dependency-update", false, "run helm dependency update before installing the chart") + f.BoolVar(&client.DisableOpenAPIValidation, "disable-openapi-validation", false, "if set, the installation process will not validate rendered templates against the Kubernetes OpenAPI Schema") f.BoolVar(&client.Atomic, "atomic", false, "if set, installation process purges chart on fail. The --wait flag will be set automatically if --atomic is used") f.BoolVar(&client.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed. By default, CRDs are installed if not already present") f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent") diff --git a/pkg/action/install.go b/pkg/action/install.go index 89a343a6f..c48b9e930 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -67,23 +67,24 @@ type Install struct { ChartPathOptions - ClientOnly bool - DryRun bool - DisableHooks bool - Replace bool - Wait bool - Devel bool - DependencyUpdate bool - Timeout time.Duration - Namespace string - ReleaseName string - GenerateName bool - NameTemplate string - Description string - OutputDir string - Atomic bool - SkipCRDs bool - SubNotes bool + ClientOnly bool + DryRun bool + DisableHooks bool + Replace bool + Wait bool + Devel bool + DependencyUpdate bool + Timeout time.Duration + Namespace string + ReleaseName string + GenerateName bool + NameTemplate string + Description string + OutputDir string + Atomic bool + SkipCRDs bool + SubNotes bool + DisableOpenAPIValidation bool // APIVersions allows a manual set of supported API Versions to be passed // (for things like templating). These are ignored if ClientOnly is false APIVersions chartutil.VersionSet @@ -232,7 +233,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. // Mark this release as in-progress rel.SetStatus(release.StatusPendingInstall, "Initial install underway") - resources, err := i.cfg.KubeClient.Build(bytes.NewBufferString(rel.Manifest), true) + resources, err := i.cfg.KubeClient.Build(bytes.NewBufferString(rel.Manifest), !i.DisableOpenAPIValidation) if err != nil { return nil, errors.Wrap(err, "unable to build kubernetes objects from release manifest") } From 9254be9675feb5f24201b55682d78afa7c25f256 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 11 Dec 2019 08:05:43 -0800 Subject: [PATCH 108/279] add Marc Khouzam as a core maintainer Signed-off-by: Matthew Fisher --- OWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/OWNERS b/OWNERS index 715c8993d..d7dac5514 100644 --- a/OWNERS +++ b/OWNERS @@ -4,6 +4,7 @@ maintainers: - fibonacci1729 - hickeyma - jdolitsky + - marckhouzam - mattfarina - michelleN - prydonius From 0cb0eaca948d55da1c824f201aa78f9313763f69 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Thu, 12 Dec 2019 04:07:05 +1100 Subject: [PATCH 109/279] fix(*): Helm v3 handling of APIVersion v1 charts dependencies (#7009) * Include requirements.* as Files in APIVersionV1 Fixes #6974. This ensures that when reading a Chart marked with APIVersion v1, we maintain the behaviour of Helm v2 and include the requirements.yaml and requirements.lock in the Files collection, and hence produce charts that work correctly with Helm v2. Signed-off-by: Paul "Hampy" Hampson * Write out requirements.lock for APIVersion1 Charts This keeps the on-disk format consistent after `helm dependency update` of an APIVersion1 Chart. Signed-off-by: Paul "Hampy" Hampson * Exclude 'dependencies' from APVersion1 Chart.yaml This fixes `helm lint` against an APIVersion1 chart packaged with Helm v3. Signed-off-by: Paul "Hampy" Hampson * Generate APIVersion v2 charts for dependency tests As the generated chart contains no requirements.yaml in its files list, but has dependencies in its metadata, it is not a valid APIVersion v1 chart. Signed-off-by: Paul "Hampy" Hampson * Generate APIVersion v2 charts for manager tests Specifically for the charts that have dependencies, the generated chart contains no requirements.yaml in its files but has dependencies in its metadata. Hence it is not a valid APIVersion v1 chart. Signed-off-by: Paul "Hampy" Hampson --- cmd/helm/dependency_update_test.go | 2 +- pkg/chart/loader/load.go | 6 ++++++ pkg/chartutil/chartfile.go | 9 +++++++++ pkg/chartutil/save.go | 9 +++++++++ pkg/downloader/manager.go | 10 +++++++--- pkg/downloader/manager_test.go | 4 ++-- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 53d67ef59..9afc04f8d 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -182,7 +182,7 @@ func TestDependencyUpdateCmd_DontDeleteOldChartsOnError(t *testing.T) { func createTestingMetadata(name, baseURL string) *chart.Chart { return &chart.Chart{ Metadata: &chart.Metadata{ - APIVersion: chart.APIVersionV1, + APIVersion: chart.APIVersionV2, Name: name, Version: "1.2.3", Dependencies: []*chart.Dependency{ diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index 3c38519bc..dd4fd2dff 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -114,12 +114,18 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil { return c, errors.Wrap(err, "cannot load requirements.yaml") } + if c.Metadata.APIVersion == chart.APIVersionV1 { + c.Files = append(c.Files, &chart.File{Name: f.Name, Data: f.Data}) + } // Deprecated: requirements.lock is deprecated use Chart.lock. case f.Name == "requirements.lock": c.Lock = new(chart.Lock) if err := yaml.Unmarshal(f.Data, &c.Lock); err != nil { return c, errors.Wrap(err, "cannot load requirements.lock") } + if c.Metadata.APIVersion == chart.APIVersionV1 { + c.Files = append(c.Files, &chart.File{Name: f.Name, Data: f.Data}) + } case strings.HasPrefix(f.Name, "templates/"): c.Templates = append(c.Templates, &chart.File{Name: f.Name, Data: f.Data}) diff --git a/pkg/chartutil/chartfile.go b/pkg/chartutil/chartfile.go index 68176ed5d..756b87cfb 100644 --- a/pkg/chartutil/chartfile.go +++ b/pkg/chartutil/chartfile.go @@ -42,7 +42,16 @@ func LoadChartfile(filename string) (*chart.Metadata, error) { // // 'filename' should be the complete path and filename ('foo/Chart.yaml') func SaveChartfile(filename string, cf *chart.Metadata) error { + // Pull out the dependencies of a v1 Chart, since there's no way + // to tell the serialiser to skip a field for just this use case + savedDependencies := cf.Dependencies + if cf.APIVersion == chart.APIVersionV1 { + cf.Dependencies = nil + } out, err := yaml.Marshal(cf) + if cf.APIVersion == chart.APIVersionV1 { + cf.Dependencies = savedDependencies + } if err != nil { return err } diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index bc8f5bdd9..e264c4391 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -141,8 +141,17 @@ func Save(c *chart.Chart, outDir string) (string, error) { func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { base := filepath.Join(prefix, c.Name()) + // Pull out the dependencies of a v1 Chart, since there's no way + // to tell the serialiser to skip a field for just this use case + savedDependencies := c.Metadata.Dependencies + if c.Metadata.APIVersion == chart.APIVersionV1 { + c.Metadata.Dependencies = nil + } // Save Chart.yaml cdata, err := yaml.Marshal(c.Metadata) + if c.Metadata.APIVersion == chart.APIVersionV1 { + c.Metadata.Dependencies = savedDependencies + } if err != nil { return err } diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 81dd53614..e46af6944 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -163,7 +163,7 @@ func (m *Manager) Update() error { } // Finally, we need to write the lockfile. - return writeLock(m.ChartPath, lock) + return writeLock(m.ChartPath, lock, c.Metadata.APIVersion == chart.APIVersionV1) } func (m *Manager) loadChartDir() (*chart.Chart, error) { @@ -634,12 +634,16 @@ func (m *Manager) loadChartRepositories() (map[string]*repo.ChartRepository, err } // writeLock writes a lockfile to disk -func writeLock(chartpath string, lock *chart.Lock) error { +func writeLock(chartpath string, lock *chart.Lock, legacyLockfile bool) error { data, err := yaml.Marshal(lock) if err != nil { return err } - dest := filepath.Join(chartpath, "Chart.lock") + lockfileName := "Chart.lock" + if legacyLockfile { + lockfileName = "requirements.lock" + } + dest := filepath.Join(chartpath, lockfileName) return ioutil.WriteFile(dest, data, 0644) } diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index dd83c3dc2..ea235c13f 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -211,7 +211,7 @@ func TestUpdateBeforeBuild(t *testing.T) { Metadata: &chart.Metadata{ Name: "with-dependency", Version: "0.1.0", - APIVersion: "v1", + APIVersion: "v2", Dependencies: []*chart.Dependency{{ Name: d.Metadata.Name, Version: ">=0.1.0", @@ -285,7 +285,7 @@ func checkBuildWithOptionalFields(t *testing.T, chartName string, dep chart.Depe Metadata: &chart.Metadata{ Name: chartName, Version: "0.1.0", - APIVersion: "v1", + APIVersion: "v2", Dependencies: []*chart.Dependency{&dep}, }, } From 3d04c6c5ce5d019e3a1f58354ab9f67453a83f8a Mon Sep 17 00:00:00 2001 From: jabielecki <47531708+jabielecki@users.noreply.github.com> Date: Thu, 12 Dec 2019 12:41:55 +0100 Subject: [PATCH 110/279] ref(pkg/action): split test of filterList (#6875) The existing unit test doesn't cover the most important functionality of filterList(). Adding that check. Separately test the specific namespace-related behavior. Remove the dead variable anotherOldOne. Signed-off-by: Jakub Bielecki --- pkg/action/list_test.go | 55 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/pkg/action/list_test.go b/pkg/action/list_test.go index cd86aee68..378a747b0 100644 --- a/pkg/action/list_test.go +++ b/pkg/action/list_test.go @@ -237,27 +237,36 @@ func makeMeSomeReleases(store *storage.Storage, t *testing.T) { } func TestFilterList(t *testing.T) { - one := releaseStub() - one.Name = "one" - one.Namespace = "default" - one.Version = 1 - two := releaseStub() - two.Name = "two" - two.Namespace = "default" - two.Version = 1 - anotherOldOne := releaseStub() - anotherOldOne.Name = "one" - anotherOldOne.Namespace = "testing" - anotherOldOne.Version = 1 - anotherOne := releaseStub() - anotherOne.Name = "one" - anotherOne.Namespace = "testing" - anotherOne.Version = 2 - - list := []*release.Release{one, two, anotherOne} - expectedFilteredList := []*release.Release{one, two, anotherOne} - - filteredList := filterList(list) - - assert.ElementsMatch(t, expectedFilteredList, filteredList) + t.Run("should filter old versions of the same release", func(t *testing.T) { + r1 := releaseStub() + r1.Name = "r" + r1.Version = 1 + r2 := releaseStub() + r2.Name = "r" + r2.Version = 2 + another := releaseStub() + another.Name = "another" + another.Version = 1 + + filteredList := filterList([]*release.Release{r1, r2, another}) + expectedFilteredList := []*release.Release{r2, another} + + assert.ElementsMatch(t, expectedFilteredList, filteredList) + }) + + t.Run("should not filter out any version across namespaces", func(t *testing.T) { + r1 := releaseStub() + r1.Name = "r" + r1.Namespace = "default" + r1.Version = 1 + r2 := releaseStub() + r2.Name = "r" + r2.Namespace = "testing" + r2.Version = 2 + + filteredList := filterList([]*release.Release{r1, r2}) + expectedFilteredList := []*release.Release{r1, r2} + + assert.ElementsMatch(t, expectedFilteredList, filteredList) + }) } From 0fd76b2a2bca5b3febf6488c860a7c6502c70086 Mon Sep 17 00:00:00 2001 From: kvendingoldo Date: Fri, 13 Dec 2019 20:50:25 +0400 Subject: [PATCH 111/279] fix(cmd): Add message about deprecated chart (#6889) Signed-off-by: Alexander Sharov --- cmd/helm/install.go | 5 +++++ cmd/helm/install_test.go | 6 ++++++ cmd/helm/testdata/output/deprecated-chart.txt | 7 +++++++ cmd/helm/testdata/testcharts/deprecated/Chart.yaml | 8 ++++++++ cmd/helm/testdata/testcharts/deprecated/README.md | 3 +++ cmd/helm/upgrade.go | 4 ++++ 6 files changed, 33 insertions(+) create mode 100644 cmd/helm/testdata/output/deprecated-chart.txt create mode 100644 cmd/helm/testdata/testcharts/deprecated/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/deprecated/README.md diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 176250f84..b75dfce74 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "fmt" "io" "time" @@ -182,6 +183,10 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options return nil, err } + if chartRequested.Metadata.Deprecated { + fmt.Fprintln(out, "WARNING: This chart is deprecated") + } + if req := chartRequested.Metadata.Dependencies; req != nil { // If CheckDependencies returns an error, we have unfulfilled dependencies. // As of Helm 2.4.0, this is treated as a stopping condition: diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index 9ab25417b..e8b573dfc 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -183,6 +183,12 @@ func TestInstall(t *testing.T) { wantError: true, golden: "output/subchart-schema-cli-negative.txt", }, + // Install deprecated chart + { + name: "install with warning about deprecated chart", + cmd: "install aeneas testdata/testcharts/deprecated --namespace default", + golden: "output/deprecated-chart.txt", + }, } runTestActionCmd(t, tests) diff --git a/cmd/helm/testdata/output/deprecated-chart.txt b/cmd/helm/testdata/output/deprecated-chart.txt new file mode 100644 index 000000000..e5be2c3f1 --- /dev/null +++ b/cmd/helm/testdata/output/deprecated-chart.txt @@ -0,0 +1,7 @@ +WARNING: This chart is deprecated +NAME: aeneas +LAST DEPLOYED: Fri Sep 2 22:04:05 1977 +NAMESPACE: default +STATUS: deployed +REVISION: 1 +TEST SUITE: None diff --git a/cmd/helm/testdata/testcharts/deprecated/Chart.yaml b/cmd/helm/testdata/testcharts/deprecated/Chart.yaml new file mode 100644 index 000000000..10185beeb --- /dev/null +++ b/cmd/helm/testdata/testcharts/deprecated/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +description: Deprecated testing chart +home: https://helm.sh/helm +name: deprecated +sources: + - https://github.com/helm/helm +version: 0.1.0 +deprecated: true diff --git a/cmd/helm/testdata/testcharts/deprecated/README.md b/cmd/helm/testdata/testcharts/deprecated/README.md new file mode 100644 index 000000000..0df9a8bbc --- /dev/null +++ b/cmd/helm/testdata/testcharts/deprecated/README.md @@ -0,0 +1,3 @@ +#Deprecated + +This space intentionally left blank. diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index dce8ad74f..acfc23198 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -127,6 +127,10 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } } + if ch.Metadata.Deprecated { + fmt.Fprintln(out, "WARNING: This chart is deprecated") + } + rel, err := client.Run(args[0], ch, vals) if err != nil { return errors.Wrap(err, "UPGRADE FAILED") From 1efdd2ed628f7fb8b51393cc1abe93f83cfa3cee Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 13 Dec 2019 13:33:36 -0500 Subject: [PATCH 112/279] Updating to sprig 3.0.2 to bring in a bugfix Signed-off-by: Matt Farina --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 57b342ed2..8e972fdfe 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e // indirect - github.com/Masterminds/semver/v3 v3.0.1 - github.com/Masterminds/sprig/v3 v3.0.0 + github.com/Masterminds/semver/v3 v3.0.3 + github.com/Masterminds/sprig/v3 v3.0.2 github.com/Masterminds/vcs v1.13.0 github.com/Microsoft/go-winio v0.4.12 // indirect github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a diff --git a/go.sum b/go.sum index 5659b06f8..fb11fdbc4 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,12 @@ github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RP github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.0.1 h1:2kKm5lb7dKVrt5TYUiAavE6oFc1cFT0057UVGT+JqLk= github.com/Masterminds/semver/v3 v3.0.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/semver/v3 v3.0.3 h1:znjIyLfpXEDQjOIEWh+ehwpTU14UzUPub3c3sm36u14= +github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/sprig/v3 v3.0.0 h1:KSQz7Nb08/3VU9E4ns29dDxcczhOD1q7O1UfM4G3t3g= github.com/Masterminds/sprig/v3 v3.0.0/go.mod h1:NEUY/Qq8Gdm2xgYA+NwJM6wmfdRV9xkh8h/Rld20R0U= +github.com/Masterminds/sprig/v3 v3.0.2 h1:wz22D0CiSctrliXiI9ZO3HoNApweeRGftyDN+BQa3B8= +github.com/Masterminds/sprig/v3 v3.0.2/go.mod h1:oesJ8kPONMONaZgtiHNzUShJbksypC5kWczhZAf6+aU= github.com/Masterminds/vcs v1.13.0 h1:USF5TvZGYgIpcbNAEMLfFhHqP08tFZVlUVrmTSpqnyA= github.com/Masterminds/vcs v1.13.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= From 0eaa881c4e699910f1db97ac889f573124f002f3 Mon Sep 17 00:00:00 2001 From: Jason Pickens Date: Tue, 17 Dec 2019 03:47:24 +1300 Subject: [PATCH 113/279] Add missing statuses to the status help text (#7035) Signed-off-by: Jason Pickens --- cmd/helm/status.go | 3 ++- pkg/release/status.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 92e12dbe0..92a947c26 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -31,12 +31,13 @@ import ( "helm.sh/helm/v3/pkg/release" ) +// NOTE: Keep the list of statuses up-to-date with pkg/release/status.go. var statusHelp = ` This command shows the status of a named release. The status consists of: - last deployment time - k8s namespace in which the release lives -- state of the release (can be: unknown, deployed, deleted, superseded, failed or deleting) +- state of the release (can be: unknown, deployed, uninstalled, superseded, failed, uninstalling, pending-install, pending-upgrade or pending-rollback) - list of resources that this release consists of, sorted by kind - details on last test suite run, if applicable - additional notes provided by the chart diff --git a/pkg/release/status.go b/pkg/release/status.go index cd025e279..0e535f9a4 100644 --- a/pkg/release/status.go +++ b/pkg/release/status.go @@ -19,6 +19,7 @@ package release type Status string // Describe the status of a release +// NOTE: Make sure to update cmd/helm/status.go when adding or modifying any of these statuses. const ( // StatusUnknown indicates that a release is in an uncertain state. StatusUnknown Status = "unknown" From a3f00fde691585ffa2dc4934c6813d69ff0ec284 Mon Sep 17 00:00:00 2001 From: Lennard Eijsackers Date: Mon, 16 Dec 2019 18:14:06 +0100 Subject: [PATCH 114/279] fix(helm): Validate number of arguments in install client The 'helm install' command returned confusing error messages if a flag was misspecified (e.g. `helm install name chart --set value foo`). This lead to an error indicating that a name should be specified for the command. Now an explicit check is done on the number of arguments passed, returning a message indicating the invalid arguments (`foo` in the example`). Closes #7225 Signed-off-by: Lennard Eijsackers --- pkg/action/install.go | 4 ++++ pkg/action/install_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/pkg/action/install.go b/pkg/action/install.go index 89a343a6f..dc5941810 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -555,6 +555,10 @@ func (i *Install) NameAndChart(args []string) (string, string, error) { return nil } + if len(args) > 2 { + return args[0], args[1], errors.Errorf("expected at most two arguments, unexpected arguments: %v", strings.Join(args[2:], ", ")) + } + if len(args) == 2 { return args[0], args[1], flagsNotSet() } diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 4637a4b10..d6f1c88cd 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -505,6 +505,14 @@ func TestNameAndChart(t *testing.T) { t.Fatal("expected an error") } is.Equal("must either provide a name or specify --generate-name", err.Error()) + + instAction.NameTemplate = "" + instAction.ReleaseName = "" + _, _, err = instAction.NameAndChart([]string{"foo", chartName, "bar"}) + if err == nil { + t.Fatal("expected an error") + } + is.Equal("expected at most two arguments, unexpected arguments: bar", err.Error()) } func TestNameAndChartGenerateName(t *testing.T) { From 4d8160eedf43db8ed137906a8af0c5d67e03e4fe Mon Sep 17 00:00:00 2001 From: Andreas Sommer Date: Wed, 30 Oct 2019 22:22:42 +0100 Subject: [PATCH 115/279] feat(template): process manifests in file path order, then in order found in each file (before sorting manifests) Signed-off-by: Andreas Sommer --- cmd/helm/helm_test.go | 39 ++-- cmd/helm/template_test.go | 8 + cmd/helm/testdata/output/object-order.txt | 191 ++++++++++++++++++ .../testcharts/object-order/Chart.yaml | 5 + .../object-order/templates/01-a.yml | 57 ++++++ .../object-order/templates/02-b.yml | 143 +++++++++++++ .../testcharts/object-order/values.yaml | 0 pkg/releaseutil/kind_sorter.go | 8 +- pkg/releaseutil/kind_sorter_test.go | 8 +- pkg/releaseutil/manifest.go | 18 +- pkg/releaseutil/manifest_sorter.go | 29 ++- 11 files changed, 472 insertions(+), 34 deletions(-) create mode 100644 cmd/helm/testdata/output/object-order.txt create mode 100644 cmd/helm/testdata/testcharts/object-order/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/object-order/templates/01-a.yml create mode 100644 cmd/helm/testdata/testcharts/object-order/templates/02-b.yml create mode 100644 cmd/helm/testdata/testcharts/object-order/values.yaml diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 924e8e9d3..a08720e7a 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -47,24 +47,26 @@ func init() { func runTestCmd(t *testing.T, tests []cmdTestCase) { t.Helper() for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer resetEnv()() - - storage := storageFixture() - for _, rel := range tt.rels { - if err := storage.Create(rel); err != nil { - t.Fatal(err) + for i := 0; i <= tt.repeat; i++ { + t.Run(tt.name, func(t *testing.T) { + defer resetEnv()() + + storage := storageFixture() + for _, rel := range tt.rels { + if err := storage.Create(rel); err != nil { + t.Fatal(err) + } } - } - t.Log("running cmd: ", tt.cmd) - _, out, err := executeActionCommandC(storage, tt.cmd) - if (err != nil) != tt.wantError { - t.Errorf("expected error, got '%v'", err) - } - if tt.golden != "" { - test.AssertGoldenString(t, out, tt.golden) - } - }) + t.Logf("running cmd (attempt %d): %s", i+1, tt.cmd) + _, out, err := executeActionCommandC(storage, tt.cmd) + if (err != nil) != tt.wantError { + t.Errorf("expected error, got '%v'", err) + } + if tt.golden != "" { + test.AssertGoldenString(t, out, tt.golden) + } + }) + } } } @@ -124,6 +126,9 @@ type cmdTestCase struct { wantError bool // Rels are the available releases at the start of the test. rels []*release.Release + // Number of repeats (in case a feature was previously flaky and the test checks + // it's now stably producing identical results). 0 means test is run exactly once. + repeat int } func executeActionCommand(cmd string) (*cobra.Command, string, error) { diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 735829432..35a8e996b 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -84,6 +84,14 @@ func TestTemplateCmd(t *testing.T) { cmd: fmt.Sprintf("template '%s' --include-crds", chartPath), golden: "output/template-with-crds.txt", }, + { + name: "sorted output of manifests (order of filenames, then order of objects within each YAML file)", + cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/object-order"), + golden: "output/object-order.txt", + // Helm previously used random file order. Repeat the test so we + // don't accidentally get the expected result. + repeat: 10, + }, } runTestCmd(t, tests) } diff --git a/cmd/helm/testdata/output/object-order.txt b/cmd/helm/testdata/output/object-order.txt new file mode 100644 index 000000000..307f928f2 --- /dev/null +++ b/cmd/helm/testdata/output/object-order.txt @@ -0,0 +1,191 @@ +--- +# Source: object-order/templates/01-a.yml +# 1 +kind: NetworkPolicy +apiVersion: networking.k8s.io/v1 +metadata: + name: first +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/01-a.yml +# 2 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: second +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/01-a.yml +# 3 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: third +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 5 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: fifth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 7 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: seventh +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 8 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: eighth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 9 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: ninth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 10 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: tenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 11 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: eleventh +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 12 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: twelfth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 13 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: thirteenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 14 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: fourteenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/02-b.yml +# 15 (11th object within 02-b.yml, in order to test `SplitManifests` which assigns `manifest-10` +# to this object which should then come *after* `manifest-9`) +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: fifteenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress +--- +# Source: object-order/templates/01-a.yml +# 4 (Deployment should come after all NetworkPolicy manifests, since 'helm template' outputs in install order) +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fourth +spec: + selector: + matchLabels: + pod: fourth + replicas: 1 + template: + metadata: + labels: + pod: fourth + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/node-hello:1.0 +--- +# Source: object-order/templates/02-b.yml +# 6 (implementation detail: currently, 'helm template' outputs hook manifests last; and yes, NetworkPolicy won't make a reasonable hook, this is just a dummy unit test manifest) +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + annotations: + "helm.sh/hook": pre-install + name: sixth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress diff --git a/cmd/helm/testdata/testcharts/object-order/Chart.yaml b/cmd/helm/testdata/testcharts/object-order/Chart.yaml new file mode 100644 index 000000000..d2eb42fd7 --- /dev/null +++ b/cmd/helm/testdata/testcharts/object-order/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: object-order +description: Test ordering of manifests in output +type: application +version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml b/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml new file mode 100644 index 000000000..32aa4a475 --- /dev/null +++ b/cmd/helm/testdata/testcharts/object-order/templates/01-a.yml @@ -0,0 +1,57 @@ +# 1 +kind: NetworkPolicy +apiVersion: networking.k8s.io/v1 +metadata: + name: first +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 2 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: second +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 3 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: third +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 4 (Deployment should come after all NetworkPolicy manifests, since 'helm template' outputs in install order) +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fourth +spec: + selector: + matchLabels: + pod: fourth + replicas: 1 + template: + metadata: + labels: + pod: fourth + spec: + containers: + - name: hello-world + image: gcr.io/google-samples/node-hello:1.0 diff --git a/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml b/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml new file mode 100644 index 000000000..895db8cf7 --- /dev/null +++ b/cmd/helm/testdata/testcharts/object-order/templates/02-b.yml @@ -0,0 +1,143 @@ +# 5 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: fifth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 6 (implementation detail: currently, 'helm template' outputs hook manifests last; and yes, NetworkPolicy won't make a reasonable hook, this is just a dummy unit test manifest) +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + annotations: + "helm.sh/hook": pre-install + name: sixth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 7 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: seventh +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 8 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: eighth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 9 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: ninth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 10 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: tenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 11 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: eleventh +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 12 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: twelfth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 13 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: thirteenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 14 +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: fourteenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress + +--- + +# 15 (11th object within 02-b.yml, in order to test `SplitManifests` which assigns `manifest-10` +# to this object which should then come *after* `manifest-9`) +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: fifteenth +spec: + podSelector: {} + policyTypes: + - Egress + - Ingress diff --git a/cmd/helm/testdata/testcharts/object-order/values.yaml b/cmd/helm/testdata/testcharts/object-order/values.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/releaseutil/kind_sorter.go b/pkg/releaseutil/kind_sorter.go index a5110a100..874a47c2a 100644 --- a/pkg/releaseutil/kind_sorter.go +++ b/pkg/releaseutil/kind_sorter.go @@ -101,10 +101,10 @@ var UninstallOrder KindSortOrder = []string{ // sortByKind does an in-place sort of manifests by Kind. // -// Results are sorted by 'ordering' +// Results are sorted by 'ordering', keeping order of items with equal kind/priority func sortByKind(manifests []Manifest, ordering KindSortOrder) []Manifest { ks := newKindSorter(manifests, ordering) - sort.Sort(ks) + sort.Stable(ks) return ks.manifests } @@ -134,13 +134,11 @@ func (k *kindSorter) Less(i, j int) bool { b := k.manifests[j] first, aok := k.ordering[a.Head.Kind] second, bok := k.ordering[b.Head.Kind] - // if same kind (including unknown) sub sort alphanumeric if first == second { // if both are unknown and of different kind sort by kind alphabetically if !aok && !bok && a.Head.Kind != b.Head.Kind { return a.Head.Kind < b.Head.Kind } - return a.Name < b.Name } // unknown kind is last if !aok { @@ -149,6 +147,6 @@ func (k *kindSorter) Less(i, j int) bool { if !bok { return true } - // sort different kinds + // sort different kinds, keep original order if same priority return first < second } diff --git a/pkg/releaseutil/kind_sorter_test.go b/pkg/releaseutil/kind_sorter_test.go index 93d8ae782..e1dfc39cc 100644 --- a/pkg/releaseutil/kind_sorter_test.go +++ b/pkg/releaseutil/kind_sorter_test.go @@ -185,8 +185,8 @@ func TestKindSorter(t *testing.T) { } } -// TestKindSorterSubSort verifies manifests of same kind are also sorted alphanumeric -func TestKindSorterSubSort(t *testing.T) { +// TestKindSorterKeepOriginalOrder verifies manifests of same kind are kept in original order +func TestKindSorterKeepOriginalOrder(t *testing.T) { manifests := []Manifest{ { Name: "a", @@ -230,8 +230,8 @@ func TestKindSorterSubSort(t *testing.T) { order KindSortOrder expected string }{ - // expectation is sorted by kind (unknown is last) and then sub sorted alphabetically within each group - {"cm,clusterRole,clusterRoleBinding,Unknown,Unknown2", InstallOrder, "01Aa!zu1u2t3"}, + // expectation is sorted by kind (unknown is last) and within each group of same kind, the order is kept + {"cm,clusterRole,clusterRoleBinding,Unknown,Unknown2", InstallOrder, "01aAz!u2u1t3"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { diff --git a/pkg/releaseutil/manifest.go b/pkg/releaseutil/manifest.go index 37503b390..0b04a4599 100644 --- a/pkg/releaseutil/manifest.go +++ b/pkg/releaseutil/manifest.go @@ -19,6 +19,7 @@ package releaseutil import ( "fmt" "regexp" + "strconv" "strings" ) @@ -37,8 +38,9 @@ var sep = regexp.MustCompile("(?:^|\\s*\n)---\\s*") // SplitManifests takes a string of manifest and returns a map contains individual manifests func SplitManifests(bigFile string) map[string]string { // Basically, we're quickly splitting a stream of YAML documents into an - // array of YAML docs. In the current implementation, the file name is just - // a place holder, and doesn't have any further meaning. + // array of YAML docs. The file name is just a place holder, but should be + // integer-sortable so that manifests get output in the same order as the + // input (see `BySplitManifestsOrder`). tpl := "manifest-%d" res := map[string]string{} // Making sure that any extra whitespace in YAML stream doesn't interfere in splitting documents correctly. @@ -56,3 +58,15 @@ func SplitManifests(bigFile string) map[string]string { } return res } + +// BySplitManifestsOrder sorts by in-file manifest order, as provided in function `SplitManifests` +type BySplitManifestsOrder []string + +func (a BySplitManifestsOrder) Len() int { return len(a) } +func (a BySplitManifestsOrder) Less(i, j int) bool { + // Split `manifest-%d` + anum, _ := strconv.ParseInt(a[i][len("manifest-"):], 10, 0) + bnum, _ := strconv.ParseInt(a[j][len("manifest-"):], 10, 0) + return anum < bnum +} +func (a BySplitManifestsOrder) Swap(i, j int) { a[i], a[j] = a[j], a[i] } diff --git a/pkg/releaseutil/manifest_sorter.go b/pkg/releaseutil/manifest_sorter.go index 5f4b4e8d9..24b0c3c95 100644 --- a/pkg/releaseutil/manifest_sorter.go +++ b/pkg/releaseutil/manifest_sorter.go @@ -19,6 +19,7 @@ package releaseutil import ( "log" "path" + "sort" "strconv" "strings" @@ -74,10 +75,17 @@ var events = map[string]release.HookEvent{ // // Files that do not parse into the expected format are simply placed into a map and // returned. -func SortManifests(files map[string]string, apis chartutil.VersionSet, sort KindSortOrder) ([]*release.Hook, []Manifest, error) { +func SortManifests(files map[string]string, apis chartutil.VersionSet, ordering KindSortOrder) ([]*release.Hook, []Manifest, error) { result := &result{} - for filePath, c := range files { + var sortedFilePaths []string + for filePath := range files { + sortedFilePaths = append(sortedFilePaths, filePath) + } + sort.Strings(sortedFilePaths) + + for _, filePath := range sortedFilePaths { + content := files[filePath] // Skip partials. We could return these as a separate map, but there doesn't // seem to be any need for that at this time. @@ -85,12 +93,12 @@ func SortManifests(files map[string]string, apis chartutil.VersionSet, sort Kind continue } // Skip empty files and log this. - if strings.TrimSpace(c) == "" { + if strings.TrimSpace(content) == "" { continue } manifestFile := &manifestFile{ - entries: SplitManifests(c), + entries: SplitManifests(content), path: filePath, apis: apis, } @@ -100,7 +108,7 @@ func SortManifests(files map[string]string, apis chartutil.VersionSet, sort Kind } } - return result.hooks, sortByKind(result.generic, sort), nil + return result.hooks, sortByKind(result.generic, ordering), nil } // sort takes a manifestFile object which may contain multiple resource definition @@ -123,7 +131,16 @@ func SortManifests(files map[string]string, apis chartutil.VersionSet, sort Kind // annotations: // helm.sh/hook-delete-policy: hook-succeeded func (file *manifestFile) sort(result *result) error { - for _, m := range file.entries { + // Go through manifests in order found in file (function `SplitManifests` creates integer-sortable keys) + var sortedEntryKeys []string + for entryKey := range file.entries { + sortedEntryKeys = append(sortedEntryKeys, entryKey) + } + sort.Sort(BySplitManifestsOrder(sortedEntryKeys)) + + for _, entryKey := range sortedEntryKeys { + m := file.entries[entryKey] + var entry SimpleHead if err := yaml.Unmarshal([]byte(m), &entry); err != nil { return errors.Wrapf(err, "YAML parse error on %s", file.path) From 1c6424cb189817c46dc7ea3e3812f7f75df52cff Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Tue, 17 Dec 2019 01:30:41 +0530 Subject: [PATCH 116/279] fix(install) crd install with apiextensions.k8s.io/v1 Signed-off-by: Vibhav Bobade --- pkg/kube/client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index ab1f600ff..1811a6bfb 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -30,6 +30,7 @@ import ( "github.com/pkg/errors" batch "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" + apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -60,6 +61,10 @@ func New(getter genericclioptions.RESTClientGetter) *Client { getter = genericclioptions.NewConfigFlags(true) } // Add CRDs to the scheme. They are missing by default. + if err := apiextv1.AddToScheme(scheme.Scheme); err != nil { + // This should never happen. + panic(err) + } if err := apiextv1beta1.AddToScheme(scheme.Scheme); err != nil { // This should never happen. panic(err) From 3973fa877f766f8aa113db0e04fb070bc5e4dd96 Mon Sep 17 00:00:00 2001 From: Jakub Bielecki Date: Fri, 15 Nov 2019 12:07:10 +0100 Subject: [PATCH 117/279] doc(helmpath) move licensing info out of godoc Add intervening line into lazypath.go, so that license is not treated by godoc as a package description. Standardize license comment for xdg package. Add missing package descriptions. Signed-off-by: Jakub Bielecki --- pkg/helmpath/home.go | 1 + pkg/helmpath/lazypath.go | 1 + pkg/helmpath/xdg/xdg.go | 26 ++++++++++++++++---------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pkg/helmpath/home.go b/pkg/helmpath/home.go index 0b0f110a5..760d068a6 100644 --- a/pkg/helmpath/home.go +++ b/pkg/helmpath/home.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package helmpath calculates filesystem paths to Helm's configuration, cache and data. package helmpath // This helper builds paths to Helm's configuration, cache and data paths. diff --git a/pkg/helmpath/lazypath.go b/pkg/helmpath/lazypath.go index 5fecfc75f..0b9068671 100644 --- a/pkg/helmpath/lazypath.go +++ b/pkg/helmpath/lazypath.go @@ -10,6 +10,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package helmpath import ( diff --git a/pkg/helmpath/xdg/xdg.go b/pkg/helmpath/xdg/xdg.go index 010e1138b..eaa3e6864 100644 --- a/pkg/helmpath/xdg/xdg.go +++ b/pkg/helmpath/xdg/xdg.go @@ -1,16 +1,22 @@ -// 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 +/* +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 -// http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Package xdg holds constants pertaining to XDG Base Directory Specification. +// +// The XDG Base Directory Specification https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +// specifies the environment variables that define user-specific base directories for various categories of files. package xdg const ( From d564d4bf2d6c6a9781439db231c4aaa1d7a916f8 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Tue, 22 Oct 2019 03:00:26 +0000 Subject: [PATCH 118/279] first lookup template function implementation Signed-off-by: raffaelespazzoli --- pkg/engine/funcs.go | 1 + pkg/engine/lookup_func.go | 118 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 pkg/engine/lookup_func.go diff --git a/pkg/engine/funcs.go b/pkg/engine/funcs.go index dac105e74..eb4a398f4 100644 --- a/pkg/engine/funcs.go +++ b/pkg/engine/funcs.go @@ -53,6 +53,7 @@ func funcMap() template.FuncMap { "fromYaml": fromYAML, "toJson": toJSON, "fromJson": fromJSON, + "lookup" : lookup, // This is a placeholder for the "include" function, which is // late-bound to a template. By declaring it here, we preserve the diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go new file mode 100644 index 000000000..fe127d8f3 --- /dev/null +++ b/pkg/engine/lookup_func.go @@ -0,0 +1,118 @@ +package engine + +import ( + "flag" + "log" + "os" + "path/filepath" + "strings" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" +) + +var config *rest.Config +var addLookupFunction = false + +func init() { + // try the out-cluster config, this will default to the in-cluster config is not successful + var kubeconfig *string + if home := homeDir(); home != "" { + kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file") + } else { + kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file") + } + flag.Parse() + + // use the current context in kubeconfig + config1, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) + if err == nil { + addLookupFunction = true + config = config1 + } + return +} + +func homeDir() string { + if h := os.Getenv("HOME"); h != "" { + return h + } + return os.Getenv("USERPROFILE") // windows +} + +func lookup(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) { + var client dynamic.ResourceInterface + c, err := getDynamicClientOnKind(apiversion, resource) + if err != nil { + return map[string]interface{}{}, err + } + if namespace != "" { + client = c.Namespace(namespace) + } else { + client = c + } + if name != "" { + //this will return a single object + obj, err := client.Get(name, metav1.GetOptions{}) + if err != nil { + return map[string]interface{}{}, err + } + return obj.Object, nil + } + //this will return a list + obj, err := client.List(metav1.ListOptions{}) + if err != nil { + return map[string]interface{}{}, err + } + return obj.Object, nil + +} + +// GetDynamicClientOnUnstructured returns a dynamic client on an Unstructured type. This client can be further namespaced. +func getDynamicClientOnKind(apiversion string, kind string) (dynamic.NamespaceableResourceInterface, error) { + gvk := schema.FromAPIVersionAndKind(apiversion, kind) + apiRes, err := getAPIReourceForGVK(gvk) + if err != nil { + log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + return nil, err + } + gvr := schema.GroupVersionResource{ + Group: apiRes.Group, + Version: apiRes.Version, + Resource: apiRes.Name, + } + intf, err := dynamic.NewForConfig(config) + if err != nil { + log.Printf("[ERROR] unable to get dynamic client %s", err) + return nil, err + } + res := intf.Resource(gvr) + return res, nil +} + +func getAPIReourceForGVK(gvk schema.GroupVersionKind) (metav1.APIResource, error) { + res := metav1.APIResource{} + discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) + if err != nil { + log.Printf("[ERROR] unable to create discovery client %s", err) + return res, err + } + resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) + if err != nil { + log.Printf("[ERROR] unable to retrieve resouce list for: %s , error: %s", gvk.GroupVersion().String(), err) + return res, err + } + for _, resource := range resList.APIResources { + if resource.Kind == gvk.Kind && !strings.Contains(resource.Name, "/") { + res = resource + res.Group = gvk.Group + res.Version = gvk.Version + break + } + } + return res, nil +} From 30d245a0e30804b154574a90a23e697ab3724dca Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Wed, 23 Oct 2019 06:33:27 -0400 Subject: [PATCH 119/279] added check on namespaced resource Signed-off-by: raffaelespazzoli --- pkg/engine/lookup_func.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index fe127d8f3..fd3768292 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -46,11 +46,11 @@ func homeDir() string { func lookup(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) { var client dynamic.ResourceInterface - c, err := getDynamicClientOnKind(apiversion, resource) + c, namespaced, err := getDynamicClientOnKind(apiversion, resource) if err != nil { return map[string]interface{}{}, err } - if namespace != "" { + if namespaced && namespace != "" { client = c.Namespace(namespace) } else { client = c @@ -73,12 +73,12 @@ func lookup(apiversion string, resource string, namespace string, name string) ( } // GetDynamicClientOnUnstructured returns a dynamic client on an Unstructured type. This client can be further namespaced. -func getDynamicClientOnKind(apiversion string, kind string) (dynamic.NamespaceableResourceInterface, error) { +func getDynamicClientOnKind(apiversion string, kind string) (dynamic.NamespaceableResourceInterface, bool, error) { gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIReourceForGVK(gvk) if err != nil { log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, err + return nil, false, err } gvr := schema.GroupVersionResource{ Group: apiRes.Group, @@ -88,10 +88,10 @@ func getDynamicClientOnKind(apiversion string, kind string) (dynamic.Namespaceab intf, err := dynamic.NewForConfig(config) if err != nil { log.Printf("[ERROR] unable to get dynamic client %s", err) - return nil, err + return nil, false, err } res := intf.Resource(gvr) - return res, nil + return res, apiRes.Namespaced, nil } func getAPIReourceForGVK(gvk schema.GroupVersionKind) (metav1.APIResource, error) { From 02ce01b2415fe270a760c984f2e0158b18476573 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Wed, 23 Oct 2019 07:51:53 -0400 Subject: [PATCH 120/279] fixed circle ci issues Signed-off-by: raffaelespazzoli --- pkg/engine/funcs.go | 2 +- pkg/engine/lookup_func.go | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/engine/funcs.go b/pkg/engine/funcs.go index eb4a398f4..6ff10ea72 100644 --- a/pkg/engine/funcs.go +++ b/pkg/engine/funcs.go @@ -53,7 +53,7 @@ func funcMap() template.FuncMap { "fromYaml": fromYAML, "toJson": toJSON, "fromJson": fromJSON, - "lookup" : lookup, + "lookup": lookup, // This is a placeholder for the "include" function, which is // late-bound to a template. By declaring it here, we preserve the diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index fd3768292..75b822f86 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -16,7 +16,6 @@ import ( ) var config *rest.Config -var addLookupFunction = false func init() { // try the out-cluster config, this will default to the in-cluster config is not successful @@ -31,10 +30,8 @@ func init() { // use the current context in kubeconfig config1, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) if err == nil { - addLookupFunction = true config = config1 } - return } func homeDir() string { @@ -103,7 +100,7 @@ func getAPIReourceForGVK(gvk schema.GroupVersionKind) (metav1.APIResource, error } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - log.Printf("[ERROR] unable to retrieve resouce list for: %s , error: %s", gvk.GroupVersion().String(), err) + log.Printf("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { From b3495c73530af98d95783d371dc8a577d1c5c65f Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Wed, 23 Oct 2019 08:13:02 -0400 Subject: [PATCH 121/279] added license header Signed-off-by: raffaelespazzoli --- pkg/engine/lookup_func.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 75b822f86..f8a47ac38 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -1,3 +1,19 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package engine import ( From e98cd621f0c16cf1ee3a53e8324e18bb0f0cc297 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Mon, 4 Nov 2019 15:24:52 -0500 Subject: [PATCH 122/279] added rest client passed with action configuration Signed-off-by: raffaelespazzoli --- pkg/action/install.go | 7 +++- pkg/engine/engine.go | 15 +++++++ pkg/engine/funcs.go | 1 - pkg/engine/lookup_func.go | 86 +++++++++++++++------------------------ 4 files changed, 54 insertions(+), 55 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index dc5941810..8f865ddf9 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -436,7 +436,12 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values } } - files, err := engine.Render(ch, values) + rest, err := c.RESTClientGetter.ToRESTConfig() + if err != nil { + return hs, b, "", err + } + + files, err := engine.RenderWithClient(ch, values, rest) if err != nil { return hs, b, "", err } diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 5a7d54993..c4d5ee5a7 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -27,6 +27,7 @@ import ( "text/template" "github.com/pkg/errors" + "k8s.io/client-go/rest" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" @@ -39,6 +40,8 @@ type Engine struct { Strict bool // In LintMode, some 'required' template values may be missing, so don't fail LintMode bool + // the rest config to connect to te kubernetes api + config *rest.Config } // Render takes a chart, optional values, and value overrides, and attempts to render the Go templates. @@ -71,6 +74,15 @@ func Render(chrt *chart.Chart, values chartutil.Values) (map[string]string, erro return new(Engine).Render(chrt, values) } +// RenderWithClient takes a chart, optional values, and value overrides, and attempts to +// render the Go templates using the default options. This engine is client aware and so can have template +// functions that interact with the client +func RenderWithClient(chrt *chart.Chart, values chartutil.Values, config *rest.Config) (map[string]string, error) { + return Engine{ + config: config, + }.Render(chrt, values) +} + // renderable is an object that can be rendered. type renderable struct { // tpl is the current template. @@ -157,6 +169,9 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render } return val, nil } + if e.config != nil { + funcMap["lookup"] = NewLookupFunction(e.config) + } t.Funcs(funcMap) } diff --git a/pkg/engine/funcs.go b/pkg/engine/funcs.go index 6ff10ea72..dac105e74 100644 --- a/pkg/engine/funcs.go +++ b/pkg/engine/funcs.go @@ -53,7 +53,6 @@ func funcMap() template.FuncMap { "fromYaml": fromYAML, "toJson": toJSON, "fromJson": fromJSON, - "lookup": lookup, // This is a placeholder for the "include" function, which is // late-bound to a template. By declaring it here, we preserve the diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index f8a47ac38..7c5dc78f1 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -17,10 +17,7 @@ limitations under the License. package engine import ( - "flag" "log" - "os" - "path/filepath" "strings" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -28,67 +25,50 @@ import ( "k8s.io/client-go/discovery" "k8s.io/client-go/dynamic" "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" ) -var config *rest.Config +type lookupFunc = func(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) -func init() { - // try the out-cluster config, this will default to the in-cluster config is not successful - var kubeconfig *string - if home := homeDir(); home != "" { - kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file") - } else { - kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file") - } - flag.Parse() - - // use the current context in kubeconfig - config1, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) - if err == nil { - config = config1 - } -} - -func homeDir() string { - if h := os.Getenv("HOME"); h != "" { - return h - } - return os.Getenv("USERPROFILE") // windows -} - -func lookup(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) { - var client dynamic.ResourceInterface - c, namespaced, err := getDynamicClientOnKind(apiversion, resource) - if err != nil { - return map[string]interface{}{}, err - } - if namespaced && namespace != "" { - client = c.Namespace(namespace) - } else { - client = c - } - if name != "" { - //this will return a single object - obj, err := client.Get(name, metav1.GetOptions{}) +func NewLookupFunction(config *rest.Config) lookupFunc { + return func(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) { + var client dynamic.ResourceInterface + c, namespaced, err := getDynamicClientOnKind(apiversion, resource, config) + if err != nil { + return map[string]interface{}{}, err + } + if namespaced && namespace != "" { + client = c.Namespace(namespace) + } else { + client = c + } + if name != "" { + //this will return a single object + obj, err := client.Get(name, metav1.GetOptions{}) + if err != nil { + return map[string]interface{}{}, err + } + return obj.Object, nil + } + //this will return a list + obj, err := client.List(metav1.ListOptions{}) if err != nil { return map[string]interface{}{}, err } return obj.Object, nil } - //this will return a list - obj, err := client.List(metav1.ListOptions{}) - if err != nil { - return map[string]interface{}{}, err - } - return obj.Object, nil - } +// func homeDir() string { +// if h := os.Getenv("HOME"); h != "" { +// return h +// } +// return os.Getenv("USERPROFILE") // windows +// } + // GetDynamicClientOnUnstructured returns a dynamic client on an Unstructured type. This client can be further namespaced. -func getDynamicClientOnKind(apiversion string, kind string) (dynamic.NamespaceableResourceInterface, bool, error) { +func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) (dynamic.NamespaceableResourceInterface, bool, error) { gvk := schema.FromAPIVersionAndKind(apiversion, kind) - apiRes, err := getAPIReourceForGVK(gvk) + apiRes, err := getAPIReourceForGVK(gvk, config) if err != nil { log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) return nil, false, err @@ -107,7 +87,7 @@ func getDynamicClientOnKind(apiversion string, kind string) (dynamic.Namespaceab return res, apiRes.Namespaced, nil } -func getAPIReourceForGVK(gvk schema.GroupVersionKind) (metav1.APIResource, error) { +func getAPIReourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (metav1.APIResource, error) { res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { From 8e088fc4a2a616354872b21d9ceb84e9d55a40de Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Mon, 4 Nov 2019 15:39:09 -0500 Subject: [PATCH 123/279] fixed test issue Signed-off-by: raffaelespazzoli --- pkg/action/install.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 8f865ddf9..1a1ebeeac 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -436,13 +436,21 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values } } - rest, err := c.RESTClientGetter.ToRESTConfig() - if err != nil { - return hs, b, "", err + var files map[string]string + var err2 error + + if c.RESTClientGetter != nil { + rest, err := c.RESTClientGetter.ToRESTConfig() + if err != nil { + files, err2 = engine.Render(ch, values) + } else { + files, err2 = engine.RenderWithClient(ch, values, rest) + } + } else { + files, err2 = engine.Render(ch, values) } - files, err := engine.RenderWithClient(ch, values, rest) - if err != nil { + if err2 != nil { return hs, b, "", err } From 0bb4eaace77687e8226113df6cafef5791940999 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Wed, 11 Dec 2019 20:53:29 -0500 Subject: [PATCH 124/279] addressing some feedback from @thomastaylor312 Signed-off-by: raffaelespazzoli --- pkg/engine/lookup_func.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 7c5dc78f1..747ebee0a 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -47,25 +47,18 @@ func NewLookupFunction(config *rest.Config) lookupFunc { if err != nil { return map[string]interface{}{}, err } - return obj.Object, nil + return obj.UnstructuredContent(), nil } //this will return a list obj, err := client.List(metav1.ListOptions{}) if err != nil { return map[string]interface{}{}, err } - return obj.Object, nil + return obj.UnstructuredContent(), nil } } -// func homeDir() string { -// if h := os.Getenv("HOME"); h != "" { -// return h -// } -// return os.Getenv("USERPROFILE") // windows -// } - -// GetDynamicClientOnUnstructured returns a dynamic client on an Unstructured type. This client can be further namespaced. +// getDynamicClientOnUnstructured returns a dynamic client on an Unstructured type. This client can be further namespaced. func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) (dynamic.NamespaceableResourceInterface, bool, error) { gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIReourceForGVK(gvk, config) @@ -100,6 +93,7 @@ func getAPIReourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (meta return res, err } for _, resource := range resList.APIResources { + //if a resource contains a "/" it's referencing a subresource. we don't support suberesource for now. if resource.Kind == gvk.Kind && !strings.Contains(resource.Name, "/") { res = resource res.Group = gvk.Group From a62ba049624d3212619005bc87fec410a248ca22 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Tue, 17 Dec 2019 08:31:02 -0500 Subject: [PATCH 125/279] additional fixes based on @thomastaylor312 comment Signed-off-by: raffaelespazzoli --- pkg/action/install.go | 5 ++--- pkg/engine/lookup_func.go | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 1a1ebeeac..e185e581b 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -442,10 +442,9 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values if c.RESTClientGetter != nil { rest, err := c.RESTClientGetter.ToRESTConfig() if err != nil { - files, err2 = engine.Render(ch, values) - } else { - files, err2 = engine.RenderWithClient(ch, values, rest) + return hs, b, "", err } + files, err2 = engine.RenderWithClient(ch, values, rest) } else { files, err2 = engine.Render(ch, values) } diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 747ebee0a..c70dda424 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -20,6 +20,7 @@ import ( "log" "strings" + "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/discovery" @@ -64,7 +65,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) apiRes, err := getAPIReourceForGVK(gvk, config) if err != nil { log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, false, err + return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s , error %s", gvk.String()) } gvr := schema.GroupVersionResource{ Group: apiRes.Group, From fa643cfa31af72f06b6d041c310a29bed18f0ac4 Mon Sep 17 00:00:00 2001 From: raffaelespazzoli Date: Tue, 17 Dec 2019 08:37:17 -0500 Subject: [PATCH 126/279] fixed golint Signed-off-by: raffaelespazzoli --- pkg/engine/lookup_func.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index c70dda424..14f2351b4 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -65,7 +65,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) apiRes, err := getAPIReourceForGVK(gvk, config) if err != nil { log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s , error %s", gvk.String()) + return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ Group: apiRes.Group, From b6e2a14306964a6fe756abff85d3195542a2f1fd Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Tue, 17 Dec 2019 17:41:04 +0000 Subject: [PATCH 127/279] fix(kube): Port use of watcher with retries to wait for resources (#7217) * Port watcher with retries to wait for resources Port of Helm 2 PR #6014 to Helm 3 Signed-off-by: Martin Hickey * Add fix from PR #6907 Signed-off-by: Martin Hickey --- pkg/kube/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index ab1f600ff..96179d19d 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -34,6 +34,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" @@ -41,6 +42,7 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes/scheme" + cachetools "k8s.io/client-go/tools/cache" watchtools "k8s.io/client-go/tools/watch" cmdutil "k8s.io/kubectl/pkg/cmd/util" ) @@ -419,10 +421,13 @@ func (c *Client) watchUntilReady(timeout time.Duration, info *resource.Info) err c.Log("Watching for changes to %s %s with timeout of %v", kind, info.Name, timeout) - w, err := resource.NewHelper(info.Client, info.Mapping).WatchSingle(info.Namespace, info.Name, info.ResourceVersion) + // Use a selector on the name of the resource. This should be unique for the + // given version and kind + selector, err := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", info.Name)) if err != nil { return err } + lw := cachetools.NewListWatchFromClient(info.Client, info.Mapping.Resource.Resource, info.Namespace, selector) // What we watch for depends on the Kind. // - For a Job, we watch for completion. @@ -432,7 +437,7 @@ func (c *Client) watchUntilReady(timeout time.Duration, info *resource.Info) err ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) defer cancel() - _, err = watchtools.UntilWithoutRetry(ctx, w, func(e watch.Event) (bool, error) { + _, err = watchtools.ListWatchUntil(ctx, lw, func(e watch.Event) (bool, error) { // Make sure the incoming object is versioned as we use unstructured // objects when we build manifests obj := convertWithMapper(e.Object, info.Mapping) From bd8dbcac8bb9252d501c8c6f5b0c13828ac33a6e Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 17 Dec 2019 11:33:52 -0700 Subject: [PATCH 128/279] add technosophos public key (#7256) Signed-off-by: Matt Butcher --- KEYS | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) diff --git a/KEYS b/KEYS index 929938710..95e52f71c 100644 --- a/KEYS +++ b/KEYS @@ -622,3 +622,233 @@ BlA4kJPTfla4LmKRg/T/xow/naen/aM9mQCs7k2UAoeqNZ6IfQ6G5BZ81H9JNvHC beriLZDBuRy1LJRjBmZEz+UDBgZoR9oz5DOLh8dGVpkt =HZO9 -----END PGP PUBLIC KEY BLOCK----- +pub rsa4096 2014-05-13 [SCEA] + ABA2529598F6626C420D335B62F49E747D911B60 +uid [ unknown] Matt Butcher +sig 3 62F49E747D911B60 2017-08-11 Matt Butcher +sig 461449C25E36B98E 2018-12-12 Matthew Farina +sig 1EF612347F8A9958 2018-12-12 Adam Reese +sig 2CDBBFBB37AE822A 2018-12-12 Adnan Abdulhussein +uid [ unknown] technosophos (keybase.io/technosophos) +sig 3 62F49E747D911B60 2016-10-24 Matt Butcher +sig 461449C25E36B98E 2018-12-12 Matthew Farina +sig 1EF612347F8A9958 2018-12-12 Adam Reese +sig 2CDBBFBB37AE822A 2018-12-12 Adnan Abdulhussein +uid [ unknown] keybase.io/technosophos +sig 3 62F49E747D911B60 2014-05-13 Matt Butcher +sig 461449C25E36B98E 2018-12-12 Matthew Farina +sig 1EF612347F8A9958 2018-12-12 Adam Reese +sig 2CDBBFBB37AE822A 2018-12-12 Adnan Abdulhussein +sub rsa2048 2014-05-13 [S] [expires: 2022-05-11] +sig 62F49E747D911B60 2014-05-13 Matt Butcher +sub rsa2048 2014-05-13 [E] [expires: 2022-05-11] +sig 62F49E747D911B60 2014-05-13 Matt Butcher + +-----BEGIN PGP PUBLIC KEY BLOCK----- +Comment: GPGTools - https://gpgtools.org + +mQINBFNyROIBEADL6FVlqQPC2DAZS8RGYs9Kiqpu486QI6070Nq1l950XxUdudkm +dM8TH0FluDkq/RtQQmVHIwBdL4n/pH7EfKTUy4ggYIs9v2VPhMp7DVlRVKIXKoHl +qQu9I2VI3UNM8j+cQkisFgVrzHi93SHxRKRfJM/qPkQYmzsnBRH/2YAodSOmWybf +TZJToPtkRXqPMm+ZAAtfyhwvwPiXfSnB3/0t5K4WCdhQP601l3fifyaZVVF9GX3Z +n54i080HXYhdxr32n8xPi+EDPv7Sh3XuQZ+zmYmSTxZ12mBIZgzwCJH9Uy9XzmE5 +LrZhf/s4mus5VO7ZxqOr/pZ2edzu3Hae9SwVa96kntHK4Oc5Ja6AYK17dibRG7m6 +1AInGbpJ5oJMvm3MwQbxLXtonZuMr3F+ivdBqrnwjpGHiTfeeuBGasx3WIJwBvzv +94rldvEERAc92eMNEW4G+9tK0w2R8SYP4njWZUKM7ngXRPxA5/vRYj8pzpr/uiFi +YkkzOTo5beueqdAyqaV7GOG2bmzt2Lc5PSGXK/Ew8sLAiOV4ug2QysNMw2MdjF7v +ek6Hco8U+Ir5YQnt4B+t9piDg3w45WGdNfAe5roPZtB9yYox6Iy34fo1GmX4qUf7 +3i99UrZ/B+wgCRjHxsqborquMZnX9S0BeQFm2RV/0S2l5A5NT6yHB4B0hwARAQAB +tD90ZWNobm9zb3Bob3MgKGtleWJhc2UuaW8vdGVjaG5vc29waG9zKSA8dGVjaG5v +c29waG9zQGdtYWlsLmNvbT6JAjcEEwEKACEFAlgOZHsCGy8FCwkIBwMFFQoJCAsF +FgIDAQACHgECF4AACgkQYvSedH2RG2DUXhAAtZGIlCFk8GkhxoUFZgcR+AfgKG39 +bcEdDVulGX0r7LpVO3pF0V7KrY/Hz55fVrQjF6UMS6TF4dB/j4U4ylIdv9UUyQUJ +O9bPJwcYLbSLURqA75NeA7XVSHwvbm6hTCcdnwPxvxkfisd/YUN75mlDNeZEEXs/ +/n+2AxlPX8eQt6n/3RlYYGrekle7EUO8IJcqS8jfSloxkUBO201BubU8lg9bmE4W +uiav6Dgqs1V4q6jheGz+c6BD/PYOysQiet+1Ot0GscvIKgW0w60q7ilzzviOK3eg +fiq57W0Oc3GI4ihrfH3ppC3kcJFyAe/zle25QxWHZWfnNZ12ZElK7vIQnl1JzwVb +sICj+y3j2MUkczHtf4KJZe/7lr1G+No1mFYmDu+GZqT/eSmADOF+IrkoCZgR/jMr +O9Kgfh5U9B7spbHGkA7eZvH68FHRxqvXnUgBFS5hE9oQyTR2EmBF+hpx8T4K2uIo +NSCoq5pTD3HNEZqBZ+E1NQCGv1a8YiyLjeI32vljH52pjtfbW06Nfb4rI+/BrMU2 +82gzVHxiN9O5Ba8YmBLbkZYYTW0+9rF5w0brTxRS4IfokNNeanIJ+w7CuUhEyf0O +yOa0DRxUEvHIq6UFibJWzei2dzBIyHovdIQelkmFr2Oq9LDqsBtSZH5quGzeJ2N/ +atK1HR1GK5CNwRaJAjMEEAEIAB0WIQRnLGV74GtLMJacSldGFEnCXja5jgUCXBE3 +0gAKCRBGFEnCXja5jrJlEACarEjVOWmmZlNkHqajs2rEUJzM+qKThr0QMOd8UvYh +ZpC0+IPOXLjwXpKiZ+7sPw8YaGHw5NK36jWPy+cPdoDppZfRYHp+/0cmK4GI3DH4 +9x/jW3yG9g8ckYCKYscrhev3AeD1UwjjiiQhS5m15/TTOLPGtu4kcWyeTcdgFMo+ +sdiD1w81XA2/zCTJptsDw8AIxJEk+rqBP46qy7kPpawCsO+x1f17tleZ+5pZPYCu +G3vuaC9ggcKIp9K2oifH/Qn1YE4G8Dz9KqDsS3Ucg50PR2tpd2nXQCoWatezNxED +tyNblmx29JJFjSMs9nKNdddDmwWHM8+CNBS9mXRs1BttxtWAPmz2Y/9U4wvQ6V0H +NxZd3JUItOqxkoxVavdMQrbRDLgI8qVXA9LXABJaJ9SccOJfAK+zJVSVcOqrGoVK +7jQyBoHsMbbGl4P2EJtFNIUOiAvo+y0cA6oboAYnqgBr3ghOXWa7uiLB2zFhREro +0VoGlqCjbH6JdvjDcC4Vf9mxtVP42605phBmd6OCDXjTmgn+KToRLKd2i8b/eafZ +5djwipOpyHHxIQ5N+qSI1jxh+58P8x7502kMTHzCoAdxnWk2CT67Imggby3xh8IM +jJmvah5NM5a0eFIGZs8HNuhkbtJBuF6WzVoieBbin+O6/7zvNaS3x0ZcYJPZUpWa +dokCMwQQAQoAHRYhBEnQnIbD3I2j8KB2Ih72EjR/iplYBQJcET/bAAoJEB72EjR/ +iplYOrAP/1b4FsE7QxzYgU2ulBkqDGe9eSWPwuqWORwqpYNPy9UNYKrDn7LO4mfT +GKvVozfR2e8YjDNsP9PfqPjk7OenqiWkzDgwAZFKoFxbu0RFtxA+aMNVOG6ks6g/ +LJH3uvKxqaK0oUTntB9YusdS5B7JOcSzDo9uw+2mRyavxs7aitJmcMmrU6GySmGu +t5Nutsr0j1k5vB7lFNu7PYmc/rQyF7UK45+Q5RSzW7lsvudR6VM7qjE+eHfOOB+t +9Kym2siSrCcwsBsrqGtumXksG3KUFubDr6VG7nUX1y0CkZ8FdtdWnsyssuJy/cUz +sGhoZIXhnP8LAvVS2/0g5U+94K3TfFPrlhq8Dgt4EWOr8icL13QY1ZhlQNW861KP +HEOTtUoNJPg7DafrkB377cfwANk8K3iJAMrWK11TR1obr5brMPFvRqeb1OsDeTmf +PGJkm3DePTKydUNvLwd9FwdG9wsoZVGrn7aRQ59OUn5IdAnuZ5Q9eWnEJf03pTNp +sJ/6cH4XCLy7bM1iim6oknLKpUFWRFxOgMKVeFNQO1h1D96u21bYDXnbKyc2vlIw +sBZbKkHsxWr8AzmCOrWb1DTJO5sYTpsBQkQANQt/IUpNbg5eMC7zdyHUpLEyqQ2E +kfrWOoqoTowXv6xZ7Wdd5/OJHwn4PnsKac4ah3tOMzhQYOAgel+/iQIzBBABCAAd +FiEEURHac98S2OgSykYvLNu/uzeugioFAlwRQU4ACgkQLNu/uzeugiqARA//YEMd +eLItDPOCtLlEYJZ9N3VheUA78IER84cena7RDI38Rra7sh5M+msNJJTYH+mXK1B/ +2Y8tIHo870I300vQLLDXXjGDFWuQRDIXgNkVpk8M0msNqtvTps1Pmf7fxpSeI24a +dGwlyz3oCUELp8bXuyY7LTrNMa8LjNSbS5TdCF0xteuMZdDyD03jDO/fz44Oabtr +fdaIrzDRbw42AxnzR8wrhlR55+EFxWizWERqPLxhXYYhcGk0PyGdZUzcP9YJmjiV +h0605ct+ykiIm0RQ5/YGWkKRC8LIRDYW7NB9Hwv62kjw2pSKcOWm9kaGHOjfieCd +XnBvAPv3sAdcfgx5bP44a2Sh7Bsh8BIqrbsAAG+9b07h7IMM6MCFFxd2smNsp74n +gPR8k4GF7vfVvZherYCB3EhPLoudoxf/u0Ock2Ssa31XStZ+jHb6a/keEPFGnygg +opNDfw5BlUsys7wSEDOSTE3cdiE7B0hWxC5Xw80r3SxONk3jPczraSG/EVmKndX9 +quFboecUIXGBbsx79tUolKTMOQrVP7KIM9ltbpvQShy6RYpWa0dKTRuUgMijqiB4 +A1SR5gvVgKs/xzy2Bw9TAH2ayGc/r+mTpwpa6eOhu3NOYhqqkENlZ/IsKnX+dX55 +UvSVexlttUIjxCKjvH61Pmdi8meNhEesjVYnsbS0MWtleWJhc2UuaW8vdGVjaG5v +c29waG9zIDx0ZWNobm9zb3Bob3NAa2V5YmFzZS5pbz6JAi0EEwEKABcFAlNyROIC +Gy8DCwkHAxUKCAIeAQIXgAAKCRBi9J50fZEbYCnkD/0WpXKEaTdXwqy7fm87An1H +H6HcHDR95+Ldu8XgmSZq4nbkDc0wjDdBD5Tp25QSUznzJ4pKO/Wd7l6C4fhqTZn/ +vldDpRXl23bqvRHmWVkXH/EKZxh1y9TnID7Ysy9H9qRVdFm/yjM9EqrD++/vowYW +Sq6ekosXdjTZWuXVBnirnM/MwSZ/3w1tyK+zfbzA5XR/pscPbTO/UuKdmUbwz4yt +QjSQg+awJ2iRko0USvDG1t7PyMdDNfF+gbzp6qdI/NUo+XicRzCtmxfKR88vD5yE +FD0DY/6xl9172XpB3h5aI1jg2LTDLr0IIlO2KHRkqs9piqJuHL8uA870ZMvLJN9g +JryUny7b5PJlmaYDJPc3TmiMUUHTkrcmJq4Knlh7WtrDX8avbc6T8lWOCakn3cNC +X3O7RW37k953fF3GSgv8otDlySANW20fG5bPN2gvElfHi4LFP9hAXESZUDYuOasu +dRUHMkqc9BAMqqgrgrrY9Qmk1aE+udVTcVICRoUoZyBFVzDsRQL+c1zVBk/kJ8oL +e9cqcdpZbkvVDLtPEyA+b4icX41woqiTRfK28BbKCSwSXkqi+vo9pk9Uwy++S7OS +D3EOjZhox+Zi2Ijcpzb++B2mxX5yroRrPWvHrxIsAKs8ogO9undz+rJbqgZr1PoF +rV+wpMe0ckRECvGqEz0BiYkCMwQQAQgAHRYhBGcsZXvga0swlpxKV0YUScJeNrmO +BQJcETfSAAoJEEYUScJeNrmO1T4P/jAUMiKYNqUlYpCV+mvzVwUQWIyPYdgzqO9R +AmvI1ELCDT1BGB9pLeeUwFXQX/+8+7lGAVLynL7FPPVkkatblVIQKFgvL7XmU6gb +o73DpslX6hn+clYeYXUs37XToffVIFVwIQkWusZ+X9BkM2TeV5fgoJ4mhCh8ys5g +RHKuXYnqCIHfPj033GIhSn1DZRecKPWeb07zYZI4SHsBYEM7xfN4eUEXOjIlRXea +O6hS6N3vBTinn7LnHkRDD9mUemTruBtab2F9Nk3+njzpafMb4IprD5+GGdRacGOq +VNWFlZDYyy+3Qv5A7mXBYGCaTtH5Jlz4oEibFXvvVzD3IgwFCvmU1S+UD+9l+u+z +Nk3F4l07BuulhX6Ek55CoI3kbMCovFjPFrXWghT+/XQy6GaEhQmQ12rhUDBBjS2s +29NImvHyBGX/FHY0udt4fF/h5O0eRw7zqmGeen4yOu60cEi9MVesRz+GZcbdXupe +RghrhXhfE6NHcp7ciyK0+Y8f3dpeXVw3na4EOraR4w4ae+SJUt56Sbudqn7S6Kxj +UCKql68VWHfhh1ibdbv1wl8bAHqtSt0FQlG5mUAcN6R/COO6uK07H2rJWtmIiDAG +nhcSyLY+5SjD7LtRYvZr+SP2EWQ8wHopjkkGfvG1gXl5NQ8gaVRzErkuc4S3yHMC +47j+0GsBiQIzBBABCgAdFiEESdCchsPcjaPwoHYiHvYSNH+KmVgFAlwRP9sACgkQ +HvYSNH+KmVhSoRAArTJp7zUs6pp/+JTFfJsRHbqUBP13KAoZCtaV6auJf+MA6mFD +TD0DpVKdKBGjKna+W/qFn/8lpIjxL6YtQ3/W1j+d+uhd2OPb44atpXNuxArpCqoZ +zAyx0ELmgP1YbZ/DIRKv0v0nFsmP4jd14pcclFKGLqh/tK66n3+mOH7zSqltljV0 +9A4evtkI/29/Jj2I31j2rthk+gJmAYiksXVIZb3Hoj4VjFaW0D3/d7Bc5LaUCY2Z +6GXa208UjBfumKRtSWGXDaz4LmxoS3+H3xfnm3APQIryaSc8daBY0BjDwORa2gUB +9rddEtSWbVZvJoIdAa7shLvR+eYubMCOjmHc5cV3rG0AF+5pymOv+Z9pAIj8Uzfs +kXtmIkoXPRfubeb6rNx66fKakgjXqtcGfe0VdYg/VJiheVedPmqBvePFvuUGvROa +TzDdKxKqi+AR3+JALfcue42xbNCTqWW+iercuKz6gpNukfwuDciNMrH+Ggg8K/FL +x/NEQbVTA+IFZyuBtiRv37gDNf+gRK1buA1OJg6rS1US8CE/brOWEhSDXN1wJ9wM +JHtM6xj/Td/L8v7BYOXbq1ffuuXeX7OOa2NF86yTthS+Hx07y6ivaBRIWhf0DA6I +lQkoKtJJ8dgWtzRgH/Dl18nhgjdqhyaQXnBclxv0B8M3tbpeoJYBRTM/7haJAjME +EAEIAB0WIQRREdpz3xLY6BLKRi8s27+7N66CKgUCXBFBTQAKCRAs27+7N66CKqz6 +EACB4UuPAH70NzoHo9utcD9bzMj0PRi3GKh6MMm0CsumM360HfN9RftOrB+Y3mjq +Oyl4onqz4hWKWWQayUsI3T0YiDwtV3zeGkvyKGMB2gZN/duZplHiSj95Jv7HPQRL +kVo8rrEPboI+EdCCOypZIu8K9vfs/fTrsx14dEy85cOqv4J2is28zOapFoR+79gN +pErktx0ftcv7e2fxXQB5sUAa8k64bRNuVoFXz1HH6T+7641DwQutGAEFWug/Ythj +vytNBlcq0bxpzVwC2RAbPrnJdRu8f1XM4jBx9mJz6NfHGvSjEtlAuc53Y9DvJEcZ +uKwrN2NmtJ0dkO81NaU6B6oT9dwTaJ/6hwHq0WNvPeDcoUZxrh0XXyuhjR/p5MoU +/0TeiwA6HByO+/wQRL5ZODUag8xlsnXHMxwz6F/mqo6OirJzflJdJkm9kL4UKjCB +r/jzOmf6WVQEfjWTFmv2empmxT3Z4ahR60DLRCGPlc6v7N7QshbH74b/NfbP7CPt +SNqQwiPzSTiNjr1SZhMFJ/Zu7HS+/ysXyPw6Ku0s+8zQtkstV9+Oo/mpfm27yDih +scWIZTmc3RiZmL6eURA9tijdB7ZNuXxTyKkClUfnkiba9zdBCZT+n52zXY9aR4OE +KEYFXe/x2A2hON02AP/lzgjEpg/3vaSfLrzk0wMeh+yYjLQpTWF0dCBCdXRjaGVy +IDxtYXR0LmJ1dGNoZXJAbWljcm9zb2Z0LmNvbT6JAk4EEwEKADgWIQSrolKVmPZi +bEINM1ti9J50fZEbYAUCWY4aMQIbLwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAK +CRBi9J50fZEbYCtzD/9WqoGpj/rKKoqoToj3hInc3Nv/Nxj9quJc2Z4gxmnwYlB+ +KhZeDlfCytkFFYXgl4bB6KcpnI/OW+hynxR8jT/wIvD5E3wIUCRVJfbdmKBiSha5 +KMDgLGmVpJbVG83s7mN6BlgYPxUa7dFXI43mRBkt9hCnH7U4vwx5rtLlR5FEU6EL +sjYiWc/zyjqZFLHbnlJ8tt09zKTVDF4SfdJz1vpDCD1exY7LZtsaL1SpE+fuTq+5 +/Z6MvMQk4bJcEbXzrIF1U7C7xIoTv/npv+eb0xdiPto1UKs6C1o2rIdvxbrDc8zz +pWMRSPjBaOuey01rFKrkpSlxuX1h6HQSDyN2Q7WmeezLh3RgoTwrEnmy/Qi5Ze21 +pi2ygMtUadxTzZRi/IC77s4FOlrnqx27AonEzRQHTtKXhLKrrXD6HQTerf7W9v/l +24O/QIAdX/JlhYWHQGPHAWe/3o30XkeM/Bhlt29SAnxeWhTo3oa1EudXrAe745eM +rA/pdAHWgqIBi5KZP0j9nQRtxXN/ZP3ASKjs1CKw4OnwpIWotUkK0XgMemJTgBYR +FmNUPpUCiLTiZxfJbcQt3khDOfQ53iR3xSLP788MHO5/zGqKcOgnjFlyc8QLdLSb +db52l79ZaeXamakEEfaZRnR3wtZjWvLk+JnC9nWEVflICnLwKpLoph+ceVe8j4kC +MwQQAQgAHRYhBGcsZXvga0swlpxKV0YUScJeNrmOBQJcETezAAoJEEYUScJeNrmO +ZJgP/2yhVoDQbp6T1ngsl079C3ZwyDY//TfKXUwAJJgHo84IdrLWhYYTCo1/2nm5 +rAqmDlq3OJsUMucwj8opocEIBM2HWcRcwFJgwC3Caq6w0vLzmt9Qm5eGIwSPGH/Q +7w1YQj+6x++xyYuVdmChVIIgQy5TP2cIuM+c+T2Zq2vTGKV6VNKQpVH/o0ymB7zx +5ZSJdsQGuNWDvZbwsVrYsbbgEy72iO7fVvc3aYUVXL1gvJjAh4GUKApsLWhJGG/G +HoYvl0PSTpb++HOGwtwbG+GG4ELbISfyrs4JfMUvRA2hd7MZD5BTvO9hzWeFAOJR +ze5gsDkUCMeJ2D1yoVONHhmaZ8k9xy88p/NOC3iYamoixO6vVkOsCbOhzHRVlj1a +VV4Zs1RZ6kMgm0HBgGFjj4IjWZy39G+JWfjJuLpRAVOwPv3Km2ertTtJJjkSaTA8 +TRG+/ZjgEse+Gio40aeBhm/2LvM4A1oHe/gzZXQZrHKIl7sy9ijQowj1wuqs+oqz +gdjjBp/DcU3qbTo0vJ6ACvRjQVcIhIdOypkn31uhUSA1CtHT3TNau4/D+B7YNtWZ +egeVXWvzFZukXkYzvbDjMn9t3PYHMPKaPYynBGuFPO0fMBXouh4qOfXywFemB+zu ++ccZol3zPzBhdxInOhWi6wjMBSY1zae0S3Co34CSylZ2lu+kiQIzBBABCgAdFiEE +SdCchsPcjaPwoHYiHvYSNH+KmVgFAlwRP9sACgkQHvYSNH+KmViCHw//dGg9ochq +Wuh344h8SSqq7G5d+Hch7EIMCykPlDCkmO0/FsKEmMQ2nMySpkm1zM59pHvADlbu +tbhtLIk8kAjsfyZF2alpTCn1gxRVe/aXBsgmAf/Op2jf92zPkov8bXw7x1oFZ3ew +fWFR8bwG0OEK8kr9jpkCs2lRv7kG6g60ptsCWDkJGiXpEyovUF0W3ZpCU3RBVUIC +D8xMTBJXOiCYtux7uDpGJ9iYBGD0eUWxg5OUZs6Gmid2sr+rV4WIoBJEgGUMq37f +d+loYNwm36GQmU3ytWx3ZduCruNRf5XSdws+nJU0rPb51CiacPp/g9PR/9f9i9/a +yzao/7pA9/0mfiAXHveK39iNqFH4V0B4hOUzRWWWJJNvZw195LridOcmmgOLTWQJ +iWErD0VvzZRrf5vf8sdsRoXx1gHrgb2ana3ThfRl+7gE9jgkrEZxGZBh6eaxyxpc +eTJBtGjcAgATlKSZSrm9ZLI3Jyz+1R+uEj1LPY6rc05c1XU2l6ucoMGRvu/Vs2m6 +XBiyJeqX5yARdVbiTMbmGI39SxoZ4//KJoFjs71+FxT+sZ3syfQyQJjaS8++qB/e +zmhF4Ab2wh987um42q3Bzl3NXnERFO0Rq5R3ksgBb2ns93Sc6WQPV62pUFxzeHX5 +BcW6vVjL8jkrJuMipKetoZGm5Aimf3oydJ+JAjMEEAEIAB0WIQRREdpz3xLY6BLK +Ri8s27+7N66CKgUCXBFBTQAKCRAs27+7N66CKrU0D/9tCR/N64xwcY1eq5tEjFb0 +9T0L/aP39hcCOWeMwD2AcA5qSM1Fr/gqCs18db9JqZOcTEISrStzQ/ciGj3Dsnlz +7LjYVicQjwNK39YxedfAuU1kPAd2k4KujpE8o9b0Q25nsTOth1ZZyXJIIsrywwVS +CG0shyi2GASuZOXIZOdkYI/SIPojZdQKG8Czd37Lo+2mPDqG5lTL+LUX0UoqEFR0 +AJfsBkZhUodUAJSxzT5sn9ZyBOabAbdFhiwjMHTyvFOdFzIfc5pS+/OqQqdhwxcw +/FyCFyN5WgC6nRxEZqvW2jbB7xphLPWOWxWbogwD4QACQO6ih6pyUAvkcPGRTJRS +j9AuJ7cX1iul0hwxjFifoJGnDyNB0oDo7qyfcOQ5lKlYE6BWQiQHcE8UX4pn0Tk8 +z18pSjh79LxFUgKH9Rvv2eIjE0V/GYFh/RiPxopBRGcqnpo4F5mOvLbeNMN/lX2s +3g8rkpVLa/QWf/d+goak/zVWqLmC/5OMTFnEWrcTu6dVycoEiyfKgf8LRZ4YrSbv +jkeHNuYwM5KVgv+umLOw/p18mUueYmEvpsmQ55Ri2UxxhNWizm3xEtLo1jLGfBUu +7RwuZ3AuR8HMBeOHsWe1/MSpZgmbL0V31mfC0M25CrBs0qBUB1QxpCLv+cSa3Acy +CMfQS9ln8Ydzm2sHPsLZA7kBDQRTckTiAQgA12JICQ4oNax8PaljKomTwuFTCrm4 +6j7Z7HsBM579lqkQmsNaBu8euQF6C5WJUE4aflBIa4Q8vqinZirkdUNvkj2jGdKW +XG+KwGluvbd8IhCvD9ITV52/Sj0V1PqZMcKktRpEczn1KY5BjILXKbtlp1eVa7Ha +VMHHge01c2TH6jttOtasUFBkT0jD/Zd4fO6l1e9cN3e7hhIO6HGqcrhNIaHD1ikG +6VjJU/ndP5qkzwErqlWF2H+TThWaY/PO0zXp5pXQ8geBWPfnw4B6ZvKzoHM54vd+ +aotgoDrNpWMkksm16oAvctXkg/WSt3mzNIHQHQZSYN/uorXek9R8664MmQARAQAB +iQNEBBgBCgAPBQJTckTiBQkPCZwAAhsCASkJEGL0nnR9kRtgwF0gBBkBCgAGBQJT +ckTiAAoJENzV9eXvMsNFID4H/j9fGdHyPQLDvH363lsGx62l5zlX1vL8rjleZMTR +D+JRQJ3MjSgEIdEE8gYLyRmetPsrbQKpOu/uGVs+Ef/SDFj89VhK+661DfHwcahN +XHPTjcNi6OUlE2Z0DXdxgb4czMZkDf79ga/sf72S1uJNQb83GfYN1QfLq+MXsBmF +LfYU5RkoF7obgVQFAs5HYf3RqCribdNEhGEZPPG6wNcp5DC1UvrpotldqwHZltFS +dPPPUT5S/kpcRtqL/bilPc4Pb7qKQR1Huacy1ca1DAEP+TvhvgMmm6ExVAYiV1TA +ZBfOUYC+Czn7ZOGJ8Q4AN0yno4IOsmwBrxaUx9+38I3rb04nLhAAyUUZZGp4Zfj1 +bJ/pOxZ2H2BqX3fstN9tVvZu47D2DoeF6T6x02HIV7oVQ1/haMnjP7rtsWNjrl32 +RkMkbvwqsnQwcZJrylQTxYuzy4IGXak/tlEcesspsG6O34pvPoZ1c+q92jofPOzl +W2xnSTtKlt0Fu/m2WNg6s8tfec7emi69J6Pl+XMAmQkihXF+j4QuXYzSV4G97W2t +AMxo5d3GIQ4UzcxhEvTH5s/S12iGT0xfy6G3yEqTzFgByA94BWN/plzgaaV0bNDs +uK16Sp6c8gldHs5o5uI9wtJa468dj5Ll9zJZOdC3UN3kGDY1T5jnctnfgLpU081c +tfz7tr1URFiq2LYlxpEUC/OUFyilHuM17RacLLAM6+9s2bYFD2uAOfQyUJaUD2z2 +/9I7WRaDbL0DMhn/QZPdhLZSMuuoaBEu99NWBGHMfVpDmmPQeBLTS5l4Q7lbrf6f +zLdb+3Vuhifl6w4UTPC7Wb4qowjtIiaqdtqpsqm2LE62xsvd230wWT+ipGhBx/B4 +soOh2lVXkEGL+nEPTljBxkumkZOTxJl/EC3cFEtVKGCw9Rid8nUmc/v9LcKaJQDO +AZ0oAMc8eSyxKGaW0pePlHn8k5cds1w2ZsSCXuDGNYHATp4Gm3izEGLRsex1KYq+ ++dysRCx2EZMDsaCAUbXNrt12FNhgzh+5AQ0EU3JE4gEIALyimTnOi0q1WouENJKQ +RlpBsZ25Cxp+kc3Ttws65cFYV+3682KMRelDvZ073JRlyMbEmAsxCitrmsKfI8+9 +3TVg9XS5R9RynMpRiyi1m6sHLbeXG6LaWaT3gyzu9VC6EGoadf+l8/emQD2WeDJl +fHJr+QivlGM7hdMvjewj7Wp4+x0JclhNsgjYEUkF4ajy/q+A98YyGFybpOwqRoLv +U5WXQGxuh0LiUjvpLyrIEEFcvASCNOAJgpN92G7nsNDsXpWjwmUDYwM9uJipbM+M +kyWJykiaii9tYg/AzsFN9Cr0+w07IEX8IfWmY9iGjOC3eISwX/vx/jtrI9Mj8Ei5 +RKUAEQEAAYkDRAQYAQoADwUCU3JE4gUJDwmcAAIbDAEpCRBi9J50fZEbYMBdIAQZ +AQoABgUCU3JE4gAKCRAZcP/x+neS2tEuB/4tvkwlS/aJJles7+n9gzlcWHeRHECG +0zTrmQr99uTvBaYewB6gSJK1YrM/ocOH2k6e2EAfYw+bgBXcOpb3NQePZ4vLCAkl +6J40ktwyWBOs8uCAdBX5Ngkxhiz5oNaxQqnBU+xfovsbQJrxj0S28DBXGDR6npI1 +vqjrsYBoPeo4YZu6pUAp6wW+7eC4eHVK/NIogw0XxA3VRzwvzLK+aUI5RbzyWwYY +PDfzXrQRqeUqCF2bnnsXjDHxfqjfoWrnK+ATGFZgjbF2wHhPDRRHqAx/ggn8K/R4 +rvhEKFIqxQHrfZgQgsWregiv46Ph8DBEGcniqeIS5kRQi5y71IB7ndb9cB4QAJIb +BQaB5GhsjVw5bQTsZWMDLoweaR4kqP2eXgx6HuhRw1XcP0ZNNv5//L7tv6tmeXgb +RO17JzCw8+g2ZFq8Wbd6v9MFKefh+FT75Vvb9jV6h2NtQlteKQ9mpXVpcxZ0pKDb +hPzrjcI3Xo/zjYHFjTk2VAxWVPtamBN2eCGc3ggWifYnmuCctxHlTZNyDyrfPwJ+ +Vj8VuTsjd/7b8VVLd2lpzF2m9M25z4zNgxzldAAr4F+bIqjPJUVY29pZFyKKqcBG +zCYBTlB+yiVqjXOyyYQKwE3nkG7UrlsQdQEI/wjqBJtDpQ/w7NLPKwx2633dVQAT +omPKujL3klFlIdof/5+JUDzmg2mC9ATCJ4sgTAIodo6hHACQT2OuKmAHuCI1oqBs +7A3H1pPk3HZVKy7LbdQTy7QTzpBiUHklOKWlWj+ugWeABTZZK5U9cm9vq2mT+rcB +Wu94GriSlDo3vobC78nMDZc68eV18onQpWTlzRsTVVfOjll/8ddtruVkCVhtfRxE +ANQIfZg7P8oNxVDAX+jIsTDxjh8r+S1wsUQcTNop6JMicDbxrBRB13vYIY0Jg4+Z +9WUiKCaM69kbgcJ7tTp0skcJ+rYcjVkTz2/P33/FA8BMDUwCR2FovRnmq9pVjAAP +hS0eN8yqaR533ire0Ur5Vif6+z4A0ifVTZ2hY96B +=nEJu +-----END PGP PUBLIC KEY BLOCK----- From 02ad2b118731d012ea248e3ede800aa28fa71301 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 18 Dec 2019 07:04:08 -0500 Subject: [PATCH 129/279] Spelling (#7258) * spelling: constraint Signed-off-by: Josh Soref * spelling: cryptographic Signed-off-by: Josh Soref * spelling: dependency Signed-off-by: Josh Soref * spelling: doesnot Signed-off-by: Josh Soref * spelling: don't Signed-off-by: Josh Soref * spelling: unexpected Signed-off-by: Josh Soref * spelling: dreadnought Signed-off-by: Josh Soref * spelling: default Signed-off-by: Josh Soref * spelling: envvars Signed-off-by: Josh Soref * spelling: evaluates Signed-off-by: Josh Soref * spelling: execute Signed-off-by: Josh Soref * spelling: extractor Signed-off-by: Josh Soref * spelling: frobnitz Signed-off-by: Josh Soref * spelling: generated Signed-off-by: Josh Soref * spelling: implementation Signed-off-by: Josh Soref * spelling: jabba Signed-off-by: Josh Soref * spelling: keywords Signed-off-by: Josh Soref * spelling: kubernetes Signed-off-by: Josh Soref * spelling: override Signed-off-by: Josh Soref * spelling: package Signed-off-by: Josh Soref * spelling: parsable Signed-off-by: Josh Soref * spelling: progress Signed-off-by: Josh Soref * spelling: recursively Signed-off-by: Josh Soref * spelling: release Signed-off-by: Josh Soref * spelling: cache Signed-off-by: Josh Soref * spelling: representing Signed-off-by: Josh Soref * spelling: serializer Signed-off-by: Josh Soref * spelling: subchart Signed-off-by: Josh Soref * spelling: utilities Signed-off-by: Josh Soref --- cmd/helm/dependency_update_test.go | 6 ++-- cmd/helm/root.go | 2 +- cmd/helm/root_test.go | 10 +++---- cmd/helm/verify.go | 2 +- internal/experimental/registry/util.go | 2 +- internal/ignore/rules.go | 2 +- pkg/action/action.go | 2 +- pkg/action/install.go | 2 +- pkg/action/list.go | 2 +- pkg/chart/dependency.go | 2 +- pkg/chart/loader/load_test.go | 2 +- pkg/chartutil/chartfile.go | 2 +- pkg/chartutil/doc.go | 4 +-- pkg/chartutil/errors_test.go | 4 +-- pkg/chartutil/jsonschema.go | 8 ++--- pkg/chartutil/jsonschema_test.go | 30 +++++++++---------- pkg/chartutil/save.go | 2 +- .../subpop/charts/subchart1/values.yaml | 2 +- pkg/chartutil/values_test.go | 8 ++--- pkg/cli/environment.go | 2 +- pkg/cli/environment_test.go | 24 +++++++-------- pkg/engine/engine.go | 2 +- pkg/getter/httpgetter.go | 2 +- pkg/lint/rules/chartfile.go | 2 +- pkg/plugin/installer/http_installer_test.go | 4 +-- pkg/plugin/installer/vcs_installer.go | 2 +- pkg/release/status.go | 2 +- pkg/repo/chartrepo_test.go | 2 +- pkg/repo/doc.go | 2 +- pkg/repo/index_test.go | 2 +- pkg/storage/driver/secrets.go | 2 +- 31 files changed, 71 insertions(+), 71 deletions(-) diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 9afc04f8d..1f9d55867 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -111,9 +111,9 @@ func TestDependencyUpdateCmd(t *testing.T) { if _, err := os.Stat(expect); err != nil { t.Fatalf("Expected %q: %s", expect, err) } - dontExpect := dir(chartname, "charts/compressedchart-0.1.0.tgz") - if _, err := os.Stat(dontExpect); err == nil { - t.Fatalf("Unexpected %q", dontExpect) + unexpected := dir(chartname, "charts/compressedchart-0.1.0.tgz") + if _, err := os.Stat(unexpected); err == nil { + t.Fatalf("Unexpected %q", unexpected) } } diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 3a15966bb..443d718d5 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -418,7 +418,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string registry.ClientOptWriter(out), ) if err != nil { - // TODO: dont panic here, refactor newRootCmd to return error + // TODO: don't panic here, refactor newRootCmd to return error panic(err) } actionConfig.RegistryClient = registryClient diff --git a/cmd/helm/root_test.go b/cmd/helm/root_test.go index 7d606b8a9..f3eef8b6d 100644 --- a/cmd/helm/root_test.go +++ b/cmd/helm/root_test.go @@ -31,7 +31,7 @@ func TestRootCmd(t *testing.T) { tests := []struct { name, args, cachePath, configPath, dataPath string - envars map[string]string + envvars map[string]string }{ { name: "defaults", @@ -40,19 +40,19 @@ func TestRootCmd(t *testing.T) { { name: "with $XDG_CACHE_HOME set", args: "home", - envars: map[string]string{xdg.CacheHomeEnvVar: "/bar"}, + envvars: map[string]string{xdg.CacheHomeEnvVar: "/bar"}, cachePath: "/bar/helm", }, { name: "with $XDG_CONFIG_HOME set", args: "home", - envars: map[string]string{xdg.ConfigHomeEnvVar: "/bar"}, + envvars: map[string]string{xdg.ConfigHomeEnvVar: "/bar"}, configPath: "/bar/helm", }, { name: "with $XDG_DATA_HOME set", args: "home", - envars: map[string]string{xdg.DataHomeEnvVar: "/bar"}, + envvars: map[string]string{xdg.DataHomeEnvVar: "/bar"}, dataPath: "/bar/helm", }, } @@ -61,7 +61,7 @@ func TestRootCmd(t *testing.T) { t.Run(tt.name, func(t *testing.T) { defer ensure.HelmHome(t)() - for k, v := range tt.envars { + for k, v := range tt.envvars { os.Setenv(k, v) } diff --git a/cmd/helm/verify.go b/cmd/helm/verify.go index 1cdd26290..d3ae517c9 100644 --- a/cmd/helm/verify.go +++ b/cmd/helm/verify.go @@ -27,7 +27,7 @@ import ( const verifyDesc = ` Verify that the given chart has a valid provenance file. -Provenance files provide crytographic verification that a chart has not been +Provenance files provide cryptographic verification that a chart has not been tampered with, and was packaged by a trusted provider. This command can be used to verify a local chart. Several other commands provide diff --git a/internal/experimental/registry/util.go b/internal/experimental/registry/util.go index 3a4589d01..697a890e3 100644 --- a/internal/experimental/registry/util.go +++ b/internal/experimental/registry/util.go @@ -49,7 +49,7 @@ func shortDigest(digest string) string { return digest } -// timeAgo returns a human-readable timestamp respresenting time that has passed +// timeAgo returns a human-readable timestamp representing time that has passed func timeAgo(t time.Time) string { return units.HumanDuration(time.Now().UTC().Sub(t)) } diff --git a/internal/ignore/rules.go b/internal/ignore/rules.go index c9aaeacca..9049aff0d 100644 --- a/internal/ignore/rules.go +++ b/internal/ignore/rules.go @@ -73,7 +73,7 @@ func Parse(file io.Reader) (*Rules, error) { return r, s.Err() } -// Ignore evalutes the file at the given path, and returns true if it should be ignored. +// Ignore evaluates the file at the given path, and returns true if it should be ignored. // // Ignore evaluates path against the rules in order. Evaluation stops when a match // is found. Matching a negative rule will stop evaluation. diff --git a/pkg/action/action.go b/pkg/action/action.go index f74a25e41..16c5d3546 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -66,7 +66,7 @@ var ValidName = regexp.MustCompile("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+ // Configuration injects the dependencies that all actions share. type Configuration struct { - // RESTClientGetter is an interface that loads Kuberbetes clients. + // RESTClientGetter is an interface that loads Kubernetes clients. RESTClientGetter RESTClientGetter // Releases stores records of releases. diff --git a/pkg/action/install.go b/pkg/action/install.go index dc5941810..e368bcb28 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -87,7 +87,7 @@ type Install struct { // APIVersions allows a manual set of supported API Versions to be passed // (for things like templating). These are ignored if ClientOnly is false APIVersions chartutil.VersionSet - // Used by helm template to render charts with .Relase.IsUpgrade. Ignored if Dry-Run is false + // Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false IsUpgrade bool } diff --git a/pkg/action/list.go b/pkg/action/list.go index 4af0ef8e5..5d3417203 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -41,7 +41,7 @@ const ( ListPendingInstall // ListPendingUpgrade filters on status "pending_upgrade" (upgrade in progress) ListPendingUpgrade - // ListPendingRollback filters on status "pending_rollback" (rollback in progres) + // ListPendingRollback filters on status "pending_rollback" (rollback in progress) ListPendingRollback // ListSuperseded filters on status "superseded" (historical release version that is no longer deployed) ListSuperseded diff --git a/pkg/chart/dependency.go b/pkg/chart/dependency.go index 0837f8d19..9ec4544c2 100644 --- a/pkg/chart/dependency.go +++ b/pkg/chart/dependency.go @@ -53,7 +53,7 @@ type Dependency struct { // // It represents the state that the dependencies should be in. type Lock struct { - // Genderated is the date the lock file was last generated. + // Generated is the date the lock file was last generated. Generated time.Time `json:"generated"` // Digest is a hash of the dependencies in Chart.yaml. Digest string `json:"digest"` diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index 6576002eb..26513d359 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -461,7 +461,7 @@ func verifyChartFileAndTemplate(t *testing.T, c *chart.Chart, name string) { t.Fatalf("Expected 2 Dependency, got %d", len(dep.Dependencies())) } default: - t.Errorf("Unexpected dependeny %s", dep.Name()) + t.Errorf("Unexpected dependency %s", dep.Name()) } } } diff --git a/pkg/chartutil/chartfile.go b/pkg/chartutil/chartfile.go index 756b87cfb..808a902b1 100644 --- a/pkg/chartutil/chartfile.go +++ b/pkg/chartutil/chartfile.go @@ -43,7 +43,7 @@ func LoadChartfile(filename string) (*chart.Metadata, error) { // 'filename' should be the complete path and filename ('foo/Chart.yaml') func SaveChartfile(filename string, cf *chart.Metadata) error { // Pull out the dependencies of a v1 Chart, since there's no way - // to tell the serialiser to skip a field for just this use case + // to tell the serializer to skip a field for just this use case savedDependencies := cf.Dependencies if cf.APIVersion == chart.APIVersionV1 { cf.Dependencies = nil diff --git a/pkg/chartutil/doc.go b/pkg/chartutil/doc.go index 5dd9c7038..efcda2cfa 100644 --- a/pkg/chartutil/doc.go +++ b/pkg/chartutil/doc.go @@ -17,7 +17,7 @@ limitations under the License. /*Package chartutil contains tools for working with charts. Charts are described in the protocol buffer definition (pkg/proto/charts). -This packe provides utilities for serializing and deserializing charts. +This package provides utilities for serializing and deserializing charts. A chart can be represented on the file system in one of two ways: @@ -25,7 +25,7 @@ A chart can be represented on the file system in one of two ways: - As a tarred gzipped file containing a directory that then contains a Chart.yaml file. -This package provides utilitites for working with those file formats. +This package provides utilities for working with those file formats. The preferred way of loading a chart is using 'loader.Load`: diff --git a/pkg/chartutil/errors_test.go b/pkg/chartutil/errors_test.go index 3f9d04a71..3f63e3733 100644 --- a/pkg/chartutil/errors_test.go +++ b/pkg/chartutil/errors_test.go @@ -20,7 +20,7 @@ import ( "testing" ) -func TestErrorNoTableDoesntPanic(t *testing.T) { +func TestErrorNoTableDoesNotPanic(t *testing.T) { x := "empty" y := ErrNoTable{x} @@ -28,7 +28,7 @@ func TestErrorNoTableDoesntPanic(t *testing.T) { t.Logf("error is: %s", y) } -func TestErrorNoValueDoesntPanic(t *testing.T) { +func TestErrorNoValueDoesNotPanic(t *testing.T) { x := "empty" y := ErrNoValue{x} diff --git a/pkg/chartutil/jsonschema.go b/pkg/chartutil/jsonschema.go index 0848faaf2..753dc98c1 100644 --- a/pkg/chartutil/jsonschema.go +++ b/pkg/chartutil/jsonschema.go @@ -39,10 +39,10 @@ func ValidateAgainstSchema(chrt *chart.Chart, values map[string]interface{}) err } } - // For each dependency, recurively call this function with the coalesced values - for _, subchrt := range chrt.Dependencies() { - subchrtValues := values[subchrt.Name()].(map[string]interface{}) - if err := ValidateAgainstSchema(subchrt, subchrtValues); err != nil { + // For each dependency, recursively call this function with the coalesced values + for _, subchart := range chrt.Dependencies() { + subchartValues := values[subchart.Name()].(map[string]interface{}) + if err := ValidateAgainstSchema(subchart, subchartValues); err != nil { sb.WriteString(err.Error()) } } diff --git a/pkg/chartutil/jsonschema_test.go b/pkg/chartutil/jsonschema_test.go index 2677ee0ea..33f009259 100644 --- a/pkg/chartutil/jsonschema_test.go +++ b/pkg/chartutil/jsonschema_test.go @@ -63,7 +63,7 @@ func TestValidateAgainstSingleSchemaNegative(t *testing.T) { } } -const subchrtSchema = `{ +const subchartSchema = `{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Values", "type": "object", @@ -81,23 +81,23 @@ const subchrtSchema = `{ ` func TestValidateAgainstSchema(t *testing.T) { - subchrtJSON := []byte(subchrtSchema) - subchrt := &chart.Chart{ + subchartJSON := []byte(subchartSchema) + subchart := &chart.Chart{ Metadata: &chart.Metadata{ - Name: "subchrt", + Name: "subchart", }, - Schema: subchrtJSON, + Schema: subchartJSON, } chrt := &chart.Chart{ Metadata: &chart.Metadata{ Name: "chrt", }, } - chrt.AddDependency(subchrt) + chrt.AddDependency(subchart) vals := map[string]interface{}{ "name": "John", - "subchrt": map[string]interface{}{ + "subchart": map[string]interface{}{ "age": 25, }, } @@ -108,23 +108,23 @@ func TestValidateAgainstSchema(t *testing.T) { } func TestValidateAgainstSchemaNegative(t *testing.T) { - subchrtJSON := []byte(subchrtSchema) - subchrt := &chart.Chart{ + subchartJSON := []byte(subchartSchema) + subchart := &chart.Chart{ Metadata: &chart.Metadata{ - Name: "subchrt", + Name: "subchart", }, - Schema: subchrtJSON, + Schema: subchartJSON, } chrt := &chart.Chart{ Metadata: &chart.Metadata{ Name: "chrt", }, } - chrt.AddDependency(subchrt) + chrt.AddDependency(subchart) vals := map[string]interface{}{ - "name": "John", - "subchrt": map[string]interface{}{}, + "name": "John", + "subchart": map[string]interface{}{}, } var errString string @@ -134,7 +134,7 @@ func TestValidateAgainstSchemaNegative(t *testing.T) { errString = err.Error() } - expectedErrString := `subchrt: + expectedErrString := `subchart: - (root): age is required ` if errString != expectedErrString { diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index e264c4391..4ab9d3b24 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -142,7 +142,7 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { base := filepath.Join(prefix, c.Name()) // Pull out the dependencies of a v1 Chart, since there's no way - // to tell the serialiser to skip a field for just this use case + // to tell the serializer to skip a field for just this use case savedDependencies := c.Metadata.Dependencies if c.Metadata.APIVersion == chart.APIVersionV1 { c.Metadata.Dependencies = nil diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/values.yaml b/pkg/chartutil/testdata/subpop/charts/subchart1/values.yaml index 72d3fa5c8..a974e316a 100644 --- a/pkg/chartutil/testdata/subpop/charts/subchart1/values.yaml +++ b/pkg/chartutil/testdata/subpop/charts/subchart1/values.yaml @@ -23,7 +23,7 @@ overridden-chartA: SCAbool: true SCAfloat: 3.14 SCAint: 100 - SCAstring: "jabathehut" + SCAstring: "jabbathehut" SC1extra3: true imported-chartA-B: diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index a3fe7aeac..c95fa503a 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -76,7 +76,7 @@ func TestToRenderValues(t *testing.T) { }, } - overideValues := map[string]interface{}{ + overrideValues := map[string]interface{}{ "name": "Haroun", "where": map[string]interface{}{ "city": "Baghdad", @@ -103,7 +103,7 @@ func TestToRenderValues(t *testing.T) { IsInstall: true, } - res, err := ToRenderValues(c, overideValues, o, nil) + res, err := ToRenderValues(c, overrideValues, o, nil) if err != nil { t.Fatal(err) } @@ -275,10 +275,10 @@ chapter: } else if v != "Loomings" { t.Errorf("No error but got wrong value for title: %s\n%v", err, d) } - if _, err := d.PathValue("chapter.one.doesntexist"); err == nil { + if _, err := d.PathValue("chapter.one.doesnotexist"); err == nil { t.Errorf("Non-existent key should return error: %s\n%v", err, d) } - if _, err := d.PathValue("chapter.doesntexist.one"); err == nil { + if _, err := d.PathValue("chapter.doesnotexist.one"); err == nil { t.Errorf("Non-existent key in middle of path should return error: %s\n%v", err, d) } if _, err := d.PathValue(""); err == nil { diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 28e7873be..5f947aec7 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -52,7 +52,7 @@ type EnvSettings struct { RegistryConfig string // RepositoryConfig is the path to the repositories file. RepositoryConfig string - // Repositoryache is the path to the repository cache directory. + // RepositoryCache is the path to the repository cache directory. RepositoryCache string // PluginsDirectory is the path to the plugins directory. PluginsDirectory string diff --git a/pkg/cli/environment_test.go b/pkg/cli/environment_test.go index d6856dd01..fadc2981e 100644 --- a/pkg/cli/environment_test.go +++ b/pkg/cli/environment_test.go @@ -29,8 +29,8 @@ func TestEnvSettings(t *testing.T) { name string // input - args string - envars map[string]string + args string + envvars map[string]string // expected values ns, kcontext string @@ -47,17 +47,17 @@ func TestEnvSettings(t *testing.T) { debug: true, }, { - name: "with envvars set", - envars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns"}, - ns: "yourns", - debug: true, + name: "with envvars set", + envvars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns"}, + ns: "yourns", + debug: true, }, { - name: "with flags and envvars set", - args: "--debug --namespace=myns", - envars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns"}, - ns: "myns", - debug: true, + name: "with flags and envvars set", + args: "--debug --namespace=myns", + envvars: map[string]string{"HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns"}, + ns: "myns", + debug: true, }, } @@ -65,7 +65,7 @@ func TestEnvSettings(t *testing.T) { t.Run(tt.name, func(t *testing.T) { defer resetEnv()() - for k, v := range tt.envars { + for k, v := range tt.envvars { os.Setenv(k, v) } diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 5a7d54993..d0261dca2 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -100,7 +100,7 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render var buf strings.Builder for _, n := range includedNames { if n == name { - return "", errors.Wrapf(fmt.Errorf("unable to excute template"), "rendering template has a nested reference name: %s", name) + return "", errors.Wrapf(fmt.Errorf("unable to execute template"), "rendering template has a nested reference name: %s", name) } } includedNames = append(includedNames, name) diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index 89abfb1cf..5b476ff2d 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -27,7 +27,7 @@ import ( "helm.sh/helm/v3/internal/version" ) -// HTTPGetter is the efault HTTP(/S) backend handler +// HTTPGetter is the default HTTP(/S) backend handler type HTTPGetter struct { opts options } diff --git a/pkg/lint/rules/chartfile.go b/pkg/lint/rules/chartfile.go index 70cb83bc5..91a64fe13 100644 --- a/pkg/lint/rules/chartfile.go +++ b/pkg/lint/rules/chartfile.go @@ -40,7 +40,7 @@ func Chartfile(linter *support.Linter) { chartFile, err := chartutil.LoadChartfile(chartPath) validChartFile := linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartYamlFormat(err)) - // Guard clause. Following linter rules require a parseable ChartFile + // Guard clause. Following linter rules require a parsable ChartFile if !validChartFile { return } diff --git a/pkg/plugin/installer/http_installer_test.go b/pkg/plugin/installer/http_installer_test.go index 89884f107..cfa2e4cbe 100644 --- a/pkg/plugin/installer/http_installer_test.go +++ b/pkg/plugin/installer/http_installer_test.go @@ -234,12 +234,12 @@ func TestExtract(t *testing.T) { gz.Close() // END tarball creation - extr, err := NewExtractor(source) + extractor, err := NewExtractor(source) if err != nil { t.Fatal(err) } - if err = extr.Extract(&buf, tempDir); err != nil { + if err = extractor.Extract(&buf, tempDir); err != nil { t.Errorf("Did not expect error but got error: %v", err) } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 21a65cd13..1a5d74cca 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -135,7 +135,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { sort.Sort(sort.Reverse(semver.Collection(semvers))) for _, v := range semvers { if constraint.Check(v) { - // If the constrint passes get the original reference + // If the constraint passes get the original reference ver := v.Original() debug("setting to %s", ver) return ver, nil diff --git a/pkg/release/status.go b/pkg/release/status.go index 0e535f9a4..49b0f1544 100644 --- a/pkg/release/status.go +++ b/pkg/release/status.go @@ -25,7 +25,7 @@ const ( StatusUnknown Status = "unknown" // StatusDeployed indicates that the release has been pushed to Kubernetes. StatusDeployed Status = "deployed" - // StatusUninstalled indicates that a release has been uninstalled from Kubermetes. + // StatusUninstalled indicates that a release has been uninstalled from Kubernetes. StatusUninstalled Status = "uninstalled" // StatusSuperseded indicates that this release object is outdated and a newer one exists. StatusSuperseded Status = "superseded" diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index 9f4273682..c6b227acf 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -237,7 +237,7 @@ func verifyIndex(t *testing.T, actual *IndexFile) { t.Errorf("Expected %q, got %q", e.Version, g.Version) } if len(g.Keywords) != 3 { - t.Error("Expected 3 keyrwords.") + t.Error("Expected 3 keywords.") } if len(g.Maintainers) != 2 { t.Error("Expected 2 maintainers.") diff --git a/pkg/repo/doc.go b/pkg/repo/doc.go index 19ccf267c..05650100b 100644 --- a/pkg/repo/doc.go +++ b/pkg/repo/doc.go @@ -27,7 +27,7 @@ The first is the 'index.yaml' format, which is expressed like this: entries: frobnitz: - created: 2016-09-29T12:14:34.830161306-06:00 - description: This is a frobniz. + description: This is a frobnitz. digest: 587bd19a9bd9d2bc4a6d25ab91c8c8e7042c47b4ac246e37bf8e1e74386190f4 home: http://example.com keywords: diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index bc0b45e2c..c830a339e 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -131,7 +131,7 @@ func TestMerge(t *testing.T) { if len(ind1.Entries) != 2 { t.Errorf("Expected 2 entries, got %d", len(ind1.Entries)) - vs := ind1.Entries["dreadnaught"] + vs := ind1.Entries["dreadnought"] if len(vs) != 2 { t.Errorf("Expected 2 versions, got %d", len(vs)) } diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index eea285be1..dc55cf458 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -44,7 +44,7 @@ type Secrets struct { Log func(string, ...interface{}) } -// NewSecrets initializes a new Secrets wrapping an implmenetation of +// NewSecrets initializes a new Secrets wrapping an implementation of // the kubernetes SecretsInterface. func NewSecrets(impl corev1.SecretInterface) *Secrets { return &Secrets{ From f3249b5ee26a913d2cf32c1fce76f8c500fa5259 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 18 Dec 2019 12:08:57 +0000 Subject: [PATCH 130/279] Add new Makefile targets Signed-off-by: Dean Coakley --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d5e36bcd1..fdfacca52 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BINDIR := $(CURDIR)/bin DIST_DIRS := find * -type d -exec TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64 -TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-386.tar.gz linux-386.tar.gz.sha256 linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 windows-amd64.zip windows-amd64.zip.sha256 +TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-386.tar.gz linux-386.tar.gz.sha256 linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 linux-s390x.tar.gz linux-s390x.tar.gz.sha256 windows-amd64.zip windows-amd64.zip.sha256 BINNAME ?= helm GOPATH = $(shell go env GOPATH) From afa612df9d132180837e7c122088d44b1c72df1e Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Thu, 19 Dec 2019 13:58:02 +0000 Subject: [PATCH 131/279] Add back fix for CRD patch creation Signed-off-by: Adrian Gonzalez-Martin --- pkg/kube/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 96179d19d..07962faac 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -355,7 +355,12 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P // returned from ConvertToVersion. Anything that's unstructured should // use the jsonpatch.CreateMergePatch. Strategic Merge Patch is not supported // on objects like CRDs. - if _, ok := versionedObject.(runtime.Unstructured); ok { + _, isUnstructured := versionedObject.(runtime.Unstructured) + + // On newer K8s versions, CRDs aren't unstructured but has this dedicated type + _, isCRD := versionedObject.(*apiextv1beta1.CustomResourceDefinition) + + if isUnstructured || isCRD { // fall back to generic JSON merge patch patch, err := jsonpatch.CreateMergePatch(oldData, newData) return patch, types.MergePatchType, err From 8cb3c02c47a6133d87efbefe507878d900809f36 Mon Sep 17 00:00:00 2001 From: Romain Grenet Date: Thu, 19 Dec 2019 13:21:39 -0500 Subject: [PATCH 132/279] Port PR #4161 Fix incorrect timestamp when helm package to Helmv3 Lint CRLF Signed-off-by: Romain Grenet --- pkg/chartutil/save.go | 8 ++-- pkg/chartutil/save_test.go | 83 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index 4ab9d3b24..fb985bb59 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -23,6 +23,7 @@ import ( "fmt" "os" "path/filepath" + "time" "github.com/pkg/errors" "sigs.k8s.io/yaml" @@ -207,9 +208,10 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { func writeToTar(out *tar.Writer, name string, body []byte) error { // TODO: Do we need to create dummy parent directory names if none exist? h := &tar.Header{ - Name: name, - Mode: 0644, - Size: int64(len(body)), + Name: name, + Mode: 0644, + Size: int64(len(body)), + ModTime: time.Now(), } if err := out.WriteHeader(h); err != nil { return err diff --git a/pkg/chartutil/save_test.go b/pkg/chartutil/save_test.go index 8941d0368..f367d42eb 100644 --- a/pkg/chartutil/save_test.go +++ b/pkg/chartutil/save_test.go @@ -17,7 +17,10 @@ limitations under the License. package chartutil import ( + "archive/tar" "bytes" + "compress/gzip" + "io" "io/ioutil" "os" "path" @@ -25,6 +28,7 @@ import ( "regexp" "strings" "testing" + "time" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" @@ -99,6 +103,85 @@ func Indent(n int, text string) string { return startOfLine.ReplaceAllLiteralString(text, indentation) } +func TestSavePreservesTimestamps(t *testing.T) { + // Test executes so quickly that if we don't subtract a second, the + // check will fail because `initialCreateTime` will be identical to the + // written timestamp for the files. + initialCreateTime := time.Now().Add(-1 * time.Second) + + tmp, err := ioutil.TempDir("", "helm-") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmp) + + c := &chart.Chart{ + Metadata: &chart.Metadata{ + APIVersion: chart.APIVersionV1, + Name: "ahab", + Version: "1.2.3.4", + }, + Values: map[string]interface{}{ + "imageName": "testimage", + "imageId": 42, + }, + Files: []*chart.File{ + {Name: "scheherazade/shahryar.txt", Data: []byte("1,001 Nights")}, + }, + Schema: []byte("{\n \"title\": \"Values\"\n}"), + } + + where, err := Save(c, tmp) + if err != nil { + t.Fatalf("Failed to save: %s", err) + } + + allHeaders, err := retrieveAllHeadersFromTar(where) + if err != nil { + t.Fatalf("Failed to parse tar: %v", err) + } + + for _, header := range allHeaders { + if header.ModTime.Before(initialCreateTime) { + t.Fatalf("File timestamp not preserved: %v", header.ModTime) + } + } +} + +// We could refactor `load.go` to use this `retrieveAllHeadersFromTar` function +// as well, so we are not duplicating components of the code which iterate +// through the tar. +func retrieveAllHeadersFromTar(path string) ([]*tar.Header, error) { + raw, err := os.Open(path) + if err != nil { + return nil, err + } + defer raw.Close() + + unzipped, err := gzip.NewReader(raw) + if err != nil { + return nil, err + } + defer unzipped.Close() + + tr := tar.NewReader(unzipped) + headers := []*tar.Header{} + for { + hd, err := tr.Next() + if err == io.EOF { + break + } + + if err != nil { + return nil, err + } + + headers = append(headers, hd) + } + + return headers, nil +} + func TestSaveDir(t *testing.T) { tmp, err := ioutil.TempDir("", "helm-") if err != nil { From 96a14340272356b6013de5f0568aa5e85e571795 Mon Sep 17 00:00:00 2001 From: Thilak Somasundaram Date: Fri, 20 Dec 2019 00:17:07 -0800 Subject: [PATCH 133/279] feat(checksum): Generate shasum/sha256sum -c compatible sha256 file Commands shasum -a 256 -c (or) sha256sum -c can read the SHA sum and validate the TAR/ZIP archive Example: Download helm-v3.0.2-darwin-amd64.tar.gz.sha256 and helm-v3.0.2-darwin-amd64.tar.gz and running below will resule in shasum -a 256 -c helm-v3.0.2-darwin-amd64.tar.gz.sha256 helm-v3.0.2-darwin-amd64.tar.gz: OK Closes #4968 Signed-off-by: Thilak Somasundaram --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 611222e28..a7cd88863 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,7 @@ sign: .PHONY: checksum checksum: for f in _dist/*.{gz,zip} ; do \ - shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \ + shasum -a 256 "$${f}" > "$${f}.sha256" ; \ done # ------------------------------------------------------------------------------ From 5680f4d50644de2f4d3fd6c890b7153b533410ed Mon Sep 17 00:00:00 2001 From: Thilak Somasundaram Date: Fri, 20 Dec 2019 00:56:34 -0800 Subject: [PATCH 134/279] feat(checksum): update to get/get-helm-3 to match shasum fix Noticed get/get-helm-3 needed update to match shasum fix. Making least change to work with shasum fix. Signed-off-by: Thilak Somasundaram --- scripts/get | 2 +- scripts/get-helm-3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/get b/scripts/get index 711635ee3..615121b65 100755 --- a/scripts/get +++ b/scripts/get @@ -137,7 +137,7 @@ downloadFile() { installFile() { HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') - local expected_sum=$(cat ${HELM_SUM_FILE}) + local expected_sum=$(cat ${HELM_SUM_FILE} | awk '{print $1}') if [ "$sum" != "$expected_sum" ]; then echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." exit 1 diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 index c1655a68e..54ae9439a 100755 --- a/scripts/get-helm-3 +++ b/scripts/get-helm-3 @@ -133,7 +133,7 @@ downloadFile() { installFile() { HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') - local expected_sum=$(cat ${HELM_SUM_FILE}) + local expected_sum=$(cat ${HELM_SUM_FILE} | awk '{print $1}') if [ "$sum" != "$expected_sum" ]; then echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." exit 1 From a2bbb67839722713d48b3c775d9402efba12c108 Mon Sep 17 00:00:00 2001 From: Jan Heylen Date: Fri, 20 Dec 2019 16:03:53 +0100 Subject: [PATCH 135/279] fix(helm): add .orig as typical backup file Mercurial VCS (hg) backout's can generate '.orig' files to avoid these being picked, generate a .helmignore where also the .orig files are ignored. Signed-off-by: Jan Heylen --- pkg/chartutil/create.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index c67cde04f..4ca813593 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -170,6 +170,7 @@ const defaultIgnore = `# Patterns to ignore when building packages. *.swp *.bak *.tmp +*.orig *~ # Various IDEs .project From 560d6cdb3f59c739b6cefc1ecd0648390b40d39f Mon Sep 17 00:00:00 2001 From: Thilak Somasundaram Date: Fri, 20 Dec 2019 11:36:49 -0800 Subject: [PATCH 136/279] Updated make to create two files sha256/sha256sum Please link sha256sum as checksum file in GIT releases page for future release Signed-off-by: Thilak Somasundaram --- Makefile | 2 +- scripts/get | 2 +- scripts/get-helm-3 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a7cd88863..583f525f0 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,7 @@ sign: .PHONY: checksum checksum: for f in _dist/*.{gz,zip} ; do \ - shasum -a 256 "$${f}" > "$${f}.sha256" ; \ + shasum -a 256 "$${f}" | tee "$${f}.sha256sum" | awk '{print $$1}' > "$${f}.sha256" ; \ done # ------------------------------------------------------------------------------ diff --git a/scripts/get b/scripts/get index 615121b65..711635ee3 100755 --- a/scripts/get +++ b/scripts/get @@ -137,7 +137,7 @@ downloadFile() { installFile() { HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') - local expected_sum=$(cat ${HELM_SUM_FILE} | awk '{print $1}') + local expected_sum=$(cat ${HELM_SUM_FILE}) if [ "$sum" != "$expected_sum" ]; then echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." exit 1 diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 index 54ae9439a..c1655a68e 100755 --- a/scripts/get-helm-3 +++ b/scripts/get-helm-3 @@ -133,7 +133,7 @@ downloadFile() { installFile() { HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') - local expected_sum=$(cat ${HELM_SUM_FILE} | awk '{print $1}') + local expected_sum=$(cat ${HELM_SUM_FILE}) if [ "$sum" != "$expected_sum" ]; then echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." exit 1 From 97347ebced49717433bafde9018955bf99f8ce19 Mon Sep 17 00:00:00 2001 From: Thilak Somasundaram Date: Fri, 20 Dec 2019 11:41:58 -0800 Subject: [PATCH 137/279] fixup! Updated make to create two files sha256/sha256sum Please link sha256sum as checksum file in GIT releases page for future release Signed-off-by: Thilak Somasundaram --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 583f525f0..d228c5525 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,7 @@ sign: .PHONY: checksum checksum: for f in _dist/*.{gz,zip} ; do \ - shasum -a 256 "$${f}" | tee "$${f}.sha256sum" | awk '{print $$1}' > "$${f}.sha256" ; \ + shasum -a 256 "$${f}" | sed 's/_dist\///' | tee "$${f}.sha256sum" | awk '{print $$1}' > "$${f}.sha256" ; \ done # ------------------------------------------------------------------------------ From 36c06141f8e21ba59f45871a0909ae003c31a277 Mon Sep 17 00:00:00 2001 From: Pierre Humberdroz Date: Fri, 20 Dec 2019 22:35:27 +0100 Subject: [PATCH 138/279] docs: point users to helm hub Signed-off-by: Pierre Humberdroz --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73fd189d7..745a60c2b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Helm is a tool for managing Charts. Charts are packages of pre-configured Kubern Use Helm to: -- Find and use [popular software packaged as Helm Charts](https://github.com/helm/charts) to run in Kubernetes +- Find and use [popular software packaged as Helm Charts](https://hub.helm.sh) to run in Kubernetes - Share your own applications as Helm Charts - Create reproducible builds of your Kubernetes applications - Intelligently manage your Kubernetes manifest files From bc45d6531207f0a2e223cebb4500cacb936452f7 Mon Sep 17 00:00:00 2001 From: Nick Lee Date: Sun, 22 Dec 2019 20:04:15 -0500 Subject: [PATCH 139/279] test(cmd/lint): added test for --with-subcharts flag Signed-off-by: Nick Lee --- cmd/helm/lint_test.go | 38 +++++++++++++++++++ ...hart-with-bad-subcharts-with-subcharts.txt | 16 ++++++++ .../output/lint-chart-with-bad-subcharts.txt | 5 +++ .../chart-with-bad-subcharts/Chart.yaml | 4 ++ .../charts/bad-subchart/Chart.yaml | 1 + .../charts/bad-subchart/values.yaml | 0 .../charts/good-subchart/Chart.yaml | 4 ++ .../charts/good-subchart/values.yaml | 0 .../requirements.yaml | 5 +++ .../chart-with-bad-subcharts/values.yaml | 0 10 files changed, 73 insertions(+) create mode 100644 cmd/helm/lint_test.go create mode 100644 cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt create mode 100644 cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml diff --git a/cmd/helm/lint_test.go b/cmd/helm/lint_test.go new file mode 100644 index 000000000..7638acb84 --- /dev/null +++ b/cmd/helm/lint_test.go @@ -0,0 +1,38 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "fmt" + "testing" +) + +func TestLintCmdWithSubchartsFlag(t *testing.T) { + testChart := "testdata/testcharts/chart-with-bad-subcharts" + tests := []cmdTestCase{{ + name: "lint good chart with bad subcharts", + cmd: fmt.Sprintf("lint %s", testChart), + golden: "output/lint-chart-with-bad-subcharts.txt", + wantError: false, + }, { + name: "lint good chart with bad subcharts using --with-subcharts flag", + cmd: fmt.Sprintf("lint --with-subcharts %s", testChart), + golden: "output/lint-chart-with-bad-subcharts-with-subcharts.txt", + wantError: true, + }} + runTestCmd(t, tests) +} diff --git a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt b/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt new file mode 100644 index 000000000..cda011b57 --- /dev/null +++ b/cmd/helm/testdata/output/lint-chart-with-bad-subcharts-with-subcharts.txt @@ -0,0 +1,16 @@ +==> Linting testdata/testcharts/chart-with-bad-subcharts +[INFO] Chart.yaml: icon is recommended +[WARNING] templates/: directory not found + +==> Linting testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart +[ERROR] Chart.yaml: name is required +[ERROR] Chart.yaml: apiVersion is required. The value must be either "v1" or "v2" +[ERROR] Chart.yaml: version is required +[INFO] Chart.yaml: icon is recommended +[WARNING] templates/: directory not found + +==> Linting testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart +[INFO] Chart.yaml: icon is recommended +[WARNING] templates/: directory not found + +Error: 3 chart(s) linted, 1 chart(s) failed diff --git a/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt b/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt new file mode 100644 index 000000000..51f3f3718 --- /dev/null +++ b/cmd/helm/testdata/output/lint-chart-with-bad-subcharts.txt @@ -0,0 +1,5 @@ +==> Linting testdata/testcharts/chart-with-bad-subcharts +[INFO] Chart.yaml: icon is recommended +[WARNING] templates/: directory not found + +1 chart(s) linted, 0 chart(s) failed diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml new file mode 100644 index 000000000..a575aa9f8 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: Chart with bad subcharts +name: chart-with-bad-subcharts +version: 0.0.1 diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml new file mode 100644 index 000000000..0daa5c188 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/Chart.yaml @@ -0,0 +1 @@ +description: Bad subchart \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/bad-subchart/values.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml new file mode 100644 index 000000000..895433e31 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: Good subchart +name: good-subchart +version: 0.0.1 \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/charts/good-subchart/values.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml new file mode 100644 index 000000000..de2fbb4dd --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/requirements.yaml @@ -0,0 +1,5 @@ +dependencies: + - name: good-subchart + version: 0.0.1 + - name: bad-subchart + version: 0.0.1 \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml b/cmd/helm/testdata/testcharts/chart-with-bad-subcharts/values.yaml new file mode 100644 index 000000000..e69de29bb From cf4bee7ac8972ed98a00e621ca70f28abf6594ed Mon Sep 17 00:00:00 2001 From: Nick Lee Date: Sun, 22 Dec 2019 20:04:28 -0500 Subject: [PATCH 140/279] feat(cmd/lint): added a flag for linting subcharts Signed-off-by: Nick Lee --- cmd/helm/lint.go | 18 ++++++++++++++++++ pkg/action/lint.go | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 9a2e8d31c..b53309b20 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -19,6 +19,8 @@ package main import ( "fmt" "io" + "os" + "path/filepath" "strings" "github.com/pkg/errors" @@ -51,6 +53,21 @@ func newLintCmd(out io.Writer) *cobra.Command { if len(args) > 0 { paths = args } + if client.WithSubcharts { + for _, p := range paths { + filepath.Walk(filepath.Join(p, "/charts"), func(path string, info os.FileInfo, err error) error { + if info != nil { + if info.Name() == "Chart.yaml" { + paths = append(paths, filepath.Dir(path)) + } else if strings.HasSuffix(path, ".tgz") || strings.HasSuffix(path, ".tar.gz") { + paths = append(paths, path) + } + } + return nil + }) + } + } + client.Namespace = settings.Namespace() vals, err := valueOpts.MergeValues(getter.All(settings)) if err != nil { @@ -102,6 +119,7 @@ func newLintCmd(out io.Writer) *cobra.Command { f := cmd.Flags() f.BoolVar(&client.Strict, "strict", false, "fail on lint warnings") + f.BoolVar(&client.WithSubcharts, "with-subcharts", false, "lint dependent charts") addValueOptionsFlags(f, valueOpts) return cmd diff --git a/pkg/action/lint.go b/pkg/action/lint.go index c216c5832..ddb0101c7 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -33,8 +33,9 @@ import ( // // It provides the implementation of 'helm lint'. type Lint struct { - Strict bool - Namespace string + Strict bool + Namespace string + WithSubcharts bool } type LintResult struct { From cedd48019966d1aad49f386baf9f9808143d419b Mon Sep 17 00:00:00 2001 From: Guangwen Feng Date: Mon, 23 Dec 2019 20:53:10 +0800 Subject: [PATCH 141/279] Add corresponding unit test to the function in resource.go. Signed-off-by: Guangwen Feng --- pkg/kube/resource_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/kube/resource_test.go b/pkg/kube/resource_test.go index 2e13c3253..3c906ceca 100644 --- a/pkg/kube/resource_test.go +++ b/pkg/kube/resource_test.go @@ -37,6 +37,10 @@ func TestResourceList(t *testing.T) { r1 = []*resource.Info{info("foo"), info("bar")} r2 = []*resource.Info{info("bar")} + if r1.Get(info("bar")).Mapping.Resource.Resource != "pod" { + t.Error("expected get pod") + } + diff := r1.Difference(r2) if len(diff) != 1 { t.Error("expected 1 result") From b47a5b746d57e0ca93c9e31066a2c4ef6fa9cdc4 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 25 Dec 2019 16:07:48 -0500 Subject: [PATCH 142/279] fix(tests): Use relative path to acceptance tests With Helm using go modules, its git repo need not reside under $GOPATH/src/helm.sh anymore. In fact it may be desirable for a user to move it to another location (e.g., to get the debugger to work). In the same train of thought, the acceptance-testing repo, which is not even a go program, need not be in the GOPATH. This commit reduces the requirement on the location of the acceptance-testing repo to a relative path to the helm repo, instead of an absolute path within GOPATH. Signed-off-by: Marc Khouzam --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 611222e28..1e977d3dd 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ DEP = $(GOPATH)/bin/dep GOX = $(GOPATH)/bin/gox GOIMPORTS = $(GOPATH)/bin/goimports -ACCEPTANCE_DIR:=$(GOPATH)/src/helm.sh/acceptance-testing +ACCEPTANCE_DIR:=../acceptance-testing # To specify the subset of acceptance tests to run. '.' means all tests ACCEPTANCE_RUN_TESTS=. From 2eab781b35019ce452738012092f9df4ce9fdf00 Mon Sep 17 00:00:00 2001 From: Frank Lin PIAT Date: Sat, 28 Dec 2019 22:34:21 +0100 Subject: [PATCH 143/279] fix(comp): tail cannot open +2 for reading Signed-off-by: Frank Lin PIAT --- cmd/helm/root.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 443d718d5..3405299fd 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -69,7 +69,7 @@ __helm_override_flags_to_kubectl_flags() __helm_get_repos() { - eval $(__helm_binary_name) repo list 2>/dev/null | \tail +2 | \cut -f1 + eval $(__helm_binary_name) repo list 2>/dev/null | \tail -n +2 | \cut -f1 } __helm_get_contexts() @@ -236,7 +236,7 @@ __helm_list_plugins() __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" local out # Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3) - if out=$(eval $(__helm_binary_name) plugin list 2>/dev/null | \tail +2 | \cut -f1); then + if out=$(eval $(__helm_binary_name) plugin list 2>/dev/null | \tail -n +2 | \cut -f1); then COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) fi } From 3eb8df0c5ee5b6e9753cf99440644423e392073e Mon Sep 17 00:00:00 2001 From: Hu Shuai Date: Tue, 31 Dec 2019 13:52:19 +0800 Subject: [PATCH 144/279] Fix a typo "the the" -> "the" Signed-off-by: Hu Shuai --- internal/monocular/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/monocular/search.go b/internal/monocular/search.go index 61695f554..10e1f2136 100644 --- a/internal/monocular/search.go +++ b/internal/monocular/search.go @@ -58,7 +58,7 @@ type Chart struct { Icon string `json:"icon"` } -// Repo contains the name in monocular the the url for the repository +// Repo contains the name in monocular the url for the repository type Repo struct { Name string `json:"name"` URL string `json:"url"` From 600970459ebda95116f6e029e61f3a0e0117e9c9 Mon Sep 17 00:00:00 2001 From: Phil Grayson Date: Wed, 1 Jan 2020 21:32:25 +0000 Subject: [PATCH 145/279] Do not delete templated CRDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue #7279. Prevent the deletion of CRDs that were defined in the `templates/` directory. This makes CRD deletion behaviour consistent with Helm documentation: > CRDs are never deleted. Deleting a CRD automatically deletes all of the > CRD’s contents across all namespaces in the cluster. Consequently, Helm > will not delete CRDs. Previous the documentation only applied to CRDs that were defined in the `crds/` directory. It did not consider that Charts could have CRDs in the `templates/` directory (for example charts that were written before the `crds/` directory feature or if the Chart author needed templated CRDs). Signed-off-by: Phil Grayson --- pkg/kube/client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 07962faac..be13f237d 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -197,6 +197,11 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } for _, info := range original.Difference(target) { + if info.Mapping.GroupVersionKind.Kind == "CustomResourceDefinition" { + c.Log("Skipping the deletion of CustomResourceDefinition %q", info.Name) + continue + } + c.Log("Deleting %q in %s...", info.Name, info.Namespace) res.Deleted = append(res.Deleted, info) if err := deleteResource(info); err != nil { @@ -219,6 +224,11 @@ func (c *Client) Delete(resources ResourceList) (*Result, []error) { var errs []error res := &Result{} err := perform(resources, func(info *resource.Info) error { + if info.Mapping.GroupVersionKind.Kind == "CustomResourceDefinition" { + c.Log("Skipping the deletion of CustomResourceDefinition %q", info.Name) + return nil + } + c.Log("Starting delete for %q %s", info.Name, info.Mapping.GroupVersionKind.Kind) if err := c.skipIfNotFound(deleteResource(info)); err != nil { // Collect the error and continue on From a58430a944454ff8e5a560a9d3d70f5e05385310 Mon Sep 17 00:00:00 2001 From: Anton Kvashenkin Date: Thu, 2 Jan 2020 19:32:50 +0400 Subject: [PATCH 146/279] Fix typo in --values cmd flag Fix a small typo in `--values` flag in `helm install/upgrade --help` output. Signed-off-by: Anton Kvashenkin --- cmd/helm/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 467abbd6e..aa22603f4 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -31,7 +31,7 @@ import ( const outputFlag = "output" func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { - f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL(can specify multiple)") + f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL (can specify multiple)") f.StringArrayVar(&v.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&v.StringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&v.FileValues, "set-file", []string{}, "set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)") From 476200ed061fff0030c4c3f2918a581735b731eb Mon Sep 17 00:00:00 2001 From: Guangwen Feng Date: Fri, 3 Jan 2020 18:05:23 +0800 Subject: [PATCH 147/279] Add corresponding unit test to the function in resolver.go Signed-off-by: Guangwen Feng --- internal/resolver/resolver_test.go | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/internal/resolver/resolver_test.go b/internal/resolver/resolver_test.go index 3828771cc..d93d616ee 100644 --- a/internal/resolver/resolver_test.go +++ b/internal/resolver/resolver_test.go @@ -216,3 +216,61 @@ func TestHashReq(t *testing.T) { }) } } + +func TestGetLocalPath(t *testing.T) { + tests := []struct { + name string + repo string + chartpath string + expect string + err bool + }{ + { + name: "absolute path", + repo: "file:////proc", + expect: "/proc", + }, + { + name: "relative path", + repo: "file://../../../../cmd/helm/testdata/testcharts/signtest", + chartpath: "foo/bar", + expect: "../../cmd/helm/testdata/testcharts/signtest", + }, + { + name: "current directory path", + repo: "../charts/localdependency", + chartpath: "testdata/chartpath/charts", + expect: "testdata/chartpath/charts/localdependency", + }, + { + name: "invalid local path", + repo: "file://../testdata/notexist", + chartpath: "testdata/chartpath", + err: true, + }, + { + name: "invalid path under current directory", + repo: "../charts/nonexistentdependency", + chartpath: "testdata/chartpath/charts", + err: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + p, err := GetLocalPath(tt.repo, tt.chartpath) + if err != nil { + if tt.err { + return + } + t.Fatal(err) + } + if tt.err { + t.Fatalf("Expected error in test %q", tt.name) + } + if p != tt.expect { + t.Errorf("%q: expected %q, got %q", tt.name, tt.expect, p) + } + }) + } +} From 40df2f2a636be4a061e252715db6867796c0c5f1 Mon Sep 17 00:00:00 2001 From: Xiang Dai <764524258@qq.com> Date: Mon, 6 Jan 2020 19:33:07 +0800 Subject: [PATCH 148/279] Improve description for `--all` flag (#7144) * Improve description for `--all` flag Signed-off-by: Xiang Dai <764524258@qq.com> * feedback Signed-off-by: Xiang Dai <764524258@qq.com> --- cmd/helm/list.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 0da0c21d3..57fc4be3c 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -32,7 +32,7 @@ import ( ) var listHelp = ` -This command lists all of the releases. +This command lists all of the releases for a specified namespace (uses current namespace context if namespace not specified). By default, it lists only releases that are deployed or failed. Flags like '--uninstalled' and '--all' will alter this behavior. Such flags can be combined: @@ -96,7 +96,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVarP(&client.Short, "short", "q", false, "output short (quiet) listing format") f.BoolVarP(&client.ByDate, "date", "d", false, "sort by release date") f.BoolVarP(&client.SortReverse, "reverse", "r", false, "reverse the sort order") - f.BoolVarP(&client.All, "all", "a", false, "show all releases, not just the ones marked deployed or failed") + f.BoolVarP(&client.All, "all", "a", false, "show all releases without any filter applied") f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases (if 'helm uninstall --keep-history' was used)") f.BoolVar(&client.Superseded, "superseded", false, "show superseded releases") f.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") From 29cc5efc1853488a1e0cde1c5336063f3297fc85 Mon Sep 17 00:00:00 2001 From: Nguyen Hai Truong Date: Mon, 6 Jan 2020 22:54:47 +0700 Subject: [PATCH 149/279] Remove duplicated words (#7336) Although it is spelling mistakes, it might make an affects while reading. Signed-off-by: Nguyen Hai Truong --- internal/third_party/dep/fs/fs_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/third_party/dep/fs/fs_test.go b/internal/third_party/dep/fs/fs_test.go index bf4b803f8..a9678d8c1 100644 --- a/internal/third_party/dep/fs/fs_test.go +++ b/internal/third_party/dep/fs/fs_test.go @@ -170,7 +170,7 @@ func TestCopyDir(t *testing.T) { func TestCopyDirFail_SrcInaccessible(t *testing.T) { if runtime.GOOS == "windows" { // XXX: setting permissions works differently in - // Microsoft Windows. Skipping this this until a + // Microsoft Windows. Skipping this until a // compatible implementation is provided. t.Skip("skipping on windows") } @@ -209,7 +209,7 @@ func TestCopyDirFail_SrcInaccessible(t *testing.T) { func TestCopyDirFail_DstInaccessible(t *testing.T) { if runtime.GOOS == "windows" { // XXX: setting permissions works differently in - // Microsoft Windows. Skipping this this until a + // Microsoft Windows. Skipping this until a // compatible implementation is provided. t.Skip("skipping on windows") } @@ -309,7 +309,7 @@ func TestCopyDirFailOpen(t *testing.T) { // Microsoft Windows. os.Chmod(..., 0222) below is not // enough for the file to be readonly, and os.Chmod(..., // 0000) returns an invalid argument error. Skipping - // this this until a compatible implementation is + // this until a compatible implementation is // provided. t.Skip("skipping on windows") } @@ -478,7 +478,7 @@ func TestCopyFileSymlink(t *testing.T) { func TestCopyFileFail(t *testing.T) { if runtime.GOOS == "windows" { // XXX: setting permissions works differently in - // Microsoft Windows. Skipping this this until a + // Microsoft Windows. Skipping this until a // compatible implementation is provided. t.Skip("skipping on windows") } @@ -521,7 +521,7 @@ func TestCopyFileFail(t *testing.T) { } // setupInaccessibleDir creates a temporary location with a single -// directory in it, in such a way that that directory is not accessible +// directory in it, in such a way that directory is not accessible // after this function returns. // // op is called with the directory as argument, so that it can create From ad07bb690dbf34e7067171235861a3c0fb9897b6 Mon Sep 17 00:00:00 2001 From: "Jorge I. Gasca" <42793610+jorge-gasca@users.noreply.github.com> Date: Tue, 7 Jan 2020 12:25:15 -0500 Subject: [PATCH 150/279] fix(cmd): Fixes logging on action conf init error (#6909) * fix(cmd): Fixes logging on action conf init error Errors relating to initializing the action config cause helm to exit silently, except when in debug mode. This now emits the useful error. Closes #6863 Signed-off-by: Jorge Gasca * Remove unnecessary formatting of err struct Signed-off-by: Jorge Gasca --- cmd/helm/helm.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 2c3c9e401..112d5123f 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -68,8 +68,7 @@ func main() { cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil { - debug("%+v", err) - os.Exit(1) + log.Fatal(err) } if err := cmd.Execute(); err != nil { From 476ffaea8cf3a7f830a2262298f03a991ef61eae Mon Sep 17 00:00:00 2001 From: Dao Cong Tien Date: Wed, 8 Jan 2020 15:43:57 +0700 Subject: [PATCH 151/279] Add unit test for List() of pkg/storage/driver/memory.go Signed-off-by: Dao Cong Tien --- pkg/storage/driver/memory_test.go | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pkg/storage/driver/memory_test.go b/pkg/storage/driver/memory_test.go index c74df9432..e9d709c1f 100644 --- a/pkg/storage/driver/memory_test.go +++ b/pkg/storage/driver/memory_test.go @@ -81,6 +81,46 @@ func TestMemoryGet(t *testing.T) { } } +func TestMemoryList(t *testing.T) { + ts := tsFixtureMemory(t) + + // list all deployed releases + dpl, err := ts.List(func(rel *rspb.Release) bool { + return rel.Info.Status == rspb.StatusDeployed + }) + // check + if err != nil { + t.Errorf("Failed to list deployed releases: %s", err) + } + if len(dpl) != 2 { + t.Errorf("Expected 2 deployed, got %d", len(dpl)) + } + + // list all superseded releases + ssd, err := ts.List(func(rel *rspb.Release) bool { + return rel.Info.Status == rspb.StatusSuperseded + }) + // check + if err != nil { + t.Errorf("Failed to list superseded releases: %s", err) + } + if len(ssd) != 6 { + t.Errorf("Expected 6 superseded, got %d", len(ssd)) + } + + // list all deleted releases + del, err := ts.List(func(rel *rspb.Release) bool { + return rel.Info.Status == rspb.StatusUninstalled + }) + // check + if err != nil { + t.Errorf("Failed to list deleted releases: %s", err) + } + if len(del) != 0 { + t.Errorf("Expected 0 deleted, got %d", len(del)) + } +} + func TestMemoryQuery(t *testing.T) { var tests = []struct { desc string From de9118b87961c3ec15370d6b77293d6fe36fa88a Mon Sep 17 00:00:00 2001 From: Hu Shuai Date: Wed, 8 Jan 2020 17:19:00 +0800 Subject: [PATCH 152/279] Fix a typo "update" -> "updates" (#7346) Signed-off-by: Hu Shuai --- pkg/storage/storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 58a7eb06f..6528c48ba 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -66,7 +66,7 @@ func (s *Storage) Create(rls *rspb.Release) error { return s.Driver.Create(makeKey(rls.Name, rls.Version), rls) } -// Update update the release in storage. An error is returned if the +// Update updates the release in storage. An error is returned if the // storage backend fails to update the release or if the release // does not exist. func (s *Storage) Update(rls *rspb.Release) error { From ff0257de29e589f9550aa6c04bc3283d652dc976 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 8 Jan 2020 09:41:30 -0800 Subject: [PATCH 153/279] fix(tests): use sigs.k8s.io/yaml Signed-off-by: Matthew Fisher --- cmd/helm/repo_add_test.go | 2 +- go.mod | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/helm/repo_add_test.go b/cmd/helm/repo_add_test.go index 1ac61fba8..4dbd0f435 100644 --- a/cmd/helm/repo_add_test.go +++ b/cmd/helm/repo_add_test.go @@ -23,7 +23,7 @@ import ( "sync" "testing" - "gopkg.in/yaml.v2" + "sigs.k8s.io/yaml" "helm.sh/helm/v3/internal/test/ensure" "helm.sh/helm/v3/pkg/repo" diff --git a/go.mod b/go.mod index 8e972fdfe..ed074074d 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,6 @@ require ( google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect google.golang.org/grpc v1.24.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.2.4 k8s.io/api v0.0.0-20191016110408-35e52d86657a k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65 k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8 From ab905010fd3ce671f9e0cd74f4d8ca3bc944c130 Mon Sep 17 00:00:00 2001 From: bakito Date: Wed, 8 Jan 2020 18:42:49 +0100 Subject: [PATCH 154/279] fix error output Signed-off-by: Marc Brugger --- pkg/action/validate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/action/validate.go b/pkg/action/validate.go index 30a1d1197..6bbfc5e8d 100644 --- a/pkg/action/validate.go +++ b/pkg/action/validate.go @@ -42,7 +42,7 @@ func existingResourceConflict(resources kube.ResourceList) error { return errors.Wrap(err, "could not get information about the resource") } - return fmt.Errorf("existing resource conflict: namespace: %s, name: %s, existing: [gvk: %s, ] / new: [gvk: %s]", info.Namespace, info.Name, existing.GetObjectKind().GroupVersionKind(), info.Mapping.GroupVersionKind) + return fmt.Errorf("existing resource conflict: namespace: %s, name: %s, existing_kind: %s, new_kind: %s", info.Namespace, info.Name, existing.GetObjectKind().GroupVersionKind(), info.Mapping.GroupVersionKind) }) return err } From 1230df8822b028177ea265002f6b556c5888ad63 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 8 Jan 2020 09:46:14 -0800 Subject: [PATCH 155/279] chore(go.sum): run `go mod tidy` Signed-off-by: Matthew Fisher --- go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.sum b/go.sum index fb11fdbc4..629d466c2 100644 --- a/go.sum +++ b/go.sum @@ -25,12 +25,8 @@ github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e h1:eb0Pzkt15Bm github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.0.1 h1:2kKm5lb7dKVrt5TYUiAavE6oFc1cFT0057UVGT+JqLk= -github.com/Masterminds/semver/v3 v3.0.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/semver/v3 v3.0.3 h1:znjIyLfpXEDQjOIEWh+ehwpTU14UzUPub3c3sm36u14= github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.0.0 h1:KSQz7Nb08/3VU9E4ns29dDxcczhOD1q7O1UfM4G3t3g= -github.com/Masterminds/sprig/v3 v3.0.0/go.mod h1:NEUY/Qq8Gdm2xgYA+NwJM6wmfdRV9xkh8h/Rld20R0U= github.com/Masterminds/sprig/v3 v3.0.2 h1:wz22D0CiSctrliXiI9ZO3HoNApweeRGftyDN+BQa3B8= github.com/Masterminds/sprig/v3 v3.0.2/go.mod h1:oesJ8kPONMONaZgtiHNzUShJbksypC5kWczhZAf6+aU= github.com/Masterminds/vcs v1.13.0 h1:USF5TvZGYgIpcbNAEMLfFhHqP08tFZVlUVrmTSpqnyA= From 08663e6bb3c5694726aac665d71be26494475781 Mon Sep 17 00:00:00 2001 From: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> Date: Wed, 8 Jan 2020 18:54:08 +0100 Subject: [PATCH 156/279] fix(helm): move ServiceAccount before Secret in InstallOrder. Service accounts must be installed before secrets when service account tokens (secrets) are be managed by Helm. Otherwise Kubernetes will delete any service account token right after creation, since there is no service account mounting the token (see https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#token-controller) Closes #7159. Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com> --- pkg/releaseutil/kind_sorter.go | 4 ++-- pkg/releaseutil/kind_sorter_test.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/releaseutil/kind_sorter.go b/pkg/releaseutil/kind_sorter.go index a5110a100..0402b8bb1 100644 --- a/pkg/releaseutil/kind_sorter.go +++ b/pkg/releaseutil/kind_sorter.go @@ -31,12 +31,12 @@ var InstallOrder KindSortOrder = []string{ "LimitRange", "PodSecurityPolicy", "PodDisruptionBudget", + "ServiceAccount", "Secret", "ConfigMap", "StorageClass", "PersistentVolume", "PersistentVolumeClaim", - "ServiceAccount", "CustomResourceDefinition", "ClusterRole", "ClusterRoleList", @@ -85,12 +85,12 @@ var UninstallOrder KindSortOrder = []string{ "ClusterRoleList", "ClusterRole", "CustomResourceDefinition", - "ServiceAccount", "PersistentVolumeClaim", "PersistentVolume", "StorageClass", "ConfigMap", "Secret", + "ServiceAccount", "PodDisruptionBudget", "PodSecurityPolicy", "LimitRange", diff --git a/pkg/releaseutil/kind_sorter_test.go b/pkg/releaseutil/kind_sorter_test.go index 93d8ae782..1b42383a5 100644 --- a/pkg/releaseutil/kind_sorter_test.go +++ b/pkg/releaseutil/kind_sorter_test.go @@ -40,7 +40,7 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "ClusterRoleBindingList"}, }, { - Name: "e", + Name: "f", Head: &SimpleHead{Kind: "ConfigMap"}, }, { @@ -84,11 +84,11 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "NetworkPolicy"}, }, { - Name: "f", + Name: "g", Head: &SimpleHead{Kind: "PersistentVolume"}, }, { - Name: "g", + Name: "h", Head: &SimpleHead{Kind: "PersistentVolumeClaim"}, }, { @@ -132,7 +132,7 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "RoleBindingList"}, }, { - Name: "d", + Name: "e", Head: &SimpleHead{Kind: "Secret"}, }, { @@ -140,7 +140,7 @@ func TestKindSorter(t *testing.T) { Head: &SimpleHead{Kind: "Service"}, }, { - Name: "h", + Name: "d", Head: &SimpleHead{Kind: "ServiceAccount"}, }, { @@ -166,8 +166,8 @@ func TestKindSorter(t *testing.T) { order KindSortOrder expected string }{ - {"install", InstallOrder, "aAbcC3de1fgh2iIjJkKlLmnopqrxstuvw!"}, - {"uninstall", UninstallOrder, "wvmutsxrqponLlKkJjIi2hgf1ed3CcbAa!"}, + {"install", InstallOrder, "aAbcC3def1gh2iIjJkKlLmnopqrxstuvw!"}, + {"uninstall", UninstallOrder, "wvmutsxrqponLlKkJjIi2hg1fed3CcbAa!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) { From 2f705f94b6f6c1d7846ea5f7748ba16c803f8797 Mon Sep 17 00:00:00 2001 From: Guangwen Feng Date: Thu, 9 Jan 2020 16:27:25 +0800 Subject: [PATCH 157/279] Add corresponding unit test to the function in parser.go Signed-off-by: Guangwen Feng --- pkg/strvals/parser_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/strvals/parser_test.go b/pkg/strvals/parser_test.go index 7f38efa52..44d317220 100644 --- a/pkg/strvals/parser_test.go +++ b/pkg/strvals/parser_test.go @@ -449,6 +449,39 @@ func TestParseIntoString(t *testing.T) { } } +func TestParseFile(t *testing.T) { + input := "name1=path1" + expect := map[string]interface{}{ + "name1": "value1", + } + rs2v := func(rs []rune) (interface{}, error) { + v := string(rs) + if v != "path1" { + t.Errorf("%s: runesToVal: Expected value path1, got %s", input, v) + return "", nil + } + return "value1", nil + } + + got, err := ParseFile(input, rs2v) + if err != nil { + t.Fatal(err) + } + + y1, err := yaml.Marshal(expect) + if err != nil { + t.Fatal(err) + } + y2, err := yaml.Marshal(got) + if err != nil { + t.Fatalf("Error serializing parsed value: %s", err) + } + + if string(y1) != string(y2) { + t.Errorf("%s: Expected:\n%s\nGot:\n%s", input, y1, y2) + } +} + func TestParseIntoFile(t *testing.T) { got := map[string]interface{}{} input := "name1=path1" From a963736f6675e972448bf7a5fd141628fd0ae4df Mon Sep 17 00:00:00 2001 From: Naseem Date: Thu, 9 Jan 2020 09:04:02 -0500 Subject: [PATCH 158/279] [helm create] Include serviceAccount.annotations value (#7246) * Include serviceAccount.annotations value Signed-off-by: Naseem * Add comment about service account annotations Signed-off-by: Naseem --- pkg/chartutil/create.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 4ca813593..390f12f4c 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -103,6 +103,8 @@ fullnameOverride: "" serviceAccount: # Specifies whether a service account should be created create: true + # Annotations to add to the service account + annotations: {} # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: @@ -303,6 +305,10 @@ metadata: name: {{ include ".serviceAccountName" . }} labels: {{ include ".labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} {{- end -}} ` From ff0e0085580a9131665f691006fb4d8699d6a95b Mon Sep 17 00:00:00 2001 From: Patrik Cyvoct Date: Fri, 10 Jan 2020 09:05:57 +0100 Subject: [PATCH 159/279] add option to bypass kubeconfig namespace Signed-off-by: Patrik Cyvoct --- pkg/kube/client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index cdd996925..ed4a3cf65 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -55,6 +55,8 @@ var ErrNoObjectsVisited = errors.New("no objects visited") type Client struct { Factory Factory Log func(string, ...interface{}) + // Namespace allows to bypass the kubeconfig file for the choice of the namespace + Namespace string } // New creates a new Client. @@ -113,6 +115,9 @@ func (c *Client) Wait(resources ResourceList, timeout time.Duration) error { } func (c *Client) namespace() string { + if c.Namespace != "" { + return c.Namespace + } if ns, _, err := c.Factory.ToRawKubeConfigLoader().Namespace(); err == nil { return ns } From 985827d09a0456551e116805a7c41c32800c85c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E7=9A=84=E6=BE=9C=E8=89=B2?= <33822635+zwwhdls@users.noreply.github.com> Date: Fri, 10 Jan 2020 23:01:59 +0800 Subject: [PATCH 160/279] stop with an error immediately if a file or directory with that name already exists (#7187) * fix #7182 Signed-off-by: zwwhdls * fix testcase Signed-off-by: zwwhdls * update error message Signed-off-by: zwwhdls * complete testCase when file/dir existed. Signed-off-by: zwwhdls * fix the case with current directory Signed-off-by: zwwhdls * fix conflict subdirectory when untardir is the clashing directory Signed-off-by: zwwhdls * update comment Signed-off-by: zwwhdls * add case when destination exists. Signed-off-by: zwwhdls --- cmd/helm/pull_test.go | 39 +++++++++++++++++++++++++++++++++++++-- pkg/action/pull.go | 16 ++++++++++++---- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index 248195774..1aca66100 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -41,7 +41,10 @@ func TestPullCmd(t *testing.T) { tests := []struct { name string args string + existFile string + existDir string wantError bool + wantErrorMsg string failExpect string expectFile string expectDir bool @@ -87,10 +90,24 @@ func TestPullCmd(t *testing.T) { expectFile: "./signtest", expectDir: true, }, + { + name: "Fetch untar when file with same name existed", + args: "test/test1 --untar --untardir test1", + existFile: "test1", + wantError: true, + wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "test1")), + }, + { + name: "Fetch untar when dir with same name existed", + args: "test/test2 --untar --untardir test2", + existDir: "test2", + wantError: true, + wantErrorMsg: fmt.Sprintf("failed to untar: a file or directory with the name %s already exists", filepath.Join(srv.Root(), "test2")), + }, { name: "Fetch, verify, untar", - args: "test/signtest --verify --keyring=testdata/helm-test-key.pub --untar --untardir signtest", - expectFile: "./signtest", + args: "test/signtest --verify --keyring=testdata/helm-test-key.pub --untar --untardir signtest2", + expectFile: "./signtest2", expectDir: true, expectVerify: true, }, @@ -127,9 +144,27 @@ func TestPullCmd(t *testing.T) { filepath.Join(outdir, "repositories.yaml"), outdir, ) + // Create file or Dir before helm pull --untar, see: https://github.com/helm/helm/issues/7182 + if tt.existFile != "" { + file := filepath.Join(outdir, tt.existFile) + _, err := os.Create(file) + if err != nil { + t.Fatal("err") + } + } + if tt.existDir != "" { + file := filepath.Join(outdir, tt.existDir) + err := os.Mkdir(file, 0755) + if err != nil { + t.Fatal(err) + } + } _, out, err := executeActionCommand(cmd) if err != nil { if tt.wantError { + if tt.wantErrorMsg != "" && tt.wantErrorMsg == err.Error() { + t.Fatalf("Actual error %s, not equal to expected error %s", err, tt.wantErrorMsg) + } return } t.Fatalf("%q reported error: %s", tt.name, err) diff --git a/pkg/action/pull.go b/pkg/action/pull.go index b0a3d2598..4ff5f5c3e 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -110,13 +110,21 @@ func (p *Pull) Run(chartRef string) (string, error) { if !filepath.IsAbs(ud) { ud = filepath.Join(p.DestDir, ud) } - if fi, err := os.Stat(ud); err != nil { - if err := os.MkdirAll(ud, 0755); err != nil { + // Let udCheck to check conflict file/dir without replacing ud when untarDir is the current directory(.). + udCheck := ud + if udCheck == "." { + _, udCheck = filepath.Split(chartRef) + } else { + _, chartName := filepath.Split(chartRef) + udCheck = filepath.Join(udCheck, chartName) + } + if _, err := os.Stat(udCheck); err != nil { + if err := os.MkdirAll(udCheck, 0755); err != nil { return out.String(), errors.Wrap(err, "failed to untar (mkdir)") } - } else if !fi.IsDir() { - return out.String(), errors.Errorf("failed to untar: %s is not a directory", ud) + } else { + return out.String(), errors.Errorf("failed to untar: a file or directory with the name %s already exists", udCheck) } return out.String(), chartutil.ExpandFile(ud, saved) From 6f11334d61caaf7ccbdba64ed2731fea6a70c52b Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Fri, 10 Jan 2020 11:36:42 -0500 Subject: [PATCH 161/279] go.mod,go.sum: bump Kubernetes dependencies 1.17.0 Signed-off-by: Joe Lanford --- go.mod | 21 +++----- go.sum | 149 +++++++++++++++++++++++++++++++++------------------------ 2 files changed, 92 insertions(+), 78 deletions(-) diff --git a/go.mod b/go.mod index ed074074d..bff4fed0e 100644 --- a/go.mod +++ b/go.mod @@ -19,26 +19,20 @@ require ( github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect github.com/emicklei/go-restful v2.11.1+incompatible // indirect github.com/evanphx/json-patch v4.5.0+incompatible - github.com/ghodss/yaml v1.0.0 // indirect - github.com/go-openapi/jsonreference v0.19.3 // indirect github.com/go-openapi/spec v0.19.4 // indirect github.com/gobwas/glob v0.2.3 github.com/gofrs/flock v0.7.1 github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect - github.com/google/btree v1.0.0 // indirect github.com/google/go-cmp v0.3.1 // indirect github.com/googleapis/gnostic v0.3.1 // indirect github.com/gosuri/uitable v0.0.1 github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect github.com/hashicorp/golang-lru v0.5.3 // indirect github.com/imdario/mergo v0.3.8 // indirect - github.com/mailru/easyjson v0.7.0 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mattn/go-shellwords v1.0.5 github.com/mitchellh/copystructure v1.0.0 - github.com/onsi/ginkgo v1.10.1 // indirect - github.com/onsi/gomega v1.7.0 // indirect github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/image-spec v1.0.1 github.com/pkg/errors v0.8.1 @@ -58,16 +52,13 @@ require ( google.golang.org/appengine v1.6.5 // indirect google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect google.golang.org/grpc v1.24.0 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - k8s.io/api v0.0.0-20191016110408-35e52d86657a - k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65 - k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8 - k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5 - k8s.io/client-go v0.0.0-20191016111102-bec269661e48 + k8s.io/api v0.17.0 + k8s.io/apiextensions-apiserver v0.17.0 + k8s.io/apimachinery v0.17.1-beta.0 + k8s.io/cli-runtime v0.17.0 + k8s.io/client-go v0.17.0 k8s.io/klog v1.0.0 - k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d // indirect - k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51 - k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 // indirect + k8s.io/kubectl v0.17.0 sigs.k8s.io/yaml v1.1.0 ) diff --git a/go.sum b/go.sum index 629d466c2..bbad3e1b7 100644 --- a/go.sum +++ b/go.sum @@ -47,10 +47,12 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= +github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= @@ -61,6 +63,7 @@ github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/blang/semver v3.5.0+incompatible h1:CGxCgetQ64DKk7rdZ++Vfnb1+ogGNnB17OJKJXD2Cfs= @@ -78,17 +81,14 @@ github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tj github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 h1:7aWHqerlJ41y6FOsEUvknqgXnGmJyJSbjhAWq5pO4F8= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4 h1:aMyA5J7j6D07U7pf8BFEY67BKoDcz0zWleAbQj3zVng= github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/containerd v1.3.0 h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY= github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 h1:4BX8f882bXEDKfWIf0wa8HRvpnBoPszJJXL+TVbBw4M= github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/coreos/bbolt v1.3.1-coreos.6 h1:uTXKg9gY70s9jMAKdfljFQcuh4e/BXOM+V+d00KFj3A= -github.com/coreos/bbolt v1.3.1-coreos.6/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.15+incompatible h1:+9RjdC18gMxNQVvSiXvObLu29mOFmkgdsB4cRTlV+EE= -github.com/coreos/etcd v3.3.15+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -96,10 +96,13 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea h1:n2Ltr3SrfQlf/9nOna1DoGKxLx3qTSI8Ttl6Xrqp6mw= github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -134,6 +137,8 @@ github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZ github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e h1:p1yVGRW3nmb85p1Sh1ZJSDm4A4iKLS5QNbvUHMgGu/M= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -148,12 +153,12 @@ github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc= github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= @@ -171,6 +176,7 @@ github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpR github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.19.2 h1:ophLETFestFZHk3ji7niPEL4d466QjW+0Tdg5VyDq7E= github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY= @@ -194,20 +200,24 @@ github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.2 h1:rf5ArTHmIJxyV5Oiks+Su0mUens1+AjpkPoWr5xFRcI= github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= +github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk= github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.2 h1:SStNd1jRcYtfKCN7R0laGNs80WYYvn5CbBjM2sOmCrE= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= +github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo= github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= @@ -218,6 +228,7 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2 h1:ky5l57HjyVRrsJfd2+Ro5Z9PjGuKbsmftwyMtk8H7js= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= @@ -275,18 +286,18 @@ github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZs github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.0 h1:tOSd0UKHQd6urX6ApfOn4XdBMY6Sh1MfxV3kmaazO+U= github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gosuri/uitable v0.0.1 h1:M9sMNgSZPyAu1FJZJLpJ16ofL8q5ko2EDUkICsynvlY= github.com/gosuri/uitable v0.0.1/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= -github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM= github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 h1:lR9ssWAqp9qL0bALxqEEkuudiP1eweOdv9jsRK3e7lE= -github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -310,6 +321,8 @@ github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBv github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro= @@ -338,6 +351,9 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.5 h1:JhhFTIOslh5ZsPrpa3Wdg8bF0WI3b44EMblmU9wIsXc= @@ -367,18 +383,16 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c h1:nXxl5PrvVm2L/wCy8dQu6DMTwH4oIuGN8GJDAlqDdVE= github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= @@ -429,13 +443,14 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/soheilhy/cmux v0.1.3 h1:09wy7WZk4AqO03yH85Ex1X+Uo3vDsil3Fa9AgF8Emss= -github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= @@ -446,6 +461,7 @@ github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -460,9 +476,12 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 h1:ndzgwNDnKIqyCvHTXaCqh9KlOWKvBry6nuXMJmonVsE= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= @@ -472,8 +491,8 @@ github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4m github.com/xenolf/lego v0.0.0-20160613233155-a9d8cec0e656/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY= github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656 h1:BTvU+npm3/yjuBd53EvgiFLl5+YLikf2WvHsjRQ4KrY= github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY= -github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= -github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 h1:p7OofyZ509h8DmPLh8Hn+EIIZm/xYhdZHJ9GnXHdr6U= github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= @@ -481,13 +500,15 @@ github.com/yvasiyarov/gorelic v0.0.6 h1:qMJQYPNdtJ7UNYHjX38KXZtltKTqimMuoQjNnSVI github.com/yvasiyarov/gorelic v0.0.6/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569 h1:nSQar3Y0E3VQF/VdZ8PTAilaXpER+d7ypdABCrpwMdg= -go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/multierr v0.0.0-20180122172545-ddea229ff1df h1:shvkWr0NAZkg4nPuE3XrKP0VuBPijjk3TfX6Y6acFNg= -go.uber.org/multierr v0.0.0-20180122172545-ddea229ff1df/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v0.0.0-20180814183419-67bc79d13d15 h1:Z2sc4+v0JHV6Mn4kX1f2a5nruNjmV+Th32sugE8zwz8= -go.uber.org/zap v0.0.0-20180814183419-67bc79d13d15/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -495,6 +516,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 h1:ZC1Xn5A1nlpSmQCIva4bZ3ob3lmhYIefc+GU+DLg1Ow= @@ -517,6 +540,7 @@ golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -524,9 +548,10 @@ golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68= -golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 h1:N66aaryRB3Ax92gH0v3hp1QYZ3zWWCCUR/j8Ifh45Ss= golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -544,6 +569,7 @@ golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -554,6 +580,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 h1:u/E0NqCIWRDAo9WCFo6Ko49njPFDLSd3z+X1HgWDMpE= golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -562,8 +589,10 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -572,6 +601,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -579,8 +609,9 @@ golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485 h1:OB/uP/Puiu5vS5QMRPrXCDWUPb+kt8f1KW8oQzFejQw= gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= @@ -605,26 +636,26 @@ google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9M google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= -gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v1 v1.1.2 h1:/5jmADZB+RiKtZGr4HxsEFOEfbfsjTKsVnqpThUpE30= gopkg.in/square/go-jose.v1 v1.1.2/go.mod h1:QpYS+a4WhS+DTlyQIi6Ka7MS3SuR9a055rgXNEe6EiA= gopkg.in/square/go-jose.v2 v2.2.2 h1:orlkJ3myw8CN1nVQHBFfloD+L3egixIa4FvUP6RosSA= gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -636,43 +667,35 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.0.0-20191016110408-35e52d86657a h1:VVUE9xTCXP6KUPMf92cQmN88orz600ebexcRRaBTepQ= -k8s.io/api v0.0.0-20191016110408-35e52d86657a/go.mod h1:/L5qH+AD540e7Cetbui1tuJeXdmNhO8jM6VkXeDdDhQ= -k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65 h1:kThoiqgMsSwBdMK/lPgjtYTsEjbUU9nXCA9DyU3feok= -k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65/go.mod h1:5BINdGqggRXXKnDgpwoJ7PyQH8f+Ypp02fvVNcIFy9s= -k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8 h1:Iieh/ZEgT3BWwbLD5qEKcY06jKuPEl6zC7gPSehoLw4= -k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8/go.mod h1:llRdnznGEAqC3DcNm6yEj472xaFVfLM7hnYofMb12tQ= -k8s.io/apiserver v0.0.0-20191016112112-5190913f932d h1:leksCBKKBrPJmW1jV4dZUvwqmVtXpKdzpHsqXfFS094= -k8s.io/apiserver v0.0.0-20191016112112-5190913f932d/go.mod h1:7OqfAolfWxUM/jJ/HBLyE+cdaWFBUoo5Q5pHgJVj2ws= -k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5 h1:8ZfMjkMBzcXEawLsYHg9lDM7aLEVso3NiVKfUTnN56A= -k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5/go.mod h1:sDl6WKSQkDM6zS1u9F49a0VooQ3ycYFBFLqd2jf2Xfo= -k8s.io/client-go v0.0.0-20191016111102-bec269661e48 h1:C2XVy2z0dV94q9hSSoCuTPp1KOG7IegvbdXuz9VGxoU= -k8s.io/client-go v0.0.0-20191016111102-bec269661e48/go.mod h1:hrwktSwYGI4JK+TJA3dMaFyyvHVi/aLarVHpbs8bgCU= -k8s.io/code-generator v0.0.0-20191004115455-8e001e5d1894 h1:NMYlxaF7rYQJk2E2IyrUhaX81zX24+dmoZdkPw0gJqI= -k8s.io/code-generator v0.0.0-20191004115455-8e001e5d1894/go.mod h1:mJUgkl06XV4kstAnLHAIzJPVCOzVR+ZcfPIv4fUsFCY= -k8s.io/component-base v0.0.0-20191016111319-039242c015a9 h1:2D+G/CCNVdYc0h9D+tX+0SmtcyQmby6uzNityrps1s0= -k8s.io/component-base v0.0.0-20191016111319-039242c015a9/go.mod h1:SuWowIgd/dtU/m/iv8OD9eOxp3QZBBhTIiWMsBQvKjI= +k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM= +k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= +k8s.io/apiextensions-apiserver v0.17.0 h1:+XgcGxqaMztkbbvsORgCmHIb4uImHKvTjNyu7b8gRnA= +k8s.io/apiextensions-apiserver v0.17.0/go.mod h1:XiIFUakZywkUl54fVXa7QTEHcqQz9HG55nHd1DCoHj8= +k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= +k8s.io/apimachinery v0.17.1-beta.0 h1:0Wl/KpAiFOMe9to5h8x2Y6JnjV+BEWJiTcUk1Vx7zdE= +k8s.io/apimachinery v0.17.1-beta.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= +k8s.io/apiserver v0.17.0/go.mod h1:ABM+9x/prjINN6iiffRVNCBR2Wk7uY4z+EtEGZD48cg= +k8s.io/cli-runtime v0.17.0 h1:XEuStbJBHCQlEKFyTQmceDKEWOSYHZkcYWKp3SsQ9Hk= +k8s.io/cli-runtime v0.17.0/go.mod h1:1E5iQpMODZq2lMWLUJELwRu2MLWIzwvMgDBpn3Y81Qo= +k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg= +k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k= +k8s.io/code-generator v0.17.0/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= +k8s.io/component-base v0.17.0 h1:BnDFcmBDq+RPpxXjmuYnZXb59XNN9CaFrX8ba9+3xrA= +k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20190822140433-26a664648505 h1:ZY6yclUKVbZ+SdWnkfY+Je5vrMpKOxmGeKRbsXVmqYM= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.4.0 h1:lCJCxf/LIowc2IGS9TPjWDyXY4nOmdGdfcwwDQCOURQ= -k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ= -k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d h1:Xpe6sK+RY4ZgCTyZ3y273UmFmURhjtoJiwOMbQsXitY= -k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51 h1:RBkTKVMF+xsNsSOVc0+HdC0B5gD1sr6s6Cu5w9qNbuQ= -k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51/go.mod h1:gL826ZTIfD4vXTGlmzgTbliCAT9NGiqpCqK2aNYv5MQ= -k8s.io/metrics v0.0.0-20191016113814-3b1a734dba6e h1:VbAmCGT95GvCZaGtW3oLhf7d2FXT+lnWiTtPE8hzPVo= -k8s.io/metrics v0.0.0-20191016113814-3b1a734dba6e/go.mod h1:ve7/vMWeY5lEBkZf6Bt5TTbGS3b8wAxwGbdXAsufjRs= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 h1:Gi+/O1saihwDqnlmC8Vhv1M5Sp4+rbOmK9TbsLn8ZEA= -k8s.io/utils v0.0.0-20191010214722-8d271d903fe4/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= +k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= +k8s.io/kubectl v0.17.0 h1:xD4EWlL+epc/JTO1gvSjmV9yiYF0Z2wiHK2DIek6URY= +k8s.io/kubectl v0.17.0/go.mod h1:jIPrUAW656Vzn9wZCCe0PC+oTcu56u2HgFD21Xbfk1s= +k8s.io/metrics v0.17.0/go.mod h1:EH1D3YAwN6d7bMelrElnLhLg72l/ERStyv2SIQVt6Do= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= +k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= @@ -681,7 +704,7 @@ modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca h1:6dsH6AYQWbyZmtttJNe8Gq1cXOeS1BdV3eW37zHilAQ= -sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA= +sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI= From d3a8cc4713ddeb5f3b6e698e6e3d295e26d1eb84 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 11 Jan 2020 20:43:35 -0500 Subject: [PATCH 162/279] feat(chore): Remove unused code Signed-off-by: Marc Khouzam --- pkg/repo/index.go | 47 ------------------- pkg/repo/index_test.go | 20 -------- pkg/repo/testdata/unversioned-index.yaml | 60 ------------------------ 3 files changed, 127 deletions(-) delete mode 100644 pkg/repo/testdata/unversioned-index.yaml diff --git a/pkg/repo/index.go b/pkg/repo/index.go index a7fea673b..36386665e 100644 --- a/pkg/repo/index.go +++ b/pkg/repo/index.go @@ -17,8 +17,6 @@ limitations under the License. package repo import ( - "encoding/json" - "fmt" "io/ioutil" "os" "path" @@ -290,48 +288,3 @@ func loadIndex(data []byte) (*IndexFile, error) { } return i, nil } - -// unversionedEntry represents a deprecated pre-Alpha.5 format. -// -// This will be removed prior to v2.0.0 -type unversionedEntry struct { - Checksum string `json:"checksum"` - URL string `json:"url"` - Chartfile *chart.Metadata `json:"chartfile"` -} - -// loadUnversionedIndex loads a pre-Alpha.5 index.yaml file. -// -// This format is deprecated. This function will be removed prior to v2.0.0. -func loadUnversionedIndex(data []byte) (*IndexFile, error) { - fmt.Fprintln(os.Stderr, "WARNING: Deprecated index file format. Try 'helm repo update'") - i := map[string]unversionedEntry{} - - // This gets around an error in the YAML parser. Instead of parsing as YAML, - // we convert to JSON, and then decode again. - var err error - data, err = yaml.YAMLToJSON(data) - if err != nil { - return nil, err - } - if err := json.Unmarshal(data, &i); err != nil { - return nil, err - } - - if len(i) == 0 { - return nil, ErrNoAPIVersion - } - ni := NewIndexFile() - for n, item := range i { - if item.Chartfile == nil || item.Chartfile.Name == "" { - parts := strings.Split(n, "-") - ver := "" - if len(parts) > 1 { - ver = strings.TrimSuffix(parts[1], ".tgz") - } - item.Chartfile = &chart.Metadata{Name: parts[0], Version: ver} - } - ni.Add(item.Chartfile, item.URL, "", item.Checksum) - } - return ni, nil -} diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index c830a339e..b5119166a 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -361,26 +361,6 @@ func TestIndexDirectory(t *testing.T) { } } -func TestLoadUnversionedIndex(t *testing.T) { - data, err := ioutil.ReadFile("testdata/unversioned-index.yaml") - if err != nil { - t.Fatal(err) - } - - ind, err := loadUnversionedIndex(data) - if err != nil { - t.Fatal(err) - } - - if l := len(ind.Entries); l != 2 { - t.Fatalf("Expected 2 entries, got %d", l) - } - - if l := len(ind.Entries["mysql"]); l != 3 { - t.Fatalf("Expected 3 mysql versions, got %d", l) - } -} - func TestIndexAdd(t *testing.T) { i := NewIndexFile() i.Add(&chart.Metadata{Name: "clipper", Version: "0.1.0"}, "clipper-0.1.0.tgz", "http://example.com/charts", "sha256:1234567890") diff --git a/pkg/repo/testdata/unversioned-index.yaml b/pkg/repo/testdata/unversioned-index.yaml deleted file mode 100644 index 1d814c7ae..000000000 --- a/pkg/repo/testdata/unversioned-index.yaml +++ /dev/null @@ -1,60 +0,0 @@ -memcached-0.1.0: - name: memcached - url: https://mumoshu.github.io/charts/memcached-0.1.0.tgz - created: 2016-08-04 02:05:02.259205055 +0000 UTC - checksum: ce9b76576c4b4eb74286fa30a978c56d69e7a522 - chartfile: - name: memcached - home: http://https://hub.docker.com/_/memcached/ - sources: [] - version: 0.1.0 - description: A simple Memcached cluster - keywords: [] - maintainers: - - name: Matt Butcher - email: mbutcher@deis.com -mysql-0.2.0: - name: mysql - url: https://mumoshu.github.io/charts/mysql-0.2.0.tgz - created: 2016-08-04 00:42:47.517342022 +0000 UTC - checksum: aa5edd2904d639b0b6295f1c7cf4c0a8e4f77dd3 - chartfile: - name: mysql - home: https://www.mysql.com/ - sources: [] - version: 0.2.0 - description: Chart running MySQL. - keywords: [] - maintainers: - - name: Matt Fisher - email: mfisher@deis.com -mysql-0.2.1: - name: mysql - url: https://mumoshu.github.io/charts/mysql-0.2.1.tgz - created: 2016-08-04 02:40:29.717829534 +0000 UTC - checksum: 9d9f056171beefaaa04db75680319ca4edb6336a - chartfile: - name: mysql - home: https://www.mysql.com/ - sources: [] - version: 0.2.1 - description: Chart running MySQL. - keywords: [] - maintainers: - - name: Matt Fisher - email: mfisher@deis.com -mysql-0.2.2: - name: mysql - url: https://mumoshu.github.io/charts/mysql-0.2.2.tgz - created: 2016-08-04 02:40:29.71841952 +0000 UTC - checksum: 6d6810e76a5987943faf0040ec22990d9fb141c7 - chartfile: - name: mysql - home: https://www.mysql.com/ - sources: [] - version: 0.2.2 - description: Chart running MySQL. - keywords: [] - maintainers: - - name: Matt Fisher - email: mfisher@deis.com From f437b4d6c9755c30dc2e57a79c79e73bbda2fff3 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 11 Jan 2020 21:46:27 -0500 Subject: [PATCH 163/279] feat(comp): Speed up completion of charts The completion of charts was using 'helm search repo' which can be quite slow as it must parse the entire yaml of every repo cache file. Using completion for a chart name can end up triggering multiple calls to 'helm search'; this makes the user experience poor, as there is a delay of over a second at every press. This commit creates a cache file for each repo which contains the list of charts for that repo. The completion logic then uses this new cache file directly and obtains the chart names very quickly. With only the stable repo configured, this optimization makes the completion of charts about 85 times faster, going from 1.2 seconds to 0.014 seconds; such a difference gives a much better user experience when completing chart names. On the other hand, adding the creation of the chart list cache file to 'helm repo update' or 'helm repo add' is pretty much negligible compared to the downloading of the index file. It is also worth noting that when more repos are configured, 'helm search repo' only becomes slower, while the completion logic that uses the new chart list cache file will not be affected as it only looks for the single relevant repo file. Signed-off-by: Marc Khouzam --- cmd/helm/repo_add_test.go | 16 +++++++++++- cmd/helm/repo_remove.go | 7 +++++- cmd/helm/repo_remove_test.go | 11 +++++++-- cmd/helm/root.go | 16 ++++++++++-- pkg/helmpath/home.go | 11 ++++++++- pkg/repo/chartrepo.go | 13 +++++++++- pkg/repo/index_test.go | 47 ++++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 8 deletions(-) diff --git a/cmd/helm/repo_add_test.go b/cmd/helm/repo_add_test.go index 4dbd0f435..d1b9bc0fc 100644 --- a/cmd/helm/repo_add_test.go +++ b/cmd/helm/repo_add_test.go @@ -19,6 +19,7 @@ package main import ( "fmt" "io/ioutil" + "os" "path/filepath" "sync" "testing" @@ -26,6 +27,8 @@ import ( "sigs.k8s.io/yaml" "helm.sh/helm/v3/internal/test/ensure" + "helm.sh/helm/v3/pkg/helmpath" + "helm.sh/helm/v3/pkg/helmpath/xdg" "helm.sh/helm/v3/pkg/repo" "helm.sh/helm/v3/pkg/repo/repotest" ) @@ -55,7 +58,8 @@ func TestRepoAdd(t *testing.T) { } defer ts.Stop() - repoFile := filepath.Join(ensure.TempDir(t), "repositories.yaml") + rootDir := ensure.TempDir(t) + repoFile := filepath.Join(rootDir, "repositories.yaml") const testRepoName = "test-name" @@ -65,6 +69,7 @@ func TestRepoAdd(t *testing.T) { noUpdate: true, repoFile: repoFile, } + os.Setenv(xdg.CacheHomeEnvVar, rootDir) if err := o.run(ioutil.Discard); err != nil { t.Error(err) @@ -79,6 +84,15 @@ func TestRepoAdd(t *testing.T) { t.Errorf("%s was not successfully inserted into %s", testRepoName, repoFile) } + idx := filepath.Join(helmpath.CachePath("repository"), helmpath.CacheIndexFile(testRepoName)) + if _, err := os.Stat(idx); os.IsNotExist(err) { + t.Errorf("Error cache index file was not created for repository %s", testRepoName) + } + idx = filepath.Join(helmpath.CachePath("repository"), helmpath.CacheChartsFile(testRepoName)) + if _, err := os.Stat(idx); os.IsNotExist(err) { + t.Errorf("Error cache charts file was not created for repository %s", testRepoName) + } + o.noUpdate = false if err := o.run(ioutil.Discard); err != nil { diff --git a/cmd/helm/repo_remove.go b/cmd/helm/repo_remove.go index c1ecb1829..ea7a5db24 100644 --- a/cmd/helm/repo_remove.go +++ b/cmd/helm/repo_remove.go @@ -76,7 +76,12 @@ func (o *repoRemoveOptions) run(out io.Writer) error { } func removeRepoCache(root, name string) error { - idx := filepath.Join(root, helmpath.CacheIndexFile(name)) + idx := filepath.Join(root, helmpath.CacheChartsFile(name)) + if _, err := os.Stat(idx); err == nil { + os.Remove(idx) + } + + idx = filepath.Join(root, helmpath.CacheIndexFile(name)) if _, err := os.Stat(idx); os.IsNotExist(err) { return nil } else if err != nil { diff --git a/cmd/helm/repo_remove_test.go b/cmd/helm/repo_remove_test.go index 3fdcbe9c3..85c76bb92 100644 --- a/cmd/helm/repo_remove_test.go +++ b/cmd/helm/repo_remove_test.go @@ -63,10 +63,13 @@ func TestRepoRemove(t *testing.T) { } idx := filepath.Join(rootDir, helmpath.CacheIndexFile(testRepoName)) - mf, _ := os.Create(idx) mf.Close() + idx2 := filepath.Join(rootDir, helmpath.CacheChartsFile(testRepoName)) + mf, _ = os.Create(idx2) + mf.Close() + b.Reset() if err := rmOpts.run(b); err != nil { @@ -77,7 +80,11 @@ func TestRepoRemove(t *testing.T) { } if _, err := os.Stat(idx); err == nil { - t.Errorf("Error cache file was not removed for repository %s", testRepoName) + t.Errorf("Error cache index file was not removed for repository %s", testRepoName) + } + + if _, err := os.Stat(idx2); err == nil { + t.Errorf("Error cache chart file was not removed for repository %s", testRepoName) } f, err := repo.LoadFile(repoFile) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 3405299fd..bba3ff643 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -139,13 +139,25 @@ __helm_zsh_comp_nospace() { __helm_list_charts() { __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local repo url file out=() nospace=0 wantFiles=$1 + local prefix chart repo url file out=() nospace=0 wantFiles=$1 # Handle completions for repos for repo in $(__helm_get_repos); do if [[ "${cur}" =~ ^${repo}/.* ]]; then # We are doing completion from within a repo - out=$(eval $(__helm_binary_name) search repo ${cur} 2>/dev/null | \cut -f1 | \grep ^${cur}) + local cacheFile=$(eval $(__helm_binary_name) env 2>/dev/null | \grep HELM_REPOSITORY_CACHE | \cut -d= -f2 | \sed s/\"//g)/${repo}-charts.txt + if [ -f "$cacheFile" ]; then + # Get the list of charts from the cached file + prefix=${cur#${repo}/} + for chart in $(\grep ^$prefix $cacheFile); do + out+=(${repo}/${chart}) + done + else + # If there is no cached list file, fallback to helm search, which is much slower + # This will happen after the caching feature is first installed but before the user + # does a 'helm repo update' to generate the cached list file. + out=$(eval $(__helm_binary_name) search repo ${cur} 2>/dev/null | \cut -f1 | \grep ^${cur}) + fi nospace=0 elif [[ ${repo} =~ ^${cur}.* ]]; then # We are completing a repo name diff --git a/pkg/helmpath/home.go b/pkg/helmpath/home.go index 0b0f110a5..b3f14c558 100644 --- a/pkg/helmpath/home.go +++ b/pkg/helmpath/home.go @@ -25,10 +25,19 @@ func CachePath(elem ...string) string { return lp.cachePath(elem...) } // DataPath returns the path where Helm stores data. func DataPath(elem ...string) string { return lp.dataPath(elem...) } -// CacheIndex returns the path to an index for the given named repository. +// CacheIndexFile returns the path to an index for the given named repository. func CacheIndexFile(name string) string { if name != "" { name += "-" } return name + "index.yaml" } + +// CacheChartsFile returns the path to a text file listing all the charts +// within the given named repository. +func CacheChartsFile(name string) string { + if name != "" { + name += "-" + } + return name + "charts.txt" +} diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index c8d0d6a3d..38b6b8fb0 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -133,10 +133,21 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) { return "", err } - if _, err := loadIndex(index); err != nil { + indexFile, err := loadIndex(index) + if err != nil { return "", err } + // Create the chart list file in the cache directory + var charts strings.Builder + for name := range indexFile.Entries { + fmt.Fprintln(&charts, name) + } + chartsFile := filepath.Join(r.CachePath, helmpath.CacheChartsFile(r.Config.Name)) + os.MkdirAll(filepath.Dir(chartsFile), 0755) + ioutil.WriteFile(chartsFile, []byte(charts.String()), 0644) + + // Create the index file in the cache directory fname := filepath.Join(r.CachePath, helmpath.CacheIndexFile(r.Config.Name)) os.MkdirAll(filepath.Dir(fname), 0755) return fname, ioutil.WriteFile(fname, index, 0644) diff --git a/pkg/repo/index_test.go b/pkg/repo/index_test.go index c830a339e..ab998ba54 100644 --- a/pkg/repo/index_test.go +++ b/pkg/repo/index_test.go @@ -17,14 +17,19 @@ limitations under the License. package repo import ( + "bufio" + "bytes" "io/ioutil" "net/http" "os" + "path/filepath" + "sort" "strings" "testing" "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/getter" + "helm.sh/helm/v3/pkg/helmpath" "helm.sh/helm/v3/pkg/chart" ) @@ -178,6 +183,18 @@ func TestDownloadIndexFile(t *testing.T) { t.Fatalf("Index %q failed to parse: %s", testfile, err) } verifyLocalIndex(t, i) + + // Check that charts file is also created + idx = filepath.Join(r.CachePath, helmpath.CacheChartsFile(r.Config.Name)) + if _, err := os.Stat(idx); err != nil { + t.Fatalf("error finding created charts file: %#v", err) + } + + b, err = ioutil.ReadFile(idx) + if err != nil { + t.Fatalf("error reading charts file: %#v", err) + } + verifyLocalChartsFile(t, b, i) }) t.Run("should not decode the path in the repo url while downloading index", func(t *testing.T) { @@ -224,6 +241,18 @@ func TestDownloadIndexFile(t *testing.T) { t.Fatalf("Index %q failed to parse: %s", testfile, err) } verifyLocalIndex(t, i) + + // Check that charts file is also created + idx = filepath.Join(r.CachePath, helmpath.CacheChartsFile(r.Config.Name)) + if _, err := os.Stat(idx); err != nil { + t.Fatalf("error finding created charts file: %#v", err) + } + + b, err = ioutil.ReadFile(idx) + if err != nil { + t.Fatalf("error reading charts file: %#v", err) + } + verifyLocalChartsFile(t, b, i) }) } @@ -322,6 +351,24 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) { } } +func verifyLocalChartsFile(t *testing.T, chartsContent []byte, indexContent *IndexFile) { + var expected, real []string + for chart := range indexContent.Entries { + expected = append(expected, chart) + } + sort.Strings(expected) + + scanner := bufio.NewScanner(bytes.NewReader(chartsContent)) + for scanner.Scan() { + real = append(real, scanner.Text()) + } + sort.Strings(real) + + if strings.Join(expected, " ") != strings.Join(real, " ") { + t.Errorf("Cached charts file content unexpected. Expected:\n%s\ngot:\n%s", expected, real) + } +} + func TestIndexDirectory(t *testing.T) { dir := "testdata/repository" index, err := IndexDirectory(dir, "http://localhost:8080") From e2e21342fdb19aecb4373fc355edddeb1f7fc3db Mon Sep 17 00:00:00 2001 From: etashsingh Date: Mon, 13 Jan 2020 11:59:31 +0530 Subject: [PATCH 164/279] Refactored alpine-pod.yaml file to make the example work in accordance to the Values.yaml file Signed-off-by: etashsingh --- cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml index ae19a1127..a1a44e53f 100644 --- a/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml +++ b/cmd/helm/testdata/testcharts/alpine/templates/alpine-pod.yaml @@ -14,7 +14,7 @@ metadata: app.kubernetes.io/version: {{ .Chart.AppVersion }} # This makes it easy to audit chart usage. helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - values: {{.Values.test.Name}} + values: {{.Values.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. From 16f62050044d8eaca1ee794ab1903a719895662f Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 13 Jan 2020 10:25:31 -0500 Subject: [PATCH 165/279] fix(test): Make resetEnv() properly reset settings Because the 'settings' variable is a pointer, it cannot be used to store the original envSettings and then restore them. Instead, this commit creates an entirely new envSettings, after having set the environment variables, which may affect it. Signed-off-by: Marc Khouzam --- cmd/helm/helm_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index a08720e7a..b7156daf3 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -31,6 +31,7 @@ import ( "helm.sh/helm/v3/internal/test" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chartutil" + "helm.sh/helm/v3/pkg/cli" kubefake "helm.sh/helm/v3/pkg/kube/fake" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/storage" @@ -136,14 +137,14 @@ func executeActionCommand(cmd string) (*cobra.Command, string, error) { } func resetEnv() func() { - origSettings, origEnv := settings, os.Environ() + origEnv := os.Environ() return func() { os.Clearenv() - settings = origSettings for _, pair := range origEnv { kv := strings.SplitN(pair, "=", 2) os.Setenv(kv[0], kv[1]) } + settings = cli.New() } } From 0cdbbf287f04e10f6b44faf1bf9185b48ca7f3fa Mon Sep 17 00:00:00 2001 From: Guangwen Feng Date: Tue, 14 Jan 2020 14:11:08 +0800 Subject: [PATCH 166/279] Fix typo in comment for func IsReachable Signed-off-by: Guangwen Feng --- pkg/kube/fake/printer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/fake/printer.go b/pkg/kube/fake/printer.go index ec75aa790..58b389ab5 100644 --- a/pkg/kube/fake/printer.go +++ b/pkg/kube/fake/printer.go @@ -33,7 +33,7 @@ type PrintingKubeClient struct { Out io.Writer } -// isReachable checks if the cluster is reachable +// IsReachable checks if the cluster is reachable func (p *PrintingKubeClient) IsReachable() error { return nil } From e2946c7e343f0b0404b5f4e9ecabdccd970a87c8 Mon Sep 17 00:00:00 2001 From: Bradley Skuse Date: Thu, 19 Dec 2019 16:21:24 +0800 Subject: [PATCH 167/279] Fix: helm3 - kind sorter incorrectly compares unknown and namespace Signed-off-by: Bradley Skuse Fix style error from CI Signed-off-by: Bradley Skuse Fix: helm3 - kind sorter incorrectly compares unknown and namespace Fix: helm3 - kind sorter incorrectly compares unknown and namespace Fix: helm3 - kind sorter incorrectly compares unknown and namespace --- pkg/releaseutil/kind_sorter.go | 8 +++++--- pkg/releaseutil/kind_sorter_test.go | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkg/releaseutil/kind_sorter.go b/pkg/releaseutil/kind_sorter.go index 3ab8ab2a4..92ffa03f2 100644 --- a/pkg/releaseutil/kind_sorter.go +++ b/pkg/releaseutil/kind_sorter.go @@ -134,11 +134,13 @@ func (k *kindSorter) Less(i, j int) bool { b := k.manifests[j] first, aok := k.ordering[a.Head.Kind] second, bok := k.ordering[b.Head.Kind] - if first == second { - // if both are unknown and of different kind sort by kind alphabetically - if !aok && !bok && a.Head.Kind != b.Head.Kind { + + if !aok && !bok { + // if both are unknown then sort alphabetically by kind, keep original order if same kind + if a.Head.Kind != b.Head.Kind { return a.Head.Kind < b.Head.Kind } + return first < second } // unknown kind is last if !aok { diff --git a/pkg/releaseutil/kind_sorter_test.go b/pkg/releaseutil/kind_sorter_test.go index f29065f73..4747e8252 100644 --- a/pkg/releaseutil/kind_sorter_test.go +++ b/pkg/releaseutil/kind_sorter_test.go @@ -245,3 +245,24 @@ func TestKindSorterKeepOriginalOrder(t *testing.T) { }) } } + +func TestKindSorterNamespaceAgainstUnknown(t *testing.T) { + unknown := Manifest{ + Name: "a", + Head: &SimpleHead{Kind: "Unknown"}, + } + namespace := Manifest{ + Name: "b", + Head: &SimpleHead{Kind: "Namespace"}, + } + + manifests := []Manifest{unknown, namespace} + sortByKind(manifests, InstallOrder) + + expectedOrder := []Manifest{namespace, unknown} + for i, manifest := range manifests { + if expectedOrder[i].Name != manifest.Name { + t.Errorf("Expected %s, got %s", expectedOrder[i].Name, manifest.Name) + } + } +} From e868cb23c0939647dd37d53b1b4e0d5ffe99d65b Mon Sep 17 00:00:00 2001 From: Simon Alling Date: Wed, 15 Jan 2020 16:51:04 +0100 Subject: [PATCH 168/279] ref(pkg/storage): Refactor Deployed and DeployedAll (#7374) The error returned from DeployedAll will never contain "not found". The error returned at the end of Deployed is already known to be nil, and we never want to return ls[0] together with a non-nil error anyway. Signed-off-by: Simon Alling --- pkg/storage/storage.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 6528c48ba..56881493b 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -112,9 +112,6 @@ func (s *Storage) ListDeployed() ([]*rspb.Release, error) { func (s *Storage) Deployed(name string) (*rspb.Release, error) { ls, err := s.DeployedAll(name) if err != nil { - if strings.Contains(err.Error(), "not found") { - return nil, errors.Errorf("%q has no deployed releases", name) - } return nil, err } @@ -122,7 +119,7 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) { return nil, errors.Errorf("%q has no deployed releases", name) } - return ls[0], err + return ls[0], nil } // DeployedAll returns all deployed releases with the provided name, or From c365c8dcdc99e1fa294fa985d802b20e94b9c30a Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Wed, 15 Jan 2020 11:46:59 -0500 Subject: [PATCH 169/279] go.mod,go.sum: bump to k8s v1.17.1 Signed-off-by: Joe Lanford --- go.mod | 12 ++++++------ go.sum | 35 +++++++++++++++++------------------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index bff4fed0e..c7b25ac13 100644 --- a/go.mod +++ b/go.mod @@ -52,13 +52,13 @@ require ( google.golang.org/appengine v1.6.5 // indirect google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect google.golang.org/grpc v1.24.0 // indirect - k8s.io/api v0.17.0 - k8s.io/apiextensions-apiserver v0.17.0 - k8s.io/apimachinery v0.17.1-beta.0 - k8s.io/cli-runtime v0.17.0 - k8s.io/client-go v0.17.0 + k8s.io/api v0.17.1 + k8s.io/apiextensions-apiserver v0.17.1 + k8s.io/apimachinery v0.17.1 + k8s.io/cli-runtime v0.17.1 + k8s.io/client-go v0.17.1 k8s.io/klog v1.0.0 - k8s.io/kubectl v0.17.0 + k8s.io/kubectl v0.17.1 sigs.k8s.io/yaml v1.1.0 ) diff --git a/go.sum b/go.sum index bbad3e1b7..312152e1f 100644 --- a/go.sum +++ b/go.sum @@ -667,21 +667,20 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM= -k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= -k8s.io/apiextensions-apiserver v0.17.0 h1:+XgcGxqaMztkbbvsORgCmHIb4uImHKvTjNyu7b8gRnA= -k8s.io/apiextensions-apiserver v0.17.0/go.mod h1:XiIFUakZywkUl54fVXa7QTEHcqQz9HG55nHd1DCoHj8= -k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apimachinery v0.17.1-beta.0 h1:0Wl/KpAiFOMe9to5h8x2Y6JnjV+BEWJiTcUk1Vx7zdE= -k8s.io/apimachinery v0.17.1-beta.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apiserver v0.17.0/go.mod h1:ABM+9x/prjINN6iiffRVNCBR2Wk7uY4z+EtEGZD48cg= -k8s.io/cli-runtime v0.17.0 h1:XEuStbJBHCQlEKFyTQmceDKEWOSYHZkcYWKp3SsQ9Hk= -k8s.io/cli-runtime v0.17.0/go.mod h1:1E5iQpMODZq2lMWLUJELwRu2MLWIzwvMgDBpn3Y81Qo= -k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg= -k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k= -k8s.io/code-generator v0.17.0/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= -k8s.io/component-base v0.17.0 h1:BnDFcmBDq+RPpxXjmuYnZXb59XNN9CaFrX8ba9+3xrA= -k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc= +k8s.io/api v0.17.1 h1:i46MidoDOE9tvQ0TTEYggf3ka/pziP1+tHI/GFVeJao= +k8s.io/api v0.17.1/go.mod h1:zxiAc5y8Ngn4fmhWUtSxuUlkfz1ixT7j9wESokELzOg= +k8s.io/apiextensions-apiserver v0.17.1 h1:Gw6zQgmKyyNrFMtVpRBNEKE8p35sDBI7Tq1ImxGS+zU= +k8s.io/apiextensions-apiserver v0.17.1/go.mod h1:DRIFH5x3jalE4rE7JP0MQKby9zdYk9lUJQuMmp+M/L0= +k8s.io/apimachinery v0.17.1 h1:zUjS3szTxoUjTDYNvdFkYt2uMEXLcthcbp+7uZvWhYM= +k8s.io/apimachinery v0.17.1/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= +k8s.io/apiserver v0.17.1/go.mod h1:BQEUObJv8H6ZYO7DeKI5vb50tjk6paRJ4ZhSyJsiSco= +k8s.io/cli-runtime v0.17.1 h1:VoZRWJNRyrxuM5SIRozYhT/EtcZ6jiS+KBCxRw66p1g= +k8s.io/cli-runtime v0.17.1/go.mod h1:e5847Iy85W9uWH3rZofXTG/9nOUyGKGTVnObYF7zSik= +k8s.io/client-go v0.17.1 h1:LbbuZ5tI7OYx4et5DfRFcJuoojvpYO0c7vps2rgJsHY= +k8s.io/client-go v0.17.1/go.mod h1:HZtHJSC/VuSHcETN9QA5QDZky1tXiYrkF/7t7vRpO1A= +k8s.io/code-generator v0.17.1/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= +k8s.io/component-base v0.17.1 h1:lK/lUzZZQK+DlH0XD+gq610OUEmjWOyDuUYOTGetw10= +k8s.io/component-base v0.17.1/go.mod h1:LrBPZkXtlvGjBzDJa0+b7E5Ij4VoAAKrOGudRC5z2eY= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20190822140433-26a664648505 h1:ZY6yclUKVbZ+SdWnkfY+Je5vrMpKOxmGeKRbsXVmqYM= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= @@ -691,9 +690,9 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kubectl v0.17.0 h1:xD4EWlL+epc/JTO1gvSjmV9yiYF0Z2wiHK2DIek6URY= -k8s.io/kubectl v0.17.0/go.mod h1:jIPrUAW656Vzn9wZCCe0PC+oTcu56u2HgFD21Xbfk1s= -k8s.io/metrics v0.17.0/go.mod h1:EH1D3YAwN6d7bMelrElnLhLg72l/ERStyv2SIQVt6Do= +k8s.io/kubectl v0.17.1 h1:+gI5hPZVEXN5wWybrzX3tu3f9af54sUNcALhg86upCY= +k8s.io/kubectl v0.17.1/go.mod h1:ZmbAdEQm+SLA/3s3eWJ3g+liXb5eT6mA85jYj52LMXw= +k8s.io/metrics v0.17.1/go.mod h1:dphDhzjA1KR/nQXtXEQzoQyQXk5ViSJO85Ky8QKwBPM= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= From 9240e7812464c1eb07c6a4b6c4459d5d3b1aef01 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 31 Dec 2019 08:42:12 -0500 Subject: [PATCH 170/279] feat(comp): Dynamic completion of arguments in Go Signed-off-by: Marc Khouzam --- cmd/helm/get_all.go | 9 ++ cmd/helm/get_hooks.go | 9 ++ cmd/helm/get_manifest.go | 9 ++ cmd/helm/get_notes.go | 9 ++ cmd/helm/get_values.go | 9 ++ cmd/helm/history.go | 9 ++ cmd/helm/install.go | 14 ++ cmd/helm/list.go | 24 ++++ cmd/helm/plugin_list.go | 15 ++ cmd/helm/plugin_uninstall.go | 11 ++ cmd/helm/plugin_update.go | 11 ++ cmd/helm/pull.go | 9 ++ cmd/helm/release_testing.go | 9 ++ cmd/helm/repo_list.go | 16 +++ cmd/helm/repo_remove.go | 10 ++ cmd/helm/rollback.go | 9 ++ cmd/helm/root.go | 247 ++++++-------------------------- cmd/helm/search_repo.go | 114 +++++++++++++++ cmd/helm/show.go | 12 ++ cmd/helm/status.go | 9 ++ cmd/helm/template.go | 6 + cmd/helm/uninstall.go | 9 ++ cmd/helm/upgrade.go | 12 ++ internal/completion/complete.go | 201 ++++++++++++++++++++++++++ 24 files changed, 589 insertions(+), 203 deletions(-) create mode 100644 internal/completion/complete.go diff --git a/cmd/helm/get_all.go b/cmd/helm/get_all.go index 8e9ab4d6b..678b85f25 100644 --- a/cmd/helm/get_all.go +++ b/cmd/helm/get_all.go @@ -22,6 +22,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" ) @@ -56,6 +57,14 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.IntVar(&client.Version, "revision", 0, "get the named release with revision") f.StringVar(&template, "template", "", "go template for formatting the output, eg: {{.Release.Name}}") diff --git a/cmd/helm/get_hooks.go b/cmd/helm/get_hooks.go index 0c50c8833..84ef0c1fc 100644 --- a/cmd/helm/get_hooks.go +++ b/cmd/helm/get_hooks.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -52,6 +53,14 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") return cmd diff --git a/cmd/helm/get_manifest.go b/cmd/helm/get_manifest.go index d8fcd2e2c..1860025cd 100644 --- a/cmd/helm/get_manifest.go +++ b/cmd/helm/get_manifest.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -52,6 +53,14 @@ func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") return cmd diff --git a/cmd/helm/get_notes.go b/cmd/helm/get_notes.go index 1b0128989..de3adf498 100644 --- a/cmd/helm/get_notes.go +++ b/cmd/helm/get_notes.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -50,6 +51,14 @@ func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.IntVar(&client.Version, "revision", 0, "get the named release with revision") diff --git a/cmd/helm/get_values.go b/cmd/helm/get_values.go index 2cccaeace..898db8929 100644 --- a/cmd/helm/get_values.go +++ b/cmd/helm/get_values.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" ) @@ -54,6 +55,14 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.IntVar(&client.Version, "revision", 0, "get the named release with revision") f.BoolVarP(&client.AllValues, "all", "a", false, "dump all (computed) values") diff --git a/cmd/helm/history.go b/cmd/helm/history.go index aa873db1e..739848c1c 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/cli/output" @@ -69,6 +70,14 @@ func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.IntVar(&client.Max, "max", 256, "maximum number of revision to include in history") bindOutputFlag(cmd, &outfmt) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index b75dfce74..701048151 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/pflag" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" @@ -122,6 +123,11 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + return compInstall(args, toComplete) + }) + addInstallFlags(cmd.Flags(), client, valueOpts) bindOutputFlag(cmd, &outfmt) @@ -225,3 +231,11 @@ func isChartInstallable(ch *chart.Chart) (bool, error) { } return false, errors.Errorf("%s charts are not installable", ch.Metadata.Type) } + +// Provide dynamic auto-completion for the install and template commands +func compInstall(args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListCharts(toComplete, true) + } + return nil, completion.BashCompDirectiveNoFileComp +} diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 57fc4be3c..4b652088d 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" "helm.sh/helm/v3/pkg/release" @@ -164,3 +165,26 @@ func (r *releaseListWriter) WriteJSON(out io.Writer) error { func (r *releaseListWriter) WriteYAML(out io.Writer) error { return output.EncodeYAML(out, r.releases) } + +// Provide dynamic auto-completion for release names +func compListReleases(toComplete string, cfg *action.Configuration) ([]string, completion.BashCompDirective) { + completion.CompDebugln(fmt.Sprintf("compListReleases with toComplete %s", toComplete)) + + client := action.NewList(cfg) + client.All = true + client.Limit = 0 + client.Filter = fmt.Sprintf("^%s", toComplete) + + client.SetStateMask() + results, err := client.Run() + if err != nil { + return nil, completion.BashCompDirectiveDefault + } + + var choices []string + for _, res := range results { + choices = append(choices, res.Name) + } + + return choices, completion.BashCompDirectiveNoFileComp +} diff --git a/cmd/helm/plugin_list.go b/cmd/helm/plugin_list.go index 2f37a8028..0440b0b5e 100644 --- a/cmd/helm/plugin_list.go +++ b/cmd/helm/plugin_list.go @@ -18,6 +18,7 @@ package main import ( "fmt" "io" + "strings" "github.com/gosuri/uitable" "github.com/spf13/cobra" @@ -46,3 +47,17 @@ func newPluginListCmd(out io.Writer) *cobra.Command { } return cmd } + +// Provide dynamic auto-completion for plugin names +func compListPlugins(toComplete string) []string { + var pNames []string + plugins, err := findPlugins(settings.PluginsDirectory) + if err == nil { + for _, p := range plugins { + if strings.HasPrefix(p.Metadata.Name, toComplete) { + pNames = append(pNames, p.Metadata.Name) + } + } + } + return pNames +} diff --git a/cmd/helm/plugin_uninstall.go b/cmd/helm/plugin_uninstall.go index 30f9bc91d..f703ddcfb 100644 --- a/cmd/helm/plugin_uninstall.go +++ b/cmd/helm/plugin_uninstall.go @@ -24,6 +24,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/plugin" ) @@ -33,6 +34,7 @@ type pluginUninstallOptions struct { func newPluginUninstallCmd(out io.Writer) *cobra.Command { o := &pluginUninstallOptions{} + cmd := &cobra.Command{ Use: "uninstall ...", Aliases: []string{"rm", "remove"}, @@ -44,6 +46,15 @@ func newPluginUninstallCmd(out io.Writer) *cobra.Command { return o.run(out) }, } + + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListPlugins(toComplete), completion.BashCompDirectiveNoFileComp + }) + return cmd } diff --git a/cmd/helm/plugin_update.go b/cmd/helm/plugin_update.go index 64e8bd6c7..a24e80518 100644 --- a/cmd/helm/plugin_update.go +++ b/cmd/helm/plugin_update.go @@ -24,6 +24,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/plugin" "helm.sh/helm/v3/pkg/plugin/installer" ) @@ -34,6 +35,7 @@ type pluginUpdateOptions struct { func newPluginUpdateCmd(out io.Writer) *cobra.Command { o := &pluginUpdateOptions{} + cmd := &cobra.Command{ Use: "update ...", Aliases: []string{"up"}, @@ -45,6 +47,15 @@ func newPluginUpdateCmd(out io.Writer) *cobra.Command { return o.run(out) }, } + + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListPlugins(toComplete), completion.BashCompDirectiveNoFileComp + }) + return cmd } diff --git a/cmd/helm/pull.go b/cmd/helm/pull.go index 3b00e9bca..16cd10467 100644 --- a/cmd/helm/pull.go +++ b/cmd/helm/pull.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -68,6 +69,14 @@ func newPullCmd(out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListCharts(toComplete, false) + }) + f := cmd.Flags() f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") f.BoolVar(&client.Untar, "untar", false, "if set to true, will untar the chart after downloading it") diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go index 7190ec736..e4690b9d4 100644 --- a/cmd/helm/release_testing.go +++ b/cmd/helm/release_testing.go @@ -24,6 +24,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" ) @@ -71,6 +72,14 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&outputLogs, "logs", false, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)") diff --git a/cmd/helm/repo_list.go b/cmd/helm/repo_list.go index 2ff6162d1..25316bafc 100644 --- a/cmd/helm/repo_list.go +++ b/cmd/helm/repo_list.go @@ -18,6 +18,7 @@ package main import ( "io" + "strings" "github.com/gosuri/uitable" "github.com/pkg/errors" @@ -95,3 +96,18 @@ func (r *repoListWriter) encodeByFormat(out io.Writer, format output.Format) err // WriteJSON and WriteYAML, we shouldn't get invalid types return nil } + +// Provide dynamic auto-completion for repo names +func compListRepos(prefix string) []string { + var rNames []string + + f, err := repo.LoadFile(settings.RepositoryConfig) + if err == nil && len(f.Repositories) > 0 { + for _, repo := range f.Repositories { + if strings.HasPrefix(repo.Name, prefix) { + rNames = append(rNames, repo.Name) + } + } + } + return rNames +} diff --git a/cmd/helm/repo_remove.go b/cmd/helm/repo_remove.go index ea7a5db24..e8c0ec027 100644 --- a/cmd/helm/repo_remove.go +++ b/cmd/helm/repo_remove.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/helmpath" "helm.sh/helm/v3/pkg/repo" ) @@ -38,6 +39,7 @@ type repoRemoveOptions struct { func newRepoRemoveCmd(out io.Writer) *cobra.Command { o := &repoRemoveOptions{} + cmd := &cobra.Command{ Use: "remove [NAME]", Aliases: []string{"rm"}, @@ -51,6 +53,14 @@ func newRepoRemoveCmd(out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListRepos(toComplete), completion.BashCompDirectiveNoFileComp + }) + return cmd } diff --git a/cmd/helm/rollback.go b/cmd/helm/rollback.go index d44ef14f4..745e910b2 100644 --- a/cmd/helm/rollback.go +++ b/cmd/helm/rollback.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -64,6 +65,14 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.BoolVar(&client.DryRun, "dry-run", false, "simulate a rollback") f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") diff --git a/cmd/helm/root.go b/cmd/helm/root.go index bba3ff643..e02723a6f 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -24,6 +24,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/internal/experimental/registry" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" @@ -67,11 +68,6 @@ __helm_override_flags_to_kubectl_flags() echo "$1" | \sed s/kube-context/context/ } -__helm_get_repos() -{ - eval $(__helm_binary_name) repo list 2>/dev/null | \tail -n +2 | \cut -f1 -} - __helm_get_contexts() { __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" @@ -103,209 +99,45 @@ __helm_output_options() COMPREPLY+=( $( compgen -W "%[1]s" -- "$cur" ) ) } -__helm_binary_name() +__helm_custom_func() { - local helm_binary - helm_binary="${words[0]}" - __helm_debug "${FUNCNAME[0]}: helm_binary is ${helm_binary}" - echo ${helm_binary} -} - -# This function prevents the zsh shell from adding a space after -# a completion by adding a second, fake completion -__helm_zsh_comp_nospace() { - __helm_debug "${FUNCNAME[0]}: in is ${in[*]}" + __helm_debug "${FUNCNAME[0]}: c is $c, words[@] is ${words[@]}, #words[@] is ${#words[@]}" + __helm_debug "${FUNCNAME[0]}: cur is ${cur}, cword is ${cword}, words is ${words}" - local out in=("$@") + local out requestComp + requestComp="${words[0]} %[2]s ${words[@]:1}" - # The shell will normally add a space after these completions. - # To avoid that we should use "compopt -o nospace". However, it is not - # available in zsh. - # Instead, we trick the shell by pretending there is a second, longer match. - # We only do this if there is a single choice left for completion - # to reduce the times the user could be presented with the fake completion choice. - - out=($(echo ${in[*]} | \tr " " "\n" | \grep "^${cur}")) - __helm_debug "${FUNCNAME[0]}: out is ${out[*]}" - - [ ${#out[*]} -eq 1 ] && out+=("${out}.") - - __helm_debug "${FUNCNAME[0]}: out is now ${out[*]}" - - echo "${out[*]}" -} + if [ -z "${cur}" ]; then + # If the last parameter is complete (there is a space following it) + # We add an extra empty parameter so we can indicate this to the go method. + __helm_debug "${FUNCNAME[0]}: Adding extra empty parameter" + requestComp="${requestComp} \"\"" + fi -# $1 = 1 if the completion should include local charts (which means file completion) -__helm_list_charts() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local prefix chart repo url file out=() nospace=0 wantFiles=$1 - - # Handle completions for repos - for repo in $(__helm_get_repos); do - if [[ "${cur}" =~ ^${repo}/.* ]]; then - # We are doing completion from within a repo - local cacheFile=$(eval $(__helm_binary_name) env 2>/dev/null | \grep HELM_REPOSITORY_CACHE | \cut -d= -f2 | \sed s/\"//g)/${repo}-charts.txt - if [ -f "$cacheFile" ]; then - # Get the list of charts from the cached file - prefix=${cur#${repo}/} - for chart in $(\grep ^$prefix $cacheFile); do - out+=(${repo}/${chart}) - done - else - # If there is no cached list file, fallback to helm search, which is much slower - # This will happen after the caching feature is first installed but before the user - # does a 'helm repo update' to generate the cached list file. - out=$(eval $(__helm_binary_name) search repo ${cur} 2>/dev/null | \cut -f1 | \grep ^${cur}) + __helm_debug "${FUNCNAME[0]}: calling ${requestComp}" + # Use eval to handle any environment variables and such + out=$(eval ${requestComp} 2>/dev/null) + directive=$? + + if [ $((${directive} & %[3]d)) -ne 0 ]; then + __helm_debug "${FUNCNAME[0]}: received error, completion failed" + else + if [ $((${directive} & %[4]d)) -ne 0 ]; then + if [[ $(type -t compopt) = "builtin" ]]; then + compopt -o nospace fi - nospace=0 - elif [[ ${repo} =~ ^${cur}.* ]]; then - # We are completing a repo name - out+=(${repo}/) - nospace=1 - fi - done - __helm_debug "${FUNCNAME[0]}: out after repos is ${out[*]}" - - # Handle completions for url prefixes - for url in https:// http:// file://; do - if [[ "${cur}" =~ ^${url}.* ]]; then - # The user already put in the full url prefix. Return it - # back as a completion to avoid the shell doing path completion - out="${cur}" - nospace=1 - elif [[ ${url} =~ ^${cur}.* ]]; then - # We are completing a url prefix - out+=(${url}) - nospace=1 fi - done - __helm_debug "${FUNCNAME[0]}: out after urls is ${out[*]}" - - # Handle completion for files. - # We only do this if: - # 1- There are other completions found (if there are no completions, - # the shell will do file completion itself) - # 2- If there is some input from the user (or else we will end up - # listing the entire content of the current directory which will - # be too many choices for the user to find the real repos) - if [ $wantFiles -eq 1 ] && [ -n "${out[*]}" ] && [ -n "${cur}" ]; then - for file in $(\ls); do - if [[ ${file} =~ ^${cur}.* ]]; then - # We are completing a file prefix - out+=(${file}) - nospace=1 + if [ $((${directive} & %[5]d)) -ne 0 ]; then + if [[ $(type -t compopt) = "builtin" ]]; then + compopt +o default fi - done - fi - __helm_debug "${FUNCNAME[0]}: out after files is ${out[*]}" - - # If the user didn't provide any input to completion, - # we provide a hint that a path can also be used - [ $wantFiles -eq 1 ] && [ -z "${cur}" ] && out+=(./ /) - - __helm_debug "${FUNCNAME[0]}: out after checking empty input is ${out[*]}" - - if [ $nospace -eq 1 ]; then - if [[ -n "${ZSH_VERSION}" ]]; then - # Don't let the shell add a space after the completion - local tmpout=$(__helm_zsh_comp_nospace "${out[@]}") - unset out - out=$tmpout - elif [[ $(type -t compopt) = "builtin" ]]; then - compopt -o nospace fi - fi - - __helm_debug "${FUNCNAME[0]}: final out is ${out[*]}" - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) -} -__helm_list_releases() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local out filter - # Use ^ to map from the start of the release name - filter="^${words[c]}" - # Use eval in case helm_binary_name or __helm_override_flags contains a variable (e.g., $HOME/bin/h3) - if out=$(eval $(__helm_binary_name) list $(__helm_override_flags) -a -q -m 1000 -f ${filter} 2>/dev/null); then - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) + while IFS='' read -r comp; do + COMPREPLY+=("$comp") + done < <(compgen -W "${out[*]}" -- "$cur") fi } - -__helm_list_repos() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local out - # Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3) - if out=$(__helm_get_repos); then - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) - fi -} - -__helm_list_plugins() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local out - # Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3) - if out=$(eval $(__helm_binary_name) plugin list 2>/dev/null | \tail -n +2 | \cut -f1); then - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) - fi -} - -__helm_list_charts_after_name() { - __helm_debug "${FUNCNAME[0]}: last_command is $last_command" - if [[ ${#nouns[@]} -eq 1 ]]; then - __helm_list_charts 1 - fi -} - -__helm_list_releases_then_charts() { - __helm_debug "${FUNCNAME[0]}: last_command is $last_command" - if [[ ${#nouns[@]} -eq 0 ]]; then - __helm_list_releases - elif [[ ${#nouns[@]} -eq 1 ]]; then - __helm_list_charts 1 - fi -} - -__helm_custom_func() -{ - __helm_debug "${FUNCNAME[0]}: last_command is $last_command" - case ${last_command} in - helm_pull) - __helm_list_charts 0 - return - ;; - helm_show_*) - __helm_list_charts 1 - return - ;; - helm_install | helm_template) - __helm_list_charts_after_name - return - ;; - helm_upgrade) - __helm_list_releases_then_charts - return - ;; - helm_uninstall | helm_history | helm_status | helm_test |\ - helm_rollback | helm_get_*) - __helm_list_releases - return - ;; - helm_repo_remove) - __helm_list_repos - return - ;; - helm_plugin_uninstall | helm_plugin_update) - __helm_list_plugins - return - ;; - *) - ;; - esac -} ` ) @@ -359,12 +191,18 @@ By default, the default directories depend on the Operating System. The defaults func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command { cmd := &cobra.Command{ - Use: "helm", - Short: "The Helm package manager for Kubernetes.", - Long: globalUsage, - SilenceUsage: true, - Args: require.NoArgs, - BashCompletionFunction: fmt.Sprintf(bashCompletionFunc, strings.Join(output.Formats(), " ")), + Use: "helm", + Short: "The Helm package manager for Kubernetes.", + Long: globalUsage, + SilenceUsage: true, + Args: require.NoArgs, + BashCompletionFunction: fmt.Sprintf( + bashCompletionFunc, + strings.Join(output.Formats(), " "), + completion.CompRequestCmd, + completion.BashCompDirectiveError, + completion.BashCompDirectiveNoSpace, + completion.BashCompDirectiveNoFileComp), } flags := cmd.PersistentFlags() @@ -409,6 +247,9 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string // Hidden documentation generator command: 'helm docs' newDocsCmd(out), + + // Setup the special hidden __complete command to allow for dynamic auto-completion + completion.NewCompleteCmd(settings), ) // Add annotation to flags for which we can generate completion choices diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index 063a72a27..a57ad135b 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -19,6 +19,7 @@ package main import ( "fmt" "io" + "io/ioutil" "path/filepath" "strings" @@ -28,6 +29,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/search" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/cli/output" "helm.sh/helm/v3/pkg/helmpath" "helm.sh/helm/v3/pkg/repo" @@ -246,3 +248,115 @@ func (r *repoSearchWriter) encodeByFormat(out io.Writer, format output.Format) e // WriteJSON and WriteYAML, we shouldn't get invalid types return nil } + +// Provides the list of charts that are part of the specified repo, and that starts with 'prefix'. +func compListChartsOfRepo(repoName string, prefix string) []string { + f := filepath.Join(settings.RepositoryCache, helmpath.CacheIndexFile(repoName)) + var charts []string + if indexFile, err := repo.LoadIndexFile(f); err == nil { + for name := range indexFile.Entries { + fullName := fmt.Sprintf("%s/%s", repoName, name) + if strings.HasPrefix(fullName, prefix) { + charts = append(charts, fullName) + } + } + } + return charts +} + +// Provide dynamic auto-completion for commands that operate on charts (e.g., helm show) +// When true, the includeFiles argument indicates that completion should include local files (e.g., local charts) +func compListCharts(toComplete string, includeFiles bool) ([]string, completion.BashCompDirective) { + completion.CompDebugln(fmt.Sprintf("compListCharts with toComplete %s", toComplete)) + + noSpace := false + noFile := false + var completions []string + + // First check completions for repos + repos := compListRepos("") + for _, repo := range repos { + repoWithSlash := fmt.Sprintf("%s/", repo) + if strings.HasPrefix(toComplete, repoWithSlash) { + // Must complete with charts within the specified repo + completions = append(completions, compListChartsOfRepo(repo, toComplete)...) + noSpace = false + break + } else if strings.HasPrefix(repo, toComplete) { + // Must complete the repo name + completions = append(completions, repoWithSlash) + noSpace = true + } + } + completion.CompDebugln(fmt.Sprintf("Completions after repos: %v", completions)) + + // Now handle completions for url prefixes + for _, url := range []string{"https://", "http://", "file://"} { + if strings.HasPrefix(toComplete, url) { + // The user already put in the full url prefix; we don't have + // anything to add, but make sure the shell does not default + // to file completion since we could be returning an empty array. + noFile = true + noSpace = true + } else if strings.HasPrefix(url, toComplete) { + // We are completing a url prefix + completions = append(completions, url) + noSpace = true + } + } + completion.CompDebugln(fmt.Sprintf("Completions after urls: %v", completions)) + + // Finally, provide file completion if we need to. + // We only do this if: + // 1- There are other completions found (if there are no completions, + // the shell will do file completion itself) + // 2- If there is some input from the user (or else we will end up + // listing the entire content of the current directory which will + // be too many choices for the user to find the real repos) + if includeFiles && len(completions) > 0 && len(toComplete) > 0 { + if files, err := ioutil.ReadDir("."); err == nil { + for _, file := range files { + if strings.HasPrefix(file.Name(), toComplete) { + // We are completing a file prefix + completions = append(completions, file.Name()) + } + } + } + } + completion.CompDebugln(fmt.Sprintf("Completions after files: %v", completions)) + + // If the user didn't provide any input to completion, + // we provide a hint that a path can also be used + if includeFiles && len(toComplete) == 0 { + completions = append(completions, "./", "/") + } + completion.CompDebugln(fmt.Sprintf("Completions after checking empty input: %v", completions)) + + directive := completion.BashCompDirectiveDefault + if noFile { + directive = directive | completion.BashCompDirectiveNoFileComp + } + if noSpace { + directive = directive | completion.BashCompDirectiveNoSpace + // The completion.BashCompDirective flags do not work for zsh right now. + // We handle it ourselves instead. + completions = compEnforceNoSpace(completions) + } + return completions, directive +} + +// This function prevents the shell from adding a space after +// a completion by adding a second, fake completion. +// It is only needed for zsh, but we cannot tell which shell +// is being used here, so we do the fake completion all the time; +// there are no real downsides to doing this for bash as well. +func compEnforceNoSpace(completions []string) []string { + // To prevent the shell from adding space after the completion, + // we trick it by pretending there is a second, longer match. + // We only do this if there is a single choice for completion. + if len(completions) == 1 { + completions = append(completions, completions[0]+".") + completion.CompDebugln(fmt.Sprintf("compEnforceNoSpace: completions now are %v", completions)) + } + return completions +} diff --git a/cmd/helm/show.go b/cmd/helm/show.go index e9e9cca8b..a82ad2777 100644 --- a/cmd/helm/show.go +++ b/cmd/helm/show.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -61,6 +62,14 @@ func newShowCmd(out io.Writer) *cobra.Command { Args: require.NoArgs, } + // Function providing dynamic auto-completion + validArgsFunc := func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListCharts(toComplete, true) + } + all := &cobra.Command{ Use: "all [CHART]", Short: "shows all information of the chart", @@ -145,6 +154,9 @@ func newShowCmd(out io.Writer) *cobra.Command { for _, subCmd := range cmds { addChartPathOptionsFlags(subCmd.Flags(), &client.ChartPathOptions) showCommand.AddCommand(subCmd) + + // Register the completion function for each subcommand + completion.RegisterValidArgsFunc(subCmd, validArgsFunc) } return showCommand diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 92a947c26..8f172f66a 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/cli/output" @@ -65,6 +66,14 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.PersistentFlags() f.IntVar(&client.Version, "revision", 0, "if set, display the status of the named release with revision") bindOutputFlag(cmd, &outfmt) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index a47631c0d..fbd6f57e2 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -29,6 +29,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/cli/values" @@ -123,6 +124,11 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + return compInstall(args, toComplete) + }) + f := cmd.Flags() addInstallFlags(f, client, valueOpts) f.StringArrayVarP(&showFiles, "show-only", "s", []string{}, "only show manifests rendered from the given templates") diff --git a/cmd/helm/uninstall.go b/cmd/helm/uninstall.go index 7096d7873..85fa822bd 100644 --- a/cmd/helm/uninstall.go +++ b/cmd/helm/uninstall.go @@ -24,6 +24,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" ) @@ -64,6 +65,14 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) != 0 { + return nil, completion.BashCompDirectiveNoFileComp + } + return compListReleases(toComplete, cfg) + }) + f := cmd.Flags() f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index acfc23198..6c967b796 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -25,6 +25,7 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart/loader" "helm.sh/helm/v3/pkg/cli/output" @@ -144,6 +145,17 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } + // Function providing dynamic auto-completion + completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 0 { + return compListReleases(toComplete, cfg) + } + if len(args) == 1 { + return compListCharts(toComplete, true) + } + return nil, completion.BashCompDirectiveNoFileComp + }) + f := cmd.Flags() f.BoolVarP(&client.Install, "install", "i", false, "if a release by this name doesn't already exist, run an install") f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") diff --git a/internal/completion/complete.go b/internal/completion/complete.go new file mode 100644 index 000000000..435fdcc23 --- /dev/null +++ b/internal/completion/complete.go @@ -0,0 +1,201 @@ +/* +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 + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package completion + +import ( + "fmt" + "log" + "os" + "strings" + + "github.com/spf13/cobra" + + "helm.sh/helm/v3/cmd/helm/require" + "helm.sh/helm/v3/pkg/cli" +) + +// ================================================================================== +// The below code supports dynamic shell completion in Go. +// This should ultimately be pushed down into Cobra. +// ================================================================================== + +// CompRequestCmd Hidden command to request completion results from the program. +// Used by the shell completion script. +const CompRequestCmd = "__complete" + +// Global map allowing to find completion functions for commands. +var validArgsFunctions = map[*cobra.Command]func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective){} + +// BashCompDirective is a bit map representing the different behaviors the shell +// can be instructed to have once completions have been provided. +type BashCompDirective int + +const ( + // BashCompDirectiveError indicates an error occurred and completions should be ignored. + BashCompDirectiveError BashCompDirective = 1 << iota + + // BashCompDirectiveNoSpace indicates that the shell should not add a space + // after the completion even if there is a single completion provided. + BashCompDirectiveNoSpace + + // BashCompDirectiveNoFileComp indicates that the shell should not provide + // file completion even when no completion is provided. + // This currently does not work for zsh or bash < 4 + BashCompDirectiveNoFileComp + + // BashCompDirectiveDefault indicates to let the shell perform its default + // behavior after completions have been provided. + BashCompDirectiveDefault BashCompDirective = 0 +) + +// RegisterValidArgsFunc should be called to register a function to provide argument completion for a command +func RegisterValidArgsFunc(cmd *cobra.Command, f func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective)) { + if _, exists := validArgsFunctions[cmd]; exists { + log.Fatal(fmt.Sprintf("RegisterValidArgsFunc: command '%s' already registered", cmd.Name())) + } + validArgsFunctions[cmd] = f +} + +var debug = true + +// Returns a string listing the different directive enabled in the specified parameter +func (d BashCompDirective) string() string { + var directives []string + if d&BashCompDirectiveError != 0 { + directives = append(directives, "BashCompDirectiveError") + } + if d&BashCompDirectiveNoSpace != 0 { + directives = append(directives, "BashCompDirectiveNoSpace") + } + if d&BashCompDirectiveNoFileComp != 0 { + directives = append(directives, "BashCompDirectiveNoFileComp") + } + if len(directives) == 0 { + directives = append(directives, "BashCompDirectiveDefault") + } + + if d > BashCompDirectiveError+BashCompDirectiveNoSpace+BashCompDirectiveNoFileComp { + return fmt.Sprintf("ERROR: unexpected BashCompDirective value: %d", d) + } + return strings.Join(directives, ", ") +} + +// NewCompleteCmd add a special hidden command that an be used to request completions +func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { + debug = settings.Debug + return &cobra.Command{ + Use: fmt.Sprintf("%s [command-line]", CompRequestCmd), + DisableFlagsInUseLine: true, + Hidden: true, + DisableFlagParsing: true, + Args: require.MinimumNArgs(2), + Short: "Request shell completion choices for the specified command-line", + Long: fmt.Sprintf("%s is a special command that is used by the shell completion logic\n%s", + CompRequestCmd, "to request completion choices for the specified command-line."), + Run: func(cmd *cobra.Command, args []string) { + CompDebugln(fmt.Sprintf("%s was called with args %v", cmd.Name(), args)) + + trimmedArgs := args[:len(args)-1] + toComplete := args[len(args)-1] + + // Find the real command for which completion must be performed + finalCmd, finalArgs, err := cmd.Root().Find(trimmedArgs) + if err != nil { + // Unable to find the real command. E.g., helm invalidCmd + os.Exit(int(BashCompDirectiveError)) + } + + CompDebugln(fmt.Sprintf("Found final command '%s', with finalArgs %v", finalCmd.Name(), finalArgs)) + + // Parse the flags and extract the arguments to prepare for calling the completion function + if err = finalCmd.ParseFlags(finalArgs); err != nil { + CompErrorln(fmt.Sprintf("Error while parsing flags from args %v: %s", finalArgs, err.Error())) + return + } + argsWoFlags := finalCmd.Flags().Args() + CompDebugln(fmt.Sprintf("Args without flags are '%v' with length %d", argsWoFlags, len(argsWoFlags))) + + // Find completion function for the command + completionFn, ok := validArgsFunctions[finalCmd] + if !ok { + CompErrorln(fmt.Sprintf("Dynamic completion not supported/needed for flag or command: %s", finalCmd.Name())) + return + } + + CompDebugln(fmt.Sprintf("Calling completion method for subcommand '%s' with args '%v' and toComplete '%s'", finalCmd.Name(), argsWoFlags, toComplete)) + completions, directive := completionFn(finalCmd, argsWoFlags, toComplete) + for _, comp := range completions { + // Print each possible completion to stdout for the completion script to consume. + fmt.Println(comp) + } + + // Print some helpful info to stderr for the user to see. + // Output from stderr should be ignored from the completion script. + fmt.Fprintf(os.Stderr, "Completion ended with directive: %s\n", directive.string()) + os.Exit(int(directive)) + }, + } +} + +// CompDebug prints the specified string to the same file as where the +// completion script prints its logs. +// Note that completion printouts should never be on stdout as they would +// be wrongly interpreted as actual completion choices by the completion script. +func CompDebug(msg string) { + msg = fmt.Sprintf("[Debug] %s", msg) + + // Such logs are only printed when the user has set the environment + // variable BASH_COMP_DEBUG_FILE to the path of some file to be used. + if path := os.Getenv("BASH_COMP_DEBUG_FILE"); path != "" { + f, err := os.OpenFile(path, + os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err == nil { + defer f.Close() + f.WriteString(msg) + } + } + + if debug { + // Must print to stderr for this not to be read by the completion script. + fmt.Fprintf(os.Stderr, msg) + } +} + +// CompDebugln prints the specified string with a newline at the end +// to the same file as where the completion script prints its logs. +// Such logs are only printed when the user has set the environment +// variable BASH_COMP_DEBUG_FILE to the path of some file to be used. +func CompDebugln(msg string) { + CompDebug(fmt.Sprintf("%s\n", msg)) +} + +// CompError prints the specified completion message to stderr. +func CompError(msg string) { + msg = fmt.Sprintf("[Error] %s", msg) + + CompDebug(msg) + + // If not already printed by the call to CompDebug(). + if !debug { + // Must print to stderr for this not to be read by the completion script. + fmt.Fprintf(os.Stderr, msg) + } +} + +// CompErrorln prints the specified completion message to stderr with a newline at the end. +func CompErrorln(msg string) { + CompError(fmt.Sprintf("%s\n", msg)) +} From 62c9c34d493a63f80c06337c60871858df60ea3a Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 31 Dec 2019 08:54:20 -0500 Subject: [PATCH 171/279] feat(comp): Dynamic completion of flags in Go Conflicts: cmd/helm/completion/complete.go cmd/helm/root.go Conflicts: cmd/helm/root.go Signed-off-by: Marc Khouzam --- cmd/helm/flags.go | 17 ++++- cmd/helm/root.go | 103 +++++++++---------------- internal/completion/complete.go | 131 ++++++++++++++++++++++++++++++-- 3 files changed, 174 insertions(+), 77 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index aa22603f4..b9473a5a7 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" "helm.sh/helm/v3/pkg/cli/values" @@ -52,10 +53,20 @@ func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) { // bindOutputFlag will add the output flag to the given command and bind the // value to the given format pointer func bindOutputFlag(cmd *cobra.Command, varRef *output.Format) { - cmd.Flags().VarP(newOutputValue(output.Table, varRef), outputFlag, "o", + f := cmd.Flags() + f.VarP(newOutputValue(output.Table, varRef), outputFlag, "o", fmt.Sprintf("prints the output in the specified format. Allowed values: %s", strings.Join(output.Formats(), ", "))) - // Setup shell completion for the flag - cmd.MarkFlagCustom(outputFlag, "__helm_output_options") + + flag := f.Lookup(outputFlag) + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + var formatNames []string + for _, format := range output.Formats() { + if strings.HasPrefix(format, toComplete) { + formatNames = append(formatNames, format) + } + } + return formatNames, completion.BashCompDirectiveDefault + }) } type outputValue output.Format diff --git a/cmd/helm/root.go b/cmd/helm/root.go index e02723a6f..ab7b01c90 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -23,51 +23,16 @@ import ( "github.com/spf13/cobra" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/internal/experimental/registry" "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/cli/output" ) const ( bashCompletionFunc = ` -__helm_override_flag_list=(--kubeconfig --kube-context --namespace -n) -__helm_override_flags() -{ - local ${__helm_override_flag_list[*]##*-} two_word_of of var - for w in "${words[@]}"; do - if [ -n "${two_word_of}" ]; then - eval "${two_word_of##*-}=\"${two_word_of}=\${w}\"" - two_word_of= - continue - fi - for of in "${__helm_override_flag_list[@]}"; do - case "${w}" in - ${of}=*) - eval "${of##*-}=\"${w}\"" - ;; - ${of}) - two_word_of="${of}" - ;; - esac - done - done - for var in "${__helm_override_flag_list[@]##*-}"; do - if eval "test -n \"\$${var}\""; then - eval "echo \${${var}}" - fi - done -} - -__helm_override_flags_to_kubectl_flags() -{ - # --kubeconfig, -n, --namespace stay the same for kubectl - # --kube-context becomes --context for kubectl - __helm_debug "${FUNCNAME[0]}: flags to convert: $1" - echo "$1" | \sed s/kube-context/context/ -} - __helm_get_contexts() { __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" @@ -78,36 +43,19 @@ __helm_get_contexts() fi } -__helm_get_namespaces() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local template out - template="{{ range .items }}{{ .metadata.name }} {{ end }}" - - flags=$(__helm_override_flags_to_kubectl_flags "$(__helm_override_flags)") - __helm_debug "${FUNCNAME[0]}: override flags for kubectl are: $flags" - - # Must use eval in case the flags contain a variable such as $HOME - if out=$(eval kubectl get ${flags} -o template --template=\"${template}\" namespace 2>/dev/null); then - COMPREPLY+=( $( compgen -W "${out[*]}" -- "$cur" ) ) - fi -} - -__helm_output_options() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - COMPREPLY+=( $( compgen -W "%[1]s" -- "$cur" ) ) -} - __helm_custom_func() { __helm_debug "${FUNCNAME[0]}: c is $c, words[@] is ${words[@]}, #words[@] is ${#words[@]}" __helm_debug "${FUNCNAME[0]}: cur is ${cur}, cword is ${cword}, words is ${words}" - local out requestComp - requestComp="${words[0]} %[2]s ${words[@]:1}" + local out requestComp lastParam lastChar + requestComp="${words[0]} %[1]s ${words[@]:1}" - if [ -z "${cur}" ]; then + lastParam=${words[$((${#words[@]}-1))]} + lastChar=${lastParam:$((${#lastParam}-1)):1} + __helm_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}" + + if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then # If the last parameter is complete (there is a space following it) # We add an extra empty parameter so we can indicate this to the go method. __helm_debug "${FUNCNAME[0]}: Adding extra empty parameter" @@ -119,15 +67,15 @@ __helm_custom_func() out=$(eval ${requestComp} 2>/dev/null) directive=$? - if [ $((${directive} & %[3]d)) -ne 0 ]; then + if [ $((${directive} & %[2]d)) -ne 0 ]; then __helm_debug "${FUNCNAME[0]}: received error, completion failed" else - if [ $((${directive} & %[4]d)) -ne 0 ]; then + if [ $((${directive} & %[3]d)) -ne 0 ]; then if [[ $(type -t compopt) = "builtin" ]]; then compopt -o nospace fi fi - if [ $((${directive} & %[5]d)) -ne 0 ]; then + if [ $((${directive} & %[4]d)) -ne 0 ]; then if [[ $(type -t compopt) = "builtin" ]]; then compopt +o default fi @@ -145,7 +93,8 @@ var ( // Mapping of global flags that can have dynamic completion and the // completion function to be used. bashCompletionFlags = map[string]string{ - "namespace": "__helm_get_namespaces", + // Cannot convert the kube-context flag to Go completion yet because + // an incomplete kube-context will make actionConfig.Init() fail at the very start "kube-context": "__helm_get_contexts", } ) @@ -198,7 +147,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Args: require.NoArgs, BashCompletionFunction: fmt.Sprintf( bashCompletionFunc, - strings.Join(output.Formats(), " "), completion.CompRequestCmd, completion.BashCompDirectiveError, completion.BashCompDirectiveNoSpace, @@ -208,6 +156,29 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string settings.AddFlags(flags) + flag := flags.Lookup("namespace") + // Setup shell completion for the namespace flag + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if client, err := actionConfig.KubernetesClientSet(); err == nil { + // Choose a long enough timeout that the user notices somethings is not working + // but short enough that the user is not made to wait very long + to := int64(3) + completion.CompDebugln(fmt.Sprintf("About to call kube client for namespaces with timeout of: %d", to)) + + nsNames := []string{} + // TODO can we request only the namespace with request.prefix? + if namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{TimeoutSeconds: &to}); err == nil { + for _, ns := range namespaces.Items { + if strings.HasPrefix(ns.Name, toComplete) { + nsNames = append(nsNames, ns.Name) + } + } + return nsNames, completion.BashCompDirectiveNoFileComp + } + } + return nil, completion.BashCompDirectiveDefault + }) + // We can safely ignore any errors that flags.Parse encounters since // those errors will be caught later during the call to cmd.Execution. // This call is required to gather configuration information prior to diff --git a/internal/completion/complete.go b/internal/completion/complete.go index 435fdcc23..c0fabda1b 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/spf13/cobra" + "github.com/spf13/pflag" "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/pkg/cli" @@ -36,8 +37,8 @@ import ( // Used by the shell completion script. const CompRequestCmd = "__complete" -// Global map allowing to find completion functions for commands. -var validArgsFunctions = map[*cobra.Command]func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective){} +// Global map allowing to find completion functions for commands or flags. +var validArgsFunctions = map[interface{}]func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective){} // BashCompDirective is a bit map representing the different behaviors the shell // can be instructed to have once completions have been provided. @@ -69,6 +70,21 @@ func RegisterValidArgsFunc(cmd *cobra.Command, f func(cmd *cobra.Command, args [ validArgsFunctions[cmd] = f } +// RegisterFlagCompletionFunc should be called to register a function to provide completion for a flag +func RegisterFlagCompletionFunc(flag *pflag.Flag, f func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective)) { + if _, exists := validArgsFunctions[flag]; exists { + log.Fatal(fmt.Sprintf("RegisterFlagCompletionFunc: flag '%s' already registered", flag.Name)) + } + validArgsFunctions[flag] = f + + // Make sure the completion script call the __helm_custom_func for the registered flag. + // This is essential to make the = form work. E.g., helm -n= or helm status --output= + if flag.Annotations == nil { + flag.Annotations = map[string][]string{} + } + flag.Annotations[cobra.BashCompCustom] = []string{"__helm_custom_func"} +} + var debug = true // Returns a string listing the different directive enabled in the specified parameter @@ -101,15 +117,14 @@ func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { DisableFlagsInUseLine: true, Hidden: true, DisableFlagParsing: true, - Args: require.MinimumNArgs(2), + Args: require.MinimumNArgs(1), Short: "Request shell completion choices for the specified command-line", Long: fmt.Sprintf("%s is a special command that is used by the shell completion logic\n%s", CompRequestCmd, "to request completion choices for the specified command-line."), Run: func(cmd *cobra.Command, args []string) { CompDebugln(fmt.Sprintf("%s was called with args %v", cmd.Name(), args)) - trimmedArgs := args[:len(args)-1] - toComplete := args[len(args)-1] + flag, trimmedArgs, toComplete := checkIfFlagCompletion(cmd.Root(), args[:len(args)-1], args[len(args)-1]) // Find the real command for which completion must be performed finalCmd, finalArgs, err := cmd.Root().Find(trimmedArgs) @@ -128,10 +143,20 @@ func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { argsWoFlags := finalCmd.Flags().Args() CompDebugln(fmt.Sprintf("Args without flags are '%v' with length %d", argsWoFlags, len(argsWoFlags))) - // Find completion function for the command - completionFn, ok := validArgsFunctions[finalCmd] + var key interface{} + var keyStr string + if flag != nil { + key = flag + keyStr = flag.Name + } else { + key = finalCmd + keyStr = finalCmd.Name() + } + + // Find completion function for the flag or command + completionFn, ok := validArgsFunctions[key] if !ok { - CompErrorln(fmt.Sprintf("Dynamic completion not supported/needed for flag or command: %s", finalCmd.Name())) + CompErrorln(fmt.Sprintf("Dynamic completion not supported/needed for flag or command: %s", keyStr)) return } @@ -150,6 +175,96 @@ func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { } } +func isFlag(arg string) bool { + return len(arg) > 0 && arg[0] == '-' +} + +func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string) (*pflag.Flag, []string, string) { + var flagName string + trimmedArgs := args + flagWithEqual := false + if isFlag(lastArg) { + if index := strings.Index(lastArg, "="); index >= 0 { + flagName = strings.TrimLeft(lastArg[:index], "-") + lastArg = lastArg[index+1:] + flagWithEqual = true + } else { + CompErrorln("Unexpected completion request for flag") + os.Exit(int(BashCompDirectiveError)) + } + } + + if len(flagName) == 0 { + if len(args) > 0 { + prevArg := args[len(args)-1] + if isFlag(prevArg) { + // If the flag contains an = it means it has already been fully processed + if index := strings.Index(prevArg, "="); index < 0 { + flagName = strings.TrimLeft(prevArg, "-") + + // Remove the uncompleted flag or else Cobra could complain about + // an invalid value for that flag e.g., helm status --output j + trimmedArgs = args[:len(args)-1] + } + } + } + } + + if len(flagName) == 0 { + // Not doing flag completion + return nil, trimmedArgs, lastArg + } + + // Find the real command for which completion must be performed + finalCmd, _, err := rootCmd.Find(trimmedArgs) + if err != nil { + // Unable to find the real command. E.g., helm invalidCmd + os.Exit(int(BashCompDirectiveError)) + } + + CompDebugln(fmt.Sprintf("checkIfFlagCompletion: found final command '%s'", finalCmd.Name())) + + flag := findFlag(finalCmd, flagName) + if flag == nil { + // Flag not supported by this command, nothing to complete + CompDebugln(fmt.Sprintf("Subcommand '%s' does not support flag '%s'", finalCmd.Name(), flagName)) + os.Exit(int(BashCompDirectiveNoFileComp)) + } + + if !flagWithEqual { + if len(flag.NoOptDefVal) != 0 { + // We had assumed dealing with a two-word flag but the flag is a boolean flag. + // In that case, there is no value following it, so we are not really doing flag completion. + // Reset everything to do argument completion. + trimmedArgs = args + flag = nil + } + } + + return flag, trimmedArgs, lastArg +} + +func findFlag(cmd *cobra.Command, name string) *pflag.Flag { + flagSet := cmd.Flags() + if len(name) == 1 { + // First convert the short flag into a long flag + // as the cmd.Flag() search only accepts long flags + if short := flagSet.ShorthandLookup(name); short != nil { + CompDebugln(fmt.Sprintf("checkIfFlagCompletion: found flag '%s' which we will change to '%s'", name, short.Name)) + name = short.Name + } else { + set := cmd.InheritedFlags() + if short = set.ShorthandLookup(name); short != nil { + CompDebugln(fmt.Sprintf("checkIfFlagCompletion: found inherited flag '%s' which we will change to '%s'", name, short.Name)) + name = short.Name + } else { + return nil + } + } + } + return cmd.Flag(name) +} + // CompDebug prints the specified string to the same file as where the // completion script prints its logs. // Note that completion printouts should never be on stdout as they would From de1ca6784afe52762880d74bfd3732437399ac7b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 31 Dec 2019 08:59:10 -0500 Subject: [PATCH 172/279] feat(comp): Support --generate-name in completion Signed-off-by: Marc Khouzam --- cmd/helm/install.go | 10 +++++++--- cmd/helm/template.go | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 701048151..0f548c90c 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -125,7 +125,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // Function providing dynamic auto-completion completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { - return compInstall(args, toComplete) + return compInstall(args, toComplete, client) }) addInstallFlags(cmd.Flags(), client, valueOpts) @@ -233,8 +233,12 @@ func isChartInstallable(ch *chart.Chart) (bool, error) { } // Provide dynamic auto-completion for the install and template commands -func compInstall(args []string, toComplete string) ([]string, completion.BashCompDirective) { - if len(args) == 1 { +func compInstall(args []string, toComplete string, client *action.Install) ([]string, completion.BashCompDirective) { + requiredArgs := 1 + if client.GenerateName { + requiredArgs = 0 + } + if len(args) == requiredArgs { return compListCharts(toComplete, true) } return nil, completion.BashCompDirectiveNoFileComp diff --git a/cmd/helm/template.go b/cmd/helm/template.go index fbd6f57e2..1c34d7245 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -126,7 +126,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // Function providing dynamic auto-completion completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { - return compInstall(args, toComplete) + return compInstall(args, toComplete, client) }) f := cmd.Flags() From d5d741dfed59d82f2b350bdb0c97d05f83f4abd1 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 1 Jan 2020 15:57:51 -0500 Subject: [PATCH 173/279] feat(comp): Support completion for --revision flag Signed-off-by: Marc Khouzam --- cmd/helm/get_all.go | 8 ++++++++ cmd/helm/get_hooks.go | 10 +++++++++- cmd/helm/get_manifest.go | 10 +++++++++- cmd/helm/get_notes.go | 7 +++++++ cmd/helm/get_values.go | 7 +++++++ cmd/helm/history.go | 14 ++++++++++++++ cmd/helm/status.go | 9 +++++++++ 7 files changed, 63 insertions(+), 2 deletions(-) diff --git a/cmd/helm/get_all.go b/cmd/helm/get_all.go index 678b85f25..7d893d7e0 100644 --- a/cmd/helm/get_all.go +++ b/cmd/helm/get_all.go @@ -67,6 +67,14 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f := cmd.Flags() f.IntVar(&client.Version, "revision", 0, "get the named release with revision") + flag := f.Lookup("revision") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListRevisions(cfg, args[0]) + } + return nil, completion.BashCompDirectiveNoFileComp + }) + f.StringVar(&template, "template", "", "go template for formatting the output, eg: {{.Release.Name}}") return cmd diff --git a/cmd/helm/get_hooks.go b/cmd/helm/get_hooks.go index 84ef0c1fc..c2087b1ba 100644 --- a/cmd/helm/get_hooks.go +++ b/cmd/helm/get_hooks.go @@ -61,7 +61,15 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return compListReleases(toComplete, cfg) }) - cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") + f := cmd.Flags() + f.IntVar(&client.Version, "revision", 0, "get the named release with revision") + flag := f.Lookup("revision") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListRevisions(cfg, args[0]) + } + return nil, completion.BashCompDirectiveNoFileComp + }) return cmd } diff --git a/cmd/helm/get_manifest.go b/cmd/helm/get_manifest.go index 1860025cd..f332befd9 100644 --- a/cmd/helm/get_manifest.go +++ b/cmd/helm/get_manifest.go @@ -61,7 +61,15 @@ func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command return compListReleases(toComplete, cfg) }) - cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") + f := cmd.Flags() + f.IntVar(&client.Version, "revision", 0, "get the named release with revision") + flag := f.Lookup("revision") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListRevisions(cfg, args[0]) + } + return nil, completion.BashCompDirectiveNoFileComp + }) return cmd } diff --git a/cmd/helm/get_notes.go b/cmd/helm/get_notes.go index de3adf498..4491bd9ba 100644 --- a/cmd/helm/get_notes.go +++ b/cmd/helm/get_notes.go @@ -61,6 +61,13 @@ func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f := cmd.Flags() f.IntVar(&client.Version, "revision", 0, "get the named release with revision") + flag := f.Lookup("revision") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListRevisions(cfg, args[0]) + } + return nil, completion.BashCompDirectiveNoFileComp + }) return cmd } diff --git a/cmd/helm/get_values.go b/cmd/helm/get_values.go index 898db8929..a8c5acc5e 100644 --- a/cmd/helm/get_values.go +++ b/cmd/helm/get_values.go @@ -65,6 +65,13 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f := cmd.Flags() f.IntVar(&client.Version, "revision", 0, "get the named release with revision") + flag := f.Lookup("revision") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListRevisions(cfg, args[0]) + } + return nil, completion.BashCompDirectiveNoFileComp + }) f.BoolVarP(&client.AllValues, "all", "a", false, "dump all (computed) values") bindOutputFlag(cmd, &outfmt) diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 739848c1c..3ef542e58 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -19,6 +19,7 @@ package main import ( "fmt" "io" + "strconv" "time" "github.com/gosuri/uitable" @@ -185,3 +186,16 @@ func min(x, y int) int { } return y } + +func compListRevisions(cfg *action.Configuration, releaseName string) ([]string, completion.BashCompDirective) { + client := action.NewHistory(cfg) + + var revisions []string + if hist, err := client.Run(releaseName); err == nil { + for _, release := range hist { + revisions = append(revisions, strconv.Itoa(release.Version)) + } + return revisions, completion.BashCompDirectiveDefault + } + return nil, completion.BashCompDirectiveError +} diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 8f172f66a..34543c6cb 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -75,7 +75,16 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }) f := cmd.PersistentFlags() + f.IntVar(&client.Version, "revision", 0, "if set, display the status of the named release with revision") + flag := f.Lookup("revision") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + if len(args) == 1 { + return compListRevisions(cfg, args[0]) + } + return nil, completion.BashCompDirectiveNoFileComp + }) + bindOutputFlag(cmd, &outfmt) return cmd From 90548c591d9f2662c2db303b4cb09feaab33a02d Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 9 Jan 2020 20:28:46 -0500 Subject: [PATCH 174/279] feat(comp): Don't use error codes for completion To use error codes to indicate completion directive to the completion script had us use os.Exit() in the __complete command. This prevented go tests calling the __complete command from succeeding. Another option was to return an error containing an error code (like is done for helm plugins) instead of calling os.Exit(). However such an approach requires a change in how helm handles the returned error of a Cobra command; although we can do this for Helm, it would be an annoying requirement for other programs if we ever push this completion logic into Cobra. The chosen solution instead is to printout the directive at the end of the list of completions, and have the completion script extract it. Note that we print both the completions and directive to stdout. It would have been interesting to print the completions to stdout and the directive to stderr; however, it is very complicated for the completion script to extract both stdout and stderr to different variables, and even if possible, such code would not be portable to many shells. Printing both to stdout is much simpler. Signed-off-by: Marc Khouzam --- cmd/helm/root.go | 14 ++++++++++++- internal/completion/complete.go | 35 +++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index ab7b01c90..bf98e72fe 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -65,18 +65,30 @@ __helm_custom_func() __helm_debug "${FUNCNAME[0]}: calling ${requestComp}" # Use eval to handle any environment variables and such out=$(eval ${requestComp} 2>/dev/null) - directive=$? + + # Extract the directive int at the very end of the output following a : + directive=${out##*:} + # Remove the directive + out=${out%%:*} + if [ "${directive}" = "${out}" ]; then + # There is not directive specified + directive=0 + fi + __helm_debug "${FUNCNAME[0]}: the completion directive is: ${directive}" + __helm_debug "${FUNCNAME[0]}: the completions are: ${out[*]}" if [ $((${directive} & %[2]d)) -ne 0 ]; then __helm_debug "${FUNCNAME[0]}: received error, completion failed" else if [ $((${directive} & %[3]d)) -ne 0 ]; then if [[ $(type -t compopt) = "builtin" ]]; then + __helm_debug "${FUNCNAME[0]}: activating no space" compopt -o nospace fi fi if [ $((${directive} & %[4]d)) -ne 0 ]; then if [[ $(type -t compopt) = "builtin" ]]; then + __helm_debug "${FUNCNAME[0]}: activating no file completion" compopt +o default fi fi diff --git a/internal/completion/complete.go b/internal/completion/complete.go index c0fabda1b..d13c7f5bd 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -16,6 +16,7 @@ limitations under the License. package completion import ( + "errors" "fmt" "log" "os" @@ -124,13 +125,17 @@ func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { Run: func(cmd *cobra.Command, args []string) { CompDebugln(fmt.Sprintf("%s was called with args %v", cmd.Name(), args)) - flag, trimmedArgs, toComplete := checkIfFlagCompletion(cmd.Root(), args[:len(args)-1], args[len(args)-1]) - + flag, trimmedArgs, toComplete, err := checkIfFlagCompletion(cmd.Root(), args[:len(args)-1], args[len(args)-1]) + if err != nil { + // Error while attempting to parse flags + CompErrorln(err.Error()) + return + } // Find the real command for which completion must be performed finalCmd, finalArgs, err := cmd.Root().Find(trimmedArgs) if err != nil { // Unable to find the real command. E.g., helm invalidCmd - os.Exit(int(BashCompDirectiveError)) + return } CompDebugln(fmt.Sprintf("Found final command '%s', with finalArgs %v", finalCmd.Name(), finalArgs)) @@ -167,10 +172,15 @@ func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { fmt.Println(comp) } - // Print some helpful info to stderr for the user to see. + // As the last printout, print the completion directive for the + // completion script to parse. + // The directive integer must be that last character following a single : + // The completion script expects :directive + fmt.Printf("\n:%d\n", directive) + + // Print some helpful info to stderr for the user to understand. // Output from stderr should be ignored from the completion script. fmt.Fprintf(os.Stderr, "Completion ended with directive: %s\n", directive.string()) - os.Exit(int(directive)) }, } } @@ -179,7 +189,7 @@ func isFlag(arg string) bool { return len(arg) > 0 && arg[0] == '-' } -func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string) (*pflag.Flag, []string, string) { +func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string) (*pflag.Flag, []string, string, error) { var flagName string trimmedArgs := args flagWithEqual := false @@ -189,8 +199,7 @@ func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string lastArg = lastArg[index+1:] flagWithEqual = true } else { - CompErrorln("Unexpected completion request for flag") - os.Exit(int(BashCompDirectiveError)) + return nil, nil, "", errors.New("Unexpected completion request for flag") } } @@ -212,14 +221,14 @@ func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string if len(flagName) == 0 { // Not doing flag completion - return nil, trimmedArgs, lastArg + return nil, trimmedArgs, lastArg, nil } // Find the real command for which completion must be performed finalCmd, _, err := rootCmd.Find(trimmedArgs) if err != nil { // Unable to find the real command. E.g., helm invalidCmd - os.Exit(int(BashCompDirectiveError)) + return nil, nil, "", errors.New("Unable to find final command for completion") } CompDebugln(fmt.Sprintf("checkIfFlagCompletion: found final command '%s'", finalCmd.Name())) @@ -227,8 +236,8 @@ func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string flag := findFlag(finalCmd, flagName) if flag == nil { // Flag not supported by this command, nothing to complete - CompDebugln(fmt.Sprintf("Subcommand '%s' does not support flag '%s'", finalCmd.Name(), flagName)) - os.Exit(int(BashCompDirectiveNoFileComp)) + err = fmt.Errorf("Subcommand '%s' does not support flag '%s'", finalCmd.Name(), flagName) + return nil, nil, "", err } if !flagWithEqual { @@ -241,7 +250,7 @@ func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string } } - return flag, trimmedArgs, lastArg + return flag, trimmedArgs, lastArg, nil } func findFlag(cmd *cobra.Command, name string) *pflag.Flag { From 0095e320012b606d70f0fa52f5bb4084275a2ffa Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 8 Jan 2020 15:04:07 -0500 Subject: [PATCH 175/279] feat(test): add some completion tests Signed-off-by: Marc Khouzam --- cmd/helm/flags_test.go | 88 +++++++++++++++++++ cmd/helm/get_all_test.go | 4 + cmd/helm/get_hooks_test.go | 4 + cmd/helm/get_manifest_test.go | 4 + cmd/helm/get_notes_test.go | 4 + cmd/helm/get_values_test.go | 8 ++ cmd/helm/helm_test.go | 29 ++++++ cmd/helm/history_test.go | 40 +++++++++ cmd/helm/install_test.go | 4 + cmd/helm/list_test.go | 4 + cmd/helm/repo_list_test.go | 25 ++++++ cmd/helm/root.go | 2 +- cmd/helm/search_hub_test.go | 3 + cmd/helm/search_repo_test.go | 4 + cmd/helm/status_test.go | 63 +++++++++++++ cmd/helm/testdata/output/output-comp.txt | 4 + cmd/helm/testdata/output/revision-comp.txt | 5 ++ .../output/revision-wrong-args-comp.txt | 1 + cmd/helm/testdata/output/status-comp.txt | 3 + .../output/status-wrong-args-comp.txt | 1 + cmd/helm/upgrade_test.go | 4 + internal/completion/complete.go | 7 +- 22 files changed, 307 insertions(+), 4 deletions(-) create mode 100644 cmd/helm/flags_test.go create mode 100644 cmd/helm/repo_list_test.go create mode 100644 cmd/helm/testdata/output/output-comp.txt create mode 100644 cmd/helm/testdata/output/revision-comp.txt create mode 100644 cmd/helm/testdata/output/revision-wrong-args-comp.txt create mode 100644 cmd/helm/testdata/output/status-comp.txt create mode 100644 cmd/helm/testdata/output/status-wrong-args-comp.txt diff --git a/cmd/helm/flags_test.go b/cmd/helm/flags_test.go new file mode 100644 index 000000000..d5576fe9f --- /dev/null +++ b/cmd/helm/flags_test.go @@ -0,0 +1,88 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "fmt" + "testing" + + "helm.sh/helm/v3/pkg/chart" + "helm.sh/helm/v3/pkg/release" + helmtime "helm.sh/helm/v3/pkg/time" +) + +func outputFlagCompletionTest(t *testing.T, cmdName string) { + releasesMockWithStatus := func(info *release.Info, hooks ...*release.Hook) []*release.Release { + info.LastDeployed = helmtime.Unix(1452902400, 0).UTC() + return []*release.Release{{ + Name: "athos", + Namespace: "default", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }, { + Name: "porthos", + Namespace: "default", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }, { + Name: "aramis", + Namespace: "default", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }, { + Name: "dartagnan", + Namespace: "gascony", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }} + } + + tests := []cmdTestCase{{ + name: "completion for output flag long and before arg", + cmd: fmt.Sprintf("__complete %s --output ''", cmdName), + golden: "output/output-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }, { + name: "completion for output flag long and after arg", + cmd: fmt.Sprintf("__complete %s aramis --output ''", cmdName), + golden: "output/output-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }, { + name: "completion for output flag short and before arg", + cmd: fmt.Sprintf("__complete %s -o ''", cmdName), + golden: "output/output-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }, { + name: "completion for output flag short and after arg", + cmd: fmt.Sprintf("__complete %s aramis -o ''", cmdName), + golden: "output/output-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }} + runTestCmd(t, tests) +} diff --git a/cmd/helm/get_all_test.go b/cmd/helm/get_all_test.go index 0b026fca4..a213ac583 100644 --- a/cmd/helm/get_all_test.go +++ b/cmd/helm/get_all_test.go @@ -41,3 +41,7 @@ func TestGetCmd(t *testing.T) { }} runTestCmd(t, tests) } + +func TestGetAllRevisionCompletion(t *testing.T) { + revisionFlagCompletionTest(t, "get all") +} diff --git a/cmd/helm/get_hooks_test.go b/cmd/helm/get_hooks_test.go index f843f7d59..7b9142d12 100644 --- a/cmd/helm/get_hooks_test.go +++ b/cmd/helm/get_hooks_test.go @@ -36,3 +36,7 @@ func TestGetHooks(t *testing.T) { }} runTestCmd(t, tests) } + +func TestGetHooksRevisionCompletion(t *testing.T) { + revisionFlagCompletionTest(t, "get hooks") +} diff --git a/cmd/helm/get_manifest_test.go b/cmd/helm/get_manifest_test.go index be54d4a5b..bd0ffc5d6 100644 --- a/cmd/helm/get_manifest_test.go +++ b/cmd/helm/get_manifest_test.go @@ -36,3 +36,7 @@ func TestGetManifest(t *testing.T) { }} runTestCmd(t, tests) } + +func TestGetManifestRevisionCompletion(t *testing.T) { + revisionFlagCompletionTest(t, "get manifest") +} diff --git a/cmd/helm/get_notes_test.go b/cmd/helm/get_notes_test.go index a3ddea9a7..a59120b77 100644 --- a/cmd/helm/get_notes_test.go +++ b/cmd/helm/get_notes_test.go @@ -36,3 +36,7 @@ func TestGetNotesCmd(t *testing.T) { }} runTestCmd(t, tests) } + +func TestGetNotesRevisionCompletion(t *testing.T) { + revisionFlagCompletionTest(t, "get notes") +} diff --git a/cmd/helm/get_values_test.go b/cmd/helm/get_values_test.go index da3cc9e39..ecd92d354 100644 --- a/cmd/helm/get_values_test.go +++ b/cmd/helm/get_values_test.go @@ -52,3 +52,11 @@ func TestGetValuesCmd(t *testing.T) { }} runTestCmd(t, tests) } + +func TestGetValuesRevisionCompletion(t *testing.T) { + revisionFlagCompletionTest(t, "get values") +} + +func TestGetValuesOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "get values") +} diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index b7156daf3..5f9d80a3a 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -18,6 +18,7 @@ package main import ( "bytes" + "fmt" "io/ioutil" "os" "os/exec" @@ -96,11 +97,39 @@ func storageFixture() *storage.Storage { return storage.Init(driver.NewMemory()) } +// go-shellwords does not handle empty arguments properly +// https://github.com/mattn/go-shellwords/issues/5#issuecomment-573431458 +// +// This method checks if the last argument was an empty one, +// and if go-shellwords missed it, we add it ourselves. +// +// This is important for completion tests as completion often +// uses an empty last parameter. +func checkLastEmpty(in string, out []string) []string { + lastIndex := len(in) - 1 + + if lastIndex >= 1 && (in[lastIndex] == '"' && in[lastIndex-1] == '"' || + in[lastIndex] == '\'' && in[lastIndex-1] == '\'') { + // The last parameter of 'in' was empty ("" or ''), let's make sure it was detected. + if len(out) > 0 && out[len(out)-1] != "" { + // Bug from go-shellwords: + // 'out' does not have the empty parameter. We add it ourselves as a workaround. + out = append(out, "") + } else { + fmt.Println("WARNING: go-shellwords seems to have been fixed. This workaround can be removed.") + } + } + return out +} + func executeActionCommandC(store *storage.Storage, cmd string) (*cobra.Command, string, error) { args, err := shellwords.Parse(cmd) if err != nil { return nil, "", err } + // Workaround the bug in shellwords + args = checkLastEmpty(cmd, args) + buf := new(bytes.Buffer) actionConfig := &action.Configuration{ diff --git a/cmd/helm/history_test.go b/cmd/helm/history_test.go index 3e750cefc..c9bfb648e 100644 --- a/cmd/helm/history_test.go +++ b/cmd/helm/history_test.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "fmt" "testing" "helm.sh/helm/v3/pkg/release" @@ -68,3 +69,42 @@ func TestHistoryCmd(t *testing.T) { }} runTestCmd(t, tests) } + +func TestHistoryOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "history") +} + +func revisionFlagCompletionTest(t *testing.T, cmdName string) { + mk := func(name string, vers int, status release.Status) *release.Release { + return release.Mock(&release.MockReleaseOptions{ + Name: name, + Version: vers, + Status: status, + }) + } + + releases := []*release.Release{ + mk("musketeers", 11, release.StatusDeployed), + mk("musketeers", 10, release.StatusSuperseded), + mk("musketeers", 9, release.StatusSuperseded), + mk("musketeers", 8, release.StatusSuperseded), + } + + tests := []cmdTestCase{{ + name: "completion for revision flag", + cmd: fmt.Sprintf("__complete %s musketeers --revision ''", cmdName), + rels: releases, + golden: "output/revision-comp.txt", + }, { + name: "completion for revision flag with too few args", + cmd: fmt.Sprintf("__complete %s --revision ''", cmdName), + rels: releases, + golden: "output/revision-wrong-args-comp.txt", + }, { + name: "completion for revision flag with too many args", + cmd: fmt.Sprintf("__complete %s three musketeers --revision ''", cmdName), + rels: releases, + golden: "output/revision-wrong-args-comp.txt", + }} + runTestCmd(t, tests) +} diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index e8b573dfc..57972024f 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -193,3 +193,7 @@ func TestInstall(t *testing.T) { runTestActionCmd(t, tests) } + +func TestInstallOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "install") +} diff --git a/cmd/helm/list_test.go b/cmd/helm/list_test.go index b5833fd72..127a8a980 100644 --- a/cmd/helm/list_test.go +++ b/cmd/helm/list_test.go @@ -206,3 +206,7 @@ func TestListCmd(t *testing.T) { }} runTestCmd(t, tests) } + +func TestListOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "list") +} diff --git a/cmd/helm/repo_list_test.go b/cmd/helm/repo_list_test.go new file mode 100644 index 000000000..f371452f2 --- /dev/null +++ b/cmd/helm/repo_list_test.go @@ -0,0 +1,25 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "testing" +) + +func TestRepoListOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "repo list") +} diff --git a/cmd/helm/root.go b/cmd/helm/root.go index bf98e72fe..c6c055993 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -232,7 +232,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string newDocsCmd(out), // Setup the special hidden __complete command to allow for dynamic auto-completion - completion.NewCompleteCmd(settings), + completion.NewCompleteCmd(settings, out), ) // Add annotation to flags for which we can generate completion choices diff --git a/cmd/helm/search_hub_test.go b/cmd/helm/search_hub_test.go index dfe0cacc2..7b0f3a389 100644 --- a/cmd/helm/search_hub_test.go +++ b/cmd/helm/search_hub_test.go @@ -49,5 +49,8 @@ func TestSearchHubCmd(t *testing.T) { t.Log(out) t.Log(expected) } +} +func TestSearchHubOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "search hub") } diff --git a/cmd/helm/search_repo_test.go b/cmd/helm/search_repo_test.go index 6ece55505..402ef2970 100644 --- a/cmd/helm/search_repo_test.go +++ b/cmd/helm/search_repo_test.go @@ -83,3 +83,7 @@ func TestSearchRepositoriesCmd(t *testing.T) { } runTestCmd(t, tests) } + +func TestSearchRepoOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "search repo") +} diff --git a/cmd/helm/status_test.go b/cmd/helm/status_test.go index 91a008e5a..0d2500e65 100644 --- a/cmd/helm/status_test.go +++ b/cmd/helm/status_test.go @@ -108,3 +108,66 @@ func mustParseTime(t string) helmtime.Time { res, _ := helmtime.Parse(time.RFC3339, t) return res } + +func TestStatusCompletion(t *testing.T) { + releasesMockWithStatus := func(info *release.Info, hooks ...*release.Hook) []*release.Release { + info.LastDeployed = helmtime.Unix(1452902400, 0).UTC() + return []*release.Release{{ + Name: "athos", + Namespace: "default", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }, { + Name: "porthos", + Namespace: "default", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }, { + Name: "aramis", + Namespace: "default", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }, { + Name: "dartagnan", + Namespace: "gascony", + Info: info, + Chart: &chart.Chart{}, + Hooks: hooks, + }} + } + + tests := []cmdTestCase{{ + name: "completion for status", + cmd: "__complete status a", + golden: "output/status-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }, { + name: "completion for status with too many arguments", + cmd: "__complete status dartagnan ''", + golden: "output/status-wrong-args-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }, { + name: "completion for status with too many arguments", + cmd: "__complete status --debug a", + golden: "output/status-comp.txt", + rels: releasesMockWithStatus(&release.Info{ + Status: release.StatusDeployed, + }), + }} + runTestCmd(t, tests) +} + +func TestStatusRevisionCompletion(t *testing.T) { + revisionFlagCompletionTest(t, "status") +} + +func TestStatusOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "status") +} diff --git a/cmd/helm/testdata/output/output-comp.txt b/cmd/helm/testdata/output/output-comp.txt new file mode 100644 index 000000000..de5f16f1d --- /dev/null +++ b/cmd/helm/testdata/output/output-comp.txt @@ -0,0 +1,4 @@ +table +json +yaml +:0 diff --git a/cmd/helm/testdata/output/revision-comp.txt b/cmd/helm/testdata/output/revision-comp.txt new file mode 100644 index 000000000..b4799f059 --- /dev/null +++ b/cmd/helm/testdata/output/revision-comp.txt @@ -0,0 +1,5 @@ +8 +9 +10 +11 +:0 diff --git a/cmd/helm/testdata/output/revision-wrong-args-comp.txt b/cmd/helm/testdata/output/revision-wrong-args-comp.txt new file mode 100644 index 000000000..b6f867176 --- /dev/null +++ b/cmd/helm/testdata/output/revision-wrong-args-comp.txt @@ -0,0 +1 @@ +:4 diff --git a/cmd/helm/testdata/output/status-comp.txt b/cmd/helm/testdata/output/status-comp.txt new file mode 100644 index 000000000..c97882964 --- /dev/null +++ b/cmd/helm/testdata/output/status-comp.txt @@ -0,0 +1,3 @@ +aramis +athos +:4 diff --git a/cmd/helm/testdata/output/status-wrong-args-comp.txt b/cmd/helm/testdata/output/status-wrong-args-comp.txt new file mode 100644 index 000000000..b6f867176 --- /dev/null +++ b/cmd/helm/testdata/output/status-wrong-args-comp.txt @@ -0,0 +1 @@ +:4 diff --git a/cmd/helm/upgrade_test.go b/cmd/helm/upgrade_test.go index bd1ccec35..3cecbe6d3 100644 --- a/cmd/helm/upgrade_test.go +++ b/cmd/helm/upgrade_test.go @@ -258,3 +258,7 @@ func prepareMockRelease(releaseName string, t *testing.T) (func(n string, v int, return relMock, ch, chartPath } + +func TestUpgradeOutputCompletion(t *testing.T) { + outputFlagCompletionTest(t, "upgrade") +} diff --git a/internal/completion/complete.go b/internal/completion/complete.go index d13c7f5bd..ccc868a59 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -18,6 +18,7 @@ package completion import ( "errors" "fmt" + "io" "log" "os" "strings" @@ -111,7 +112,7 @@ func (d BashCompDirective) string() string { } // NewCompleteCmd add a special hidden command that an be used to request completions -func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { +func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command { debug = settings.Debug return &cobra.Command{ Use: fmt.Sprintf("%s [command-line]", CompRequestCmd), @@ -169,14 +170,14 @@ func NewCompleteCmd(settings *cli.EnvSettings) *cobra.Command { completions, directive := completionFn(finalCmd, argsWoFlags, toComplete) for _, comp := range completions { // Print each possible completion to stdout for the completion script to consume. - fmt.Println(comp) + fmt.Fprintln(out, comp) } // As the last printout, print the completion directive for the // completion script to parse. // The directive integer must be that last character following a single : // The completion script expects :directive - fmt.Printf("\n:%d\n", directive) + fmt.Fprintln(out, fmt.Sprintf(":%d", directive)) // Print some helpful info to stderr for the user to understand. // Output from stderr should be ignored from the completion script. From fc618b4b6e579ba5582f50ceb7f9c9e14735ec78 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 15 Jan 2020 19:01:54 -0500 Subject: [PATCH 176/279] feat(comp): Use cached charts file for speed Signed-off-by: Marc Khouzam --- cmd/helm/search_repo.go | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index a57ad135b..9f5af1e3c 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -17,6 +17,8 @@ limitations under the License. package main import ( + "bufio" + "bytes" "fmt" "io" "io/ioutil" @@ -251,17 +253,39 @@ func (r *repoSearchWriter) encodeByFormat(out io.Writer, format output.Format) e // Provides the list of charts that are part of the specified repo, and that starts with 'prefix'. func compListChartsOfRepo(repoName string, prefix string) []string { - f := filepath.Join(settings.RepositoryCache, helmpath.CacheIndexFile(repoName)) var charts []string - if indexFile, err := repo.LoadIndexFile(f); err == nil { - for name := range indexFile.Entries { - fullName := fmt.Sprintf("%s/%s", repoName, name) + + path := filepath.Join(settings.RepositoryCache, helmpath.CacheChartsFile(repoName)) + content, err := ioutil.ReadFile(path) + if err == nil { + scanner := bufio.NewScanner(bytes.NewReader(content)) + for scanner.Scan() { + fullName := fmt.Sprintf("%s/%s", repoName, scanner.Text()) if strings.HasPrefix(fullName, prefix) { charts = append(charts, fullName) } } + return charts } - return charts + + if isNotExist(err) { + // If there is no cached charts file, fallback to the full index file. + // This is much slower but can happen after the caching feature is first + // installed but before the user does a 'helm repo update' to generate the + // first cached charts file. + path = filepath.Join(settings.RepositoryCache, helmpath.CacheIndexFile(repoName)) + if indexFile, err := repo.LoadIndexFile(path); err == nil { + for name := range indexFile.Entries { + fullName := fmt.Sprintf("%s/%s", repoName, name) + if strings.HasPrefix(fullName, prefix) { + charts = append(charts, fullName) + } + } + return charts + } + } + + return []string{} } // Provide dynamic auto-completion for commands that operate on charts (e.g., helm show) From a8369db802d47f0b60f7d84602da85d28bc79be4 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 15 Jan 2020 19:30:04 -0500 Subject: [PATCH 177/279] feat(comp): Isolate go completion framework better Signed-off-by: Marc Khouzam --- cmd/helm/root.go | 75 +++------------------------------ internal/completion/complete.go | 70 ++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 72 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index c6c055993..a3e4da746 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -32,7 +32,7 @@ import ( ) const ( - bashCompletionFunc = ` + contextCompFunc = ` __helm_get_contexts() { __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" @@ -42,62 +42,6 @@ __helm_get_contexts() COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) fi } - -__helm_custom_func() -{ - __helm_debug "${FUNCNAME[0]}: c is $c, words[@] is ${words[@]}, #words[@] is ${#words[@]}" - __helm_debug "${FUNCNAME[0]}: cur is ${cur}, cword is ${cword}, words is ${words}" - - local out requestComp lastParam lastChar - requestComp="${words[0]} %[1]s ${words[@]:1}" - - lastParam=${words[$((${#words[@]}-1))]} - lastChar=${lastParam:$((${#lastParam}-1)):1} - __helm_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}" - - if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then - # If the last parameter is complete (there is a space following it) - # We add an extra empty parameter so we can indicate this to the go method. - __helm_debug "${FUNCNAME[0]}: Adding extra empty parameter" - requestComp="${requestComp} \"\"" - fi - - __helm_debug "${FUNCNAME[0]}: calling ${requestComp}" - # Use eval to handle any environment variables and such - out=$(eval ${requestComp} 2>/dev/null) - - # Extract the directive int at the very end of the output following a : - directive=${out##*:} - # Remove the directive - out=${out%%:*} - if [ "${directive}" = "${out}" ]; then - # There is not directive specified - directive=0 - fi - __helm_debug "${FUNCNAME[0]}: the completion directive is: ${directive}" - __helm_debug "${FUNCNAME[0]}: the completions are: ${out[*]}" - - if [ $((${directive} & %[2]d)) -ne 0 ]; then - __helm_debug "${FUNCNAME[0]}: received error, completion failed" - else - if [ $((${directive} & %[3]d)) -ne 0 ]; then - if [[ $(type -t compopt) = "builtin" ]]; then - __helm_debug "${FUNCNAME[0]}: activating no space" - compopt -o nospace - fi - fi - if [ $((${directive} & %[4]d)) -ne 0 ]; then - if [[ $(type -t compopt) = "builtin" ]]; then - __helm_debug "${FUNCNAME[0]}: activating no file completion" - compopt +o default - fi - fi - - while IFS='' read -r comp; do - COMPREPLY+=("$comp") - done < <(compgen -W "${out[*]}" -- "$cur") - fi -} ` ) @@ -152,17 +96,12 @@ By default, the default directories depend on the Operating System. The defaults func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command { cmd := &cobra.Command{ - Use: "helm", - Short: "The Helm package manager for Kubernetes.", - Long: globalUsage, - SilenceUsage: true, - Args: require.NoArgs, - BashCompletionFunction: fmt.Sprintf( - bashCompletionFunc, - completion.CompRequestCmd, - completion.BashCompDirectiveError, - completion.BashCompDirectiveNoSpace, - completion.BashCompDirectiveNoFileComp), + Use: "helm", + Short: "The Helm package manager for Kubernetes.", + Long: globalUsage, + SilenceUsage: true, + Args: require.NoArgs, + BashCompletionFunction: fmt.Sprintf("%s%s", contextCompFunc, completion.GetBashCustomFunction()), } flags := cmd.PersistentFlags() diff --git a/internal/completion/complete.go b/internal/completion/complete.go index ccc868a59..a24390fc0 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -35,9 +35,9 @@ import ( // This should ultimately be pushed down into Cobra. // ================================================================================== -// CompRequestCmd Hidden command to request completion results from the program. +// compRequestCmd Hidden command to request completion results from the program. // Used by the shell completion script. -const CompRequestCmd = "__complete" +const compRequestCmd = "__complete" // Global map allowing to find completion functions for commands or flags. var validArgsFunctions = map[interface{}]func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective){} @@ -64,6 +64,68 @@ const ( BashCompDirectiveDefault BashCompDirective = 0 ) +// GetBashCustomFunction returns the bash code to handle custom go completion +// This should eventually be provided by Cobra +func GetBashCustomFunction() string { + return fmt.Sprintf(` +__helm_custom_func() +{ + __helm_debug "${FUNCNAME[0]}: c is $c, words[@] is ${words[@]}, #words[@] is ${#words[@]}" + __helm_debug "${FUNCNAME[0]}: cur is ${cur}, cword is ${cword}, words is ${words}" + + local out requestComp lastParam lastChar + requestComp="${words[0]} %[1]s ${words[@]:1}" + + lastParam=${words[$((${#words[@]}-1))]} + lastChar=${lastParam:$((${#lastParam}-1)):1} + __helm_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}" + + if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then + # If the last parameter is complete (there is a space following it) + # We add an extra empty parameter so we can indicate this to the go method. + __helm_debug "${FUNCNAME[0]}: Adding extra empty parameter" + requestComp="${requestComp} \"\"" + fi + + __helm_debug "${FUNCNAME[0]}: calling ${requestComp}" + # Use eval to handle any environment variables and such + out=$(eval ${requestComp} 2>/dev/null) + + # Extract the directive int at the very end of the output following a : + directive=${out##*:} + # Remove the directive + out=${out%%:*} + if [ "${directive}" = "${out}" ]; then + # There is not directive specified + directive=0 + fi + __helm_debug "${FUNCNAME[0]}: the completion directive is: ${directive}" + __helm_debug "${FUNCNAME[0]}: the completions are: ${out[*]}" + + if [ $((${directive} & %[2]d)) -ne 0 ]; then + __helm_debug "${FUNCNAME[0]}: received error, completion failed" + else + if [ $((${directive} & %[3]d)) -ne 0 ]; then + if [[ $(type -t compopt) = "builtin" ]]; then + __helm_debug "${FUNCNAME[0]}: activating no space" + compopt -o nospace + fi + fi + if [ $((${directive} & %[4]d)) -ne 0 ]; then + if [[ $(type -t compopt) = "builtin" ]]; then + __helm_debug "${FUNCNAME[0]}: activating no file completion" + compopt +o default + fi + fi + + while IFS='' read -r comp; do + COMPREPLY+=("$comp") + done < <(compgen -W "${out[*]}" -- "$cur") + fi +} +`, compRequestCmd, BashCompDirectiveError, BashCompDirectiveNoSpace, BashCompDirectiveNoFileComp) +} + // RegisterValidArgsFunc should be called to register a function to provide argument completion for a command func RegisterValidArgsFunc(cmd *cobra.Command, f func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective)) { if _, exists := validArgsFunctions[cmd]; exists { @@ -115,14 +177,14 @@ func (d BashCompDirective) string() string { func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command { debug = settings.Debug return &cobra.Command{ - Use: fmt.Sprintf("%s [command-line]", CompRequestCmd), + Use: fmt.Sprintf("%s [command-line]", compRequestCmd), DisableFlagsInUseLine: true, Hidden: true, DisableFlagParsing: true, Args: require.MinimumNArgs(1), Short: "Request shell completion choices for the specified command-line", Long: fmt.Sprintf("%s is a special command that is used by the shell completion logic\n%s", - CompRequestCmd, "to request completion choices for the specified command-line."), + compRequestCmd, "to request completion choices for the specified command-line."), Run: func(cmd *cobra.Command, args []string) { CompDebugln(fmt.Sprintf("%s was called with args %v", cmd.Name(), args)) From d4c37d33d1a186d8b271b4f4276da434da6a20e0 Mon Sep 17 00:00:00 2001 From: Ahmad Kazemi Date: Thu, 16 Jan 2020 12:04:22 +1100 Subject: [PATCH 178/279] Signed-off-by: Ahmad Kazemi log.Printf replaced to fix the log issue. --- pkg/kube/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index cdd996925..144218793 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -418,7 +418,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object, if err != nil { return errors.Wrap(err, "failed to replace object") } - log.Printf("Replaced %q with kind %s for kind %s\n", target.Name, currentObj.GetObjectKind().GroupVersionKind().Kind, kind) + c.Log("Replaced %q with kind %s for kind %s\n", target.Name, currentObj.GetObjectKind().GroupVersionKind().Kind, kind) } else { // send patch to server obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch, nil) From 91432239323f64521f2096c2eee06cc4d8857412 Mon Sep 17 00:00:00 2001 From: Ahmad Kazemi Date: Thu, 16 Jan 2020 12:19:30 +1100 Subject: [PATCH 179/279] unnecessary import removed Signed-off-by: Ahmad Kazemi unnecessary import removed --- pkg/kube/client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 144218793..fe3caaca3 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "io" - "log" "strings" "sync" "time" From 1f0582cadc1ba222c5d7a7f9977a091edd55f6af Mon Sep 17 00:00:00 2001 From: Cristian Klein Date: Wed, 1 Jan 2020 20:44:06 +0100 Subject: [PATCH 180/279] fix(helm): improve handling of corrupted storage Helm does not yet properly handle concurrent executions (see #7322), and invoking Helm concurrently on the same release lead to corrupted storage. Specifically, several Releases may be marked as DEPLOYED. This patch improved handling of such situations, by taking the latest DEPLOYED Release. Eventually, the storage will clean itself out, after the corrupted Releases are deleted due to --history-max. This is a port to Helm v3 of #7319. Signed-off-by: Cristian Klein --- pkg/storage/storage.go | 4 ++++ pkg/storage/storage_test.go | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 56881493b..89183355f 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -119,6 +119,10 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) { return nil, errors.Errorf("%q has no deployed releases", name) } + // If executed concurrently, Helm's database gets corrupted + // and multiple releases are DEPLOYED. Take the latest. + relutil.Reverse(ls, relutil.SortByRevision) + return ls[0], nil } diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index b8c333d24..ee9c68b80 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -205,6 +205,46 @@ func TestStorageDeployed(t *testing.T) { } } +func TestStorageDeployedWithCorruption(t *testing.T) { + storage := Init(driver.NewMemory()) + + const name = "angry-bird" + const vers = int(4) + + // setup storage with test releases + setup := func() { + // release records (notice odd order and corruption) + rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.StatusSuperseded}.ToRelease() + rls1 := ReleaseTestData{Name: name, Version: 4, Status: rspb.StatusDeployed}.ToRelease() + rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.StatusSuperseded}.ToRelease() + rls3 := ReleaseTestData{Name: name, Version: 2, Status: rspb.StatusDeployed}.ToRelease() + + // create the release records in the storage + assertErrNil(t.Fatal, storage.Create(rls0), "Storing release 'angry-bird' (v1)") + assertErrNil(t.Fatal, storage.Create(rls1), "Storing release 'angry-bird' (v2)") + assertErrNil(t.Fatal, storage.Create(rls2), "Storing release 'angry-bird' (v3)") + assertErrNil(t.Fatal, storage.Create(rls3), "Storing release 'angry-bird' (v4)") + } + + setup() + + rls, err := storage.Deployed(name) + if err != nil { + t.Fatalf("Failed to query for deployed release: %s\n", err) + } + + switch { + case rls == nil: + t.Fatalf("Release is nil") + case rls.Name != name: + t.Fatalf("Expected release name %q, actual %q\n", name, rls.Name) + case rls.Version != vers: + t.Fatalf("Expected release version %d, actual %d\n", vers, rls.Version) + case rls.Info.Status != rspb.StatusDeployed: + t.Fatalf("Expected release status 'DEPLOYED', actual %s\n", rls.Info.Status.String()) + } +} + func TestStorageHistory(t *testing.T) { storage := Init(driver.NewMemory()) From 9d6f2ed10764014375751f1ed78f5d009af34f4d Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 16 Jan 2020 10:12:00 -0800 Subject: [PATCH 181/279] feat(version): show "unreleased" when built from a branch Signed-off-by: Matthew Fisher --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 31e1f4374..0a3b08548 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,13 @@ ifneq ($(BINARY_VERSION),) LDFLAGS += -X helm.sh/helm/v3/internal/version.version=${BINARY_VERSION} endif +VERSION_METADATA = unreleased # Clear the "unreleased" string in BuildMetadata ifneq ($(GIT_TAG),) - LDFLAGS += -X helm.sh/helm/v3/internal/version.metadata= + VERSION_METADATA = endif + +LDFLAGS += -X helm.sh/helm/v3/internal/version.metadata=${VERSION_METADATA} LDFLAGS += -X helm.sh/helm/v3/internal/version.gitCommit=${GIT_COMMIT} LDFLAGS += -X helm.sh/helm/v3/internal/version.gitTreeState=${GIT_DIRTY} From 6cc039ea79a435c9f335d677b78d9be574b8e770 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 16 Jan 2020 13:54:22 -0700 Subject: [PATCH 182/279] fix: catch one additional discovery client warning (#7176) Signed-off-by: Matt Butcher --- pkg/action/action.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 16c5d3546..9405cc401 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -167,8 +167,8 @@ func (c *Configuration) releaseContent(name string, version int) (*release.Relea // GetVersionSet retrieves a set of available k8s API versions func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.VersionSet, error) { groups, resources, err := client.ServerGroupsAndResources() - if err != nil { - return chartutil.DefaultVersionSet, err + if err != nil && !discovery.IsGroupDiscoveryFailedError(err) { + return chartutil.DefaultVersionSet, errors.Wrap(err, "could not get apiVersions from Kubernetes") } // FIXME: The Kubernetes test fixture for cli appears to always return nil From 77b900106f923bf1d9b787f5e1d2c6c85be9722f Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 16 Jan 2020 21:29:30 -0500 Subject: [PATCH 183/279] fix(comp): Update based on review comments Signed-off-by: Marc Khouzam --- cmd/helm/flags.go | 3 +-- cmd/helm/root.go | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index b9473a5a7..65575a5c1 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -54,10 +54,9 @@ func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) { // value to the given format pointer func bindOutputFlag(cmd *cobra.Command, varRef *output.Format) { f := cmd.Flags() - f.VarP(newOutputValue(output.Table, varRef), outputFlag, "o", + flag := f.VarPF(newOutputValue(output.Table, varRef), outputFlag, "o", fmt.Sprintf("prints the output in the specified format. Allowed values: %s", strings.Join(output.Formats(), ", "))) - flag := f.Lookup(outputFlag) completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { var formatNames []string for _, format := range output.Formats() { diff --git a/cmd/helm/root.go b/cmd/helm/root.go index a3e4da746..6ce1dcbf4 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -117,7 +117,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string completion.CompDebugln(fmt.Sprintf("About to call kube client for namespaces with timeout of: %d", to)) nsNames := []string{} - // TODO can we request only the namespace with request.prefix? if namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{TimeoutSeconds: &to}); err == nil { for _, ns := range namespaces.Items { if strings.HasPrefix(ns.Name, toComplete) { From 82823a6634be4b43a1130b244ee1a1d9c83a1ec6 Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Fri, 17 Jan 2020 10:39:26 -0500 Subject: [PATCH 184/279] Allow tests to run on s390x (#7096) Signed-off-by: Vivian Kong --- Makefile | 5 +++++ pkg/plugin/plugin_test.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 0a3b08548..7d254e919 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ GOPATH = $(shell go env GOPATH) DEP = $(GOPATH)/bin/dep GOX = $(GOPATH)/bin/gox GOIMPORTS = $(GOPATH)/bin/goimports +ARCH = $(shell uname -p) ACCEPTANCE_DIR:=../acceptance-testing # To specify the subset of acceptance tests to run. '.' means all tests @@ -67,7 +68,11 @@ $(BINDIR)/$(BINNAME): $(SRC) .PHONY: test test: build +ifeq ($(ARCH),s390x) +test: TESTFLAGS += -v +else test: TESTFLAGS += -race -v +endif test: test-style test: test-unit diff --git a/pkg/plugin/plugin_test.go b/pkg/plugin/plugin_test.go index f637eca28..076ae1187 100644 --- a/pkg/plugin/plugin_test.go +++ b/pkg/plugin/plugin_test.go @@ -87,6 +87,7 @@ func TestPlatformPrepareCommand(t *testing.T) { PlatformCommand: []PlatformCommand{ {OperatingSystem: "linux", Architecture: "i386", Command: "echo -n linux-i386"}, {OperatingSystem: "linux", Architecture: "amd64", Command: "echo -n linux-amd64"}, + {OperatingSystem: "linux", Architecture: "s390x", Command: "echo -n linux-s390x"}, {OperatingSystem: "windows", Architecture: "amd64", Command: "echo -n win-64"}, }, }, @@ -98,6 +99,8 @@ func TestPlatformPrepareCommand(t *testing.T) { osStrCmp = "linux-i386" } else if os == "linux" && arch == "amd64" { osStrCmp = "linux-amd64" + } else if os == "linux" && arch == "s390x" { + osStrCmp = "linux-s390x" } else if os == "windows" && arch == "amd64" { osStrCmp = "win-64" } else { From 88f42929d779e145b24dad12657d6984d755dd2c Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Fri, 17 Jan 2020 15:56:56 +0000 Subject: [PATCH 185/279] Remove references to protobuf (#7425) Remove references to protobuf and update description of release object stored representation to Helm v3. Signed-off-by: Martin Hickey --- pkg/chartutil/chartfile_test.go | 1 - pkg/chartutil/doc.go | 4 ++-- pkg/storage/driver/cfgmaps.go | 4 ++-- pkg/storage/driver/secrets.go | 4 ++-- pkg/storage/driver/util.go | 11 +++++------ 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pkg/chartutil/chartfile_test.go b/pkg/chartutil/chartfile_test.go index 9a6e608f6..fb5f15376 100644 --- a/pkg/chartutil/chartfile_test.go +++ b/pkg/chartutil/chartfile_test.go @@ -39,7 +39,6 @@ func verifyChartfile(t *testing.T, f *chart.Metadata, name string) { t.Fatal("Failed verifyChartfile because f is nil") } - // Api instead of API because it was generated via protobuf. if f.APIVersion != chart.APIVersionV1 { t.Errorf("Expected API Version %q, got %q", chart.APIVersionV1, f.APIVersion) } diff --git a/pkg/chartutil/doc.go b/pkg/chartutil/doc.go index efcda2cfa..8f06bcc9a 100644 --- a/pkg/chartutil/doc.go +++ b/pkg/chartutil/doc.go @@ -16,7 +16,7 @@ limitations under the License. /*Package chartutil contains tools for working with charts. -Charts are described in the protocol buffer definition (pkg/proto/charts). +Charts are described in the chart package (pkg/chart). This package provides utilities for serializing and deserializing charts. A chart can be represented on the file system in one of two ways: @@ -38,7 +38,7 @@ For accepting raw compressed tar file data from an io.Reader, the 'loader.LoadArchive()' will read in the data, uncompress it, and unpack it into a Chart. -When creating charts in memory, use the 'helm.sh/helm/pkg/proto/chart' +When creating charts in memory, use the 'helm.sh/helm/pkg/chart' package directly. */ package chartutil // import "helm.sh/helm/v3/pkg/chartutil" diff --git a/pkg/storage/driver/cfgmaps.go b/pkg/storage/driver/cfgmaps.go index 1b630f407..cc2e2416a 100644 --- a/pkg/storage/driver/cfgmaps.go +++ b/pkg/storage/driver/cfgmaps.go @@ -217,14 +217,14 @@ func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) { // newConfigMapsObject constructs a kubernetes ConfigMap object // to store a release. Each configmap data entry is the base64 -// encoded string of a release's binary protobuf encoding. +// encoded gzipped string of a release. // // The following labels are used within each configmap: // // "modifiedAt" - timestamp indicating when this configmap was last modified. (set in Update) // "createdAt" - timestamp indicating when this configmap was created. (set in Create) // "version" - version of the release. -// "status" - status of the release (see proto/hapi/release.status.pb.go for variants) +// "status" - status of the release (see pkg/release/status.go for variants) // "owner" - owner of the configmap, currently "helm". // "name" - name of the release. // diff --git a/pkg/storage/driver/secrets.go b/pkg/storage/driver/secrets.go index dc55cf458..dcb2ecfcf 100644 --- a/pkg/storage/driver/secrets.go +++ b/pkg/storage/driver/secrets.go @@ -198,14 +198,14 @@ func (secrets *Secrets) Delete(key string) (rls *rspb.Release, err error) { // newSecretsObject constructs a kubernetes Secret object // to store a release. Each secret data entry is the base64 -// encoded string of a release's binary protobuf encoding. +// encoded gzipped string of a release. // // The following labels are used within each secret: // // "modifiedAt" - timestamp indicating when this secret was last modified. (set in Update) // "createdAt" - timestamp indicating when this secret was created. (set in Create) // "version" - version of the release. -// "status" - status of the release (see proto/hapi/release.status.pb.go for variants) +// "status" - status of the release (see pkg/release/status.go for variants) // "owner" - owner of the secret, currently "helm". // "name" - name of the release. // diff --git a/pkg/storage/driver/util.go b/pkg/storage/driver/util.go index 6cde74cd3..a87002ab4 100644 --- a/pkg/storage/driver/util.go +++ b/pkg/storage/driver/util.go @@ -31,7 +31,7 @@ var b64 = base64.StdEncoding var magicGzip = []byte{0x1f, 0x8b, 0x08} // encodeRelease encodes a release returning a base64 encoded -// gzipped binary protobuf encoding representation, or error. +// gzipped string representation, or error. func encodeRelease(rls *rspb.Release) (string, error) { b, err := json.Marshal(rls) if err != nil { @@ -50,10 +50,9 @@ func encodeRelease(rls *rspb.Release) (string, error) { return b64.EncodeToString(buf.Bytes()), nil } -// decodeRelease decodes the bytes in data into a release -// type. Data must contain a base64 encoded string of a -// valid protobuf encoding of a release, otherwise -// an error is returned. +// decodeRelease decodes the bytes of data into a release +// type. Data must contain a base64 encoded gzipped string of a +// valid release, otherwise an error is returned. func decodeRelease(data string) (*rspb.Release, error) { // base64 decode string b, err := b64.DecodeString(data) @@ -77,7 +76,7 @@ func decodeRelease(data string) (*rspb.Release, error) { } var rls rspb.Release - // unmarshal protobuf bytes + // unmarshal release object bytes if err := json.Unmarshal(b, &rls); err != nil { return nil, err } From d39543013b4feba87b73e5a7366ad08a75ce884c Mon Sep 17 00:00:00 2001 From: Daniel Poelzleithner Date: Fri, 17 Jan 2020 17:43:38 +0100 Subject: [PATCH 186/279] Use /usr/bin/env for bash After this change, make works on nixos. Signed-off-by: Daniel Poelzleithner --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7d254e919..0f9d6a8a2 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ GOFLAGS := SRC := $(shell find . -type f -name '*.go' -print) # Required for globs to work correctly -SHELL = /bin/bash +SHELL = /usr/bin/env bash GIT_COMMIT = $(shell git rev-parse HEAD) GIT_SHA = $(shell git rev-parse --short HEAD) From 8fe2097ffeb0d5a6d898b6850738c14fdca0991e Mon Sep 17 00:00:00 2001 From: Jakub Bielecki Date: Tue, 17 Dec 2019 05:48:54 +0100 Subject: [PATCH 187/279] fix(kube) only add to scheme.Scheme once Closes #6566 Signed-off-by: Jakub Bielecki --- pkg/kube/client.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index cdd996925..adf195e34 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -57,20 +57,23 @@ type Client struct { Log func(string, ...interface{}) } +var addToScheme sync.Once + // New creates a new Client. func New(getter genericclioptions.RESTClientGetter) *Client { if getter == nil { getter = genericclioptions.NewConfigFlags(true) } // Add CRDs to the scheme. They are missing by default. - if err := apiextv1.AddToScheme(scheme.Scheme); err != nil { - // This should never happen. - panic(err) - } - if err := apiextv1beta1.AddToScheme(scheme.Scheme); err != nil { - // This should never happen. - panic(err) - } + addToScheme.Do(func() { + if err := apiextv1.AddToScheme(scheme.Scheme); err != nil { + // This should never happen. + panic(err) + } + if err := apiextv1beta1.AddToScheme(scheme.Scheme); err != nil { + panic(err) + } + }) return &Client{ Factory: cmdutil.NewFactory(getter), Log: nopLogger, From 559c4053620352f76953a8ef7adbeed50c5fef32 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sun, 19 Jan 2020 15:43:57 -0500 Subject: [PATCH 188/279] fix(test): Remove invalid subcommand in test The 'home' command was removed for v3, so this commit adapts the tests. Having an invalid subcommand does not cause problems currently, but will start causing failures on newer versions of Cobra, which complain on invalid subcommands. Signed-off-by: Marc Khouzam --- cmd/helm/root_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/helm/root_test.go b/cmd/helm/root_test.go index f3eef8b6d..df592a96d 100644 --- a/cmd/helm/root_test.go +++ b/cmd/helm/root_test.go @@ -35,23 +35,23 @@ func TestRootCmd(t *testing.T) { }{ { name: "defaults", - args: "home", + args: "env", }, { name: "with $XDG_CACHE_HOME set", - args: "home", + args: "env", envvars: map[string]string{xdg.CacheHomeEnvVar: "/bar"}, cachePath: "/bar/helm", }, { name: "with $XDG_CONFIG_HOME set", - args: "home", + args: "env", envvars: map[string]string{xdg.ConfigHomeEnvVar: "/bar"}, configPath: "/bar/helm", }, { name: "with $XDG_DATA_HOME set", - args: "home", + args: "env", envvars: map[string]string{xdg.DataHomeEnvVar: "/bar"}, dataPath: "/bar/helm", }, From 804e07300bd1088384eb93c7d83b8d332cbb6572 Mon Sep 17 00:00:00 2001 From: Mike Tougeron Date: Mon, 20 Jan 2020 13:31:26 -0800 Subject: [PATCH 189/279] Render the CRDs to spec files Signed-off-by: Mike Tougeron --- cmd/helm/template.go | 8 +------- pkg/action/install.go | 24 ++++++++++++++++++++---- pkg/action/upgrade.go | 2 +- pkg/chart/chart.go | 27 ++++++++++++++++++++------- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 1c34d7245..b76c4b860 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -62,19 +62,13 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client.Replace = true // Skip the name check client.ClientOnly = !validate client.APIVersions = chartutil.VersionSet(extraAPIs) + client.IncludeCRDs = includeCrds rel, err := runInstall(args, client, valueOpts, out) if err != nil { return err } var manifests bytes.Buffer - - if includeCrds { - for _, f := range rel.Chart.CRDs() { - fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", f.Name, f.Data) - } - } - fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) if !client.DisableHooks { diff --git a/pkg/action/install.go b/pkg/action/install.go index 292a7ec27..37ead9940 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -83,6 +83,7 @@ type Install struct { OutputDir string Atomic bool SkipCRDs bool + IncludeCRDs bool SubNotes bool // APIVersions allows a manual set of supported API Versions to be passed // (for things like templating). These are ignored if ClientOnly is false @@ -111,12 +112,12 @@ func NewInstall(cfg *Configuration) *Install { } } -func (i *Install) installCRDs(crds []*chart.File) error { +func (i *Install) installCRDs(crds []chart.CRD) error { // We do these one file at a time in the order they were read. totalItems := []*resource.Info{} for _, obj := range crds { // Read in the resources - res, err := i.cfg.KubeClient.Build(bytes.NewBuffer(obj.Data), false) + res, err := i.cfg.KubeClient.Build(bytes.NewBuffer(obj.File.Data), false) if err != nil { return errors.Wrapf(err, "failed to install CRD %s", obj.Name) } @@ -217,7 +218,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. rel := i.createRelease(chrt, vals) var manifestDoc *bytes.Buffer - rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.OutputDir, i.SubNotes) + rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.OutputDir, i.SubNotes, i.IncludeCRDs) // Even for errors, attach this if available if manifestDoc != nil { rel.Manifest = manifestDoc.String() @@ -421,7 +422,7 @@ func (i *Install) replaceRelease(rel *release.Release) error { } // renderResources renders the templates in a chart -func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, outputDir string, subNotes bool) ([]*release.Hook, *bytes.Buffer, string, error) { +func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, outputDir string, subNotes bool, includeCrds bool) ([]*release.Hook, *bytes.Buffer, string, error) { hs := []*release.Hook{} b := bytes.NewBuffer(nil) @@ -494,6 +495,21 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values // Aggregate all valid manifests into one big doc. fileWritten := make(map[string]bool) + + if includeCrds { + for _, crd := range ch.CRDs() { + if outputDir == "" { + fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:])) + } else { + err = writeToFile(outputDir, crd.Filename, string(crd.File.Data[:]), fileWritten[crd.Name]) + if err != nil { + return hs, b, "", err + } + fileWritten[crd.Name] = true + } + } + } + for _, m := range manifests { if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index cdc40eaaa..309678ec4 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -161,7 +161,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin return nil, nil, err } - hooks, manifestDoc, notesTxt, err := u.cfg.renderResources(chart, valuesToRender, "", u.SubNotes) + hooks, manifestDoc, notesTxt, err := u.cfg.renderResources(chart, valuesToRender, "", u.SubNotes, false) if err != nil { return nil, nil, err } diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index c3e99eae6..50b25c9b5 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -15,7 +15,10 @@ limitations under the License. package chart -import "strings" +import ( + "path/filepath" + "strings" +) // APIVersionV1 is the API version number for version 1. const APIVersionV1 = "v1" @@ -49,6 +52,15 @@ type Chart struct { dependencies []*Chart } +type CRD struct { + // Name is the File.Name for the crd file + Name string + // Filename is the File obj Name including (sub-)chart.ChartFullPath + Filename string + // File is the File obj for the crd + File *File +} + // SetDependencies replaces the chart dependencies. func (ch *Chart) SetDependencies(charts ...*Chart) { ch.dependencies = nil @@ -117,18 +129,19 @@ func (ch *Chart) AppVersion() string { return ch.Metadata.AppVersion } -// CRDs returns a list of File objects in the 'crds/' directory of a Helm chart. -func (ch *Chart) CRDs() []*File { - files := []*File{} +// CRDs returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts +func (ch *Chart) CRDs() []CRD { + crds := []CRD{} // Find all resources in the crds/ directory for _, f := range ch.Files { if strings.HasPrefix(f.Name, "crds/") { - files = append(files, f) + mycrd := CRD{Name: f.Name, Filename: filepath.Join(ch.ChartFullPath(), f.Name), File: f} + crds = append(crds, mycrd) } } // Get CRDs from dependencies, too. for _, dep := range ch.Dependencies() { - files = append(files, dep.CRDs()...) + crds = append(crds, dep.CRDs()...) } - return files + return crds } From 4eda4fa06d70a26ad8c2e2c4108e00f5c317a5c0 Mon Sep 17 00:00:00 2001 From: zwwhdls Date: Tue, 21 Jan 2020 21:46:34 +0800 Subject: [PATCH 190/279] allow limited recursion in templates Signed-off-by: zwwhdls --- pkg/engine/engine.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index d0261dca2..57ea04ef7 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -83,6 +83,7 @@ type renderable struct { const warnStartDelim = "HELM_ERR_START" const warnEndDelim = "HELM_ERR_END" +const recursionMaxNums = 1000 var warnRegex = regexp.MustCompile(warnStartDelim + `(.*)` + warnEndDelim) @@ -93,19 +94,20 @@ func warnWrap(warn string) string { // initFunMap creates the Engine's FuncMap and adds context-specific functions. func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]renderable) { funcMap := funcMap() - includedNames := make([]string, 0) + includedNames := make(map[string]int) // Add the 'include' function here so we can close over t. funcMap["include"] = func(name string, data interface{}) (string, error) { var buf strings.Builder - for _, n := range includedNames { - if n == name { + if v, ok := includedNames[name]; ok { + if v > recursionMaxNums { return "", errors.Wrapf(fmt.Errorf("unable to execute template"), "rendering template has a nested reference name: %s", name) } + includedNames[name] ++ + } else { + includedNames[name] = 1 } - includedNames = append(includedNames, name) err := t.ExecuteTemplate(&buf, name, data) - includedNames = includedNames[:len(includedNames)-1] return buf.String(), err } From 16a85f757066c44aff6dacd8c598ac7a9d699eaa Mon Sep 17 00:00:00 2001 From: zwwhdls Date: Tue, 21 Jan 2020 22:04:13 +0800 Subject: [PATCH 191/279] fix test-style Signed-off-by: zwwhdls --- pkg/engine/engine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 57ea04ef7..f777c5428 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -103,7 +103,7 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render if v > recursionMaxNums { return "", errors.Wrapf(fmt.Errorf("unable to execute template"), "rendering template has a nested reference name: %s", name) } - includedNames[name] ++ + includedNames[name]++ } else { includedNames[name] = 1 } From 5e3c7d7eb86a9fe6aad9174434415b9c42e78478 Mon Sep 17 00:00:00 2001 From: Anshul Verma Date: Thu, 23 Jan 2020 17:16:18 +0530 Subject: [PATCH 192/279] Friendly error message for non-existent Chart while packaging (#7127) * Fixes #6713 Friedly error message Signed-off-by: Anshul Verma * Fixes #6713 Friedly error message Signed-off-by: Anshul Verma * chaging error to no such file or directory Signed-off-by: Anshul Verma * changed it for the wider stat error messages which comes directly from go standard library. Signed-off-by: Anshul Verma * changed it for the wider stat error messages which comes directly from go standard library. Signed-off-by: Anshul Verma --- cmd/helm/package.go | 4 ++++ cmd/helm/package_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/cmd/helm/package.go b/cmd/helm/package.go index 9f7961f95..20cde6e4c 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "io/ioutil" + "os" "path/filepath" "github.com/pkg/errors" @@ -80,6 +81,9 @@ func newPackageCmd(out io.Writer) *cobra.Command { if err != nil { return err } + if _, err := os.Stat(args[i]); err != nil { + return err + } if client.DependencyUpdate { downloadManager := &downloader.Manager{ diff --git a/cmd/helm/package_test.go b/cmd/helm/package_test.go index 739857fa9..38938b4af 100644 --- a/cmd/helm/package_test.go +++ b/cmd/helm/package_test.go @@ -296,6 +296,41 @@ func TestPackageValues(t *testing.T) { } } +func TestNonExistentDirAndBadPermission(t *testing.T) { + nonExistentDir := "testdata/testcharts/non-existent-directory" + + tests := []struct { + name string + flags map[string]string + args []string + expect string + hasfile string + err bool + }{ + { + name: "package testdata/testcharts/non-existent-directory", + args: []string{"testdata/testcharts/non-existent-directory"}, + expect: fmt.Sprintf("stat %s: no such file or directory", nonExistentDir), + err: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var buf bytes.Buffer + c := newPackageCmd(&buf) + re := regexp.MustCompile(tt.expect) + err := c.RunE(c, tt.args) + if err != nil { + if tt.err && re.MatchString(err.Error()) { + return + } + t.Fatalf("%q: expected error %q, got %q", tt.name, tt.expect, err) + } + }) + } +} + func createValuesFile(t *testing.T, data string) string { outputDir := ensure.TempDir(t) From 0beb9f70407bed715e67dc28eaf6e6eb3c3263e1 Mon Sep 17 00:00:00 2001 From: Shota Nakamura <59258152+sukimoyoi@users.noreply.github.com> Date: Mon, 27 Jan 2020 20:00:26 +0900 Subject: [PATCH 193/279] fix(chartutil): remove empty lines and a space from rendered chart templates (#7455) Signed-off-by: sukimoyoi --- pkg/chartutil/create.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 390f12f4c..496f20166 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -304,7 +304,7 @@ kind: ServiceAccount metadata: name: {{ include ".serviceAccountName" . }} labels: -{{ include ".labels" . | nindent 4 }} + {{- include ".labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} @@ -405,7 +405,7 @@ kind: Pod metadata: name: "{{ include ".fullname" . }}-test-connection" labels: -{{ include ".labels" . | nindent 4 }} + {{- include ".labels" . | nindent 4 }} annotations: "helm.sh/hook": test-success spec: @@ -413,7 +413,7 @@ spec: - name: wget image: busybox command: ['wget'] - args: ['{{ include ".fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include ".fullname" . }}:{{ .Values.service.port }}'] restartPolicy: Never ` From 50dcd39ba5a3c50bd046b5b539c2c7e6ac68aea1 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Tue, 10 Dec 2019 13:42:35 -0800 Subject: [PATCH 194/279] fix(package): remove --set, --values, etc. flags These flags snuck in through a feature that was reverted and removed in Helm 2, but snuck into Helm 3. They were never hooked up or used, so they were a no-op. This shouldn't affect anyone. Signed-off-by: Matthew Fisher --- cmd/helm/package.go | 1 - cmd/helm/package_test.go | 170 --------------------------------------- pkg/action/package.go | 6 -- pkg/chartutil/save.go | 23 +++--- 4 files changed, 12 insertions(+), 188 deletions(-) diff --git a/cmd/helm/package.go b/cmd/helm/package.go index 20cde6e4c..00fe0ef11 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -118,7 +118,6 @@ func newPackageCmd(out io.Writer) *cobra.Command { f.StringVar(&client.AppVersion, "app-version", "", "set the appVersion on the chart to this version") f.StringVarP(&client.Destination, "destination", "d", ".", "location to write the chart.") f.BoolVarP(&client.DependencyUpdate, "dependency-update", "u", false, `update dependencies from "Chart.yaml" to dir "charts/" before packaging`) - addValueOptionsFlags(f, valueOpts) return cmd } diff --git a/cmd/helm/package_test.go b/cmd/helm/package_test.go index 38938b4af..e0a5fabd6 100644 --- a/cmd/helm/package_test.go +++ b/cmd/helm/package_test.go @@ -17,13 +17,9 @@ package main import ( "bytes" - "fmt" - "io/ioutil" "os" "path/filepath" "regexp" - "runtime" - "strings" "testing" "github.com/spf13/cobra" @@ -31,15 +27,9 @@ import ( "helm.sh/helm/v3/internal/test/ensure" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" - "helm.sh/helm/v3/pkg/chartutil" ) func TestPackage(t *testing.T) { - statFileMsg := "no such file or directory" - if runtime.GOOS == "windows" { - statFileMsg = "The system cannot find the file specified." - } - tests := []struct { name string flags map[string]string @@ -108,13 +98,6 @@ func TestPackage(t *testing.T) { hasfile: "chart-missing-deps-0.1.0.tgz", err: true, }, - { - name: "package --values does-not-exist", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"values": "does-not-exist"}, - expect: fmt.Sprintf("does-not-exist: %s", statFileMsg), - err: true, - }, { name: "package testdata/testcharts/chart-bad-type", args: []string{"testdata/testcharts/chart-bad-type"}, @@ -213,159 +196,6 @@ func TestSetAppVersion(t *testing.T) { } } -func TestPackageValues(t *testing.T) { - defer resetEnv()() - - repoFile := "testdata/helmhome/helm/repositories.yaml" - - testCases := []struct { - desc string - args []string - valuefilesContents []string - flags map[string]string - expected []string - }{ - { - desc: "helm package, single values file", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"repository-config": repoFile}, - valuefilesContents: []string{"Name: chart-name-foo"}, - expected: []string{"Name: chart-name-foo"}, - }, - { - desc: "helm package, multiple values files", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"repository-config": repoFile}, - valuefilesContents: []string{"Name: chart-name-foo", "foo: bar"}, - expected: []string{"Name: chart-name-foo", "foo: bar"}, - }, - { - desc: "helm package, with set option", - args: []string{"testdata/testcharts/alpine"}, - flags: map[string]string{"set": "Name=chart-name-foo", "repository-config": repoFile}, - expected: []string{"Name: chart-name-foo"}, - }, - { - desc: "helm package, set takes precedence over value file", - args: []string{"testdata/testcharts/alpine"}, - valuefilesContents: []string{"Name: chart-name-foo"}, - flags: map[string]string{"set": "Name=chart-name-bar", "repository-config": repoFile}, - expected: []string{"Name: chart-name-bar"}, - }, - } - - for _, tc := range testCases { - var files []string - for _, contents := range tc.valuefilesContents { - f := createValuesFile(t, contents) - files = append(files, f) - } - valueFiles := strings.Join(files, ",") - - expected, err := chartutil.ReadValues([]byte(strings.Join(tc.expected, "\n"))) - if err != nil { - t.Errorf("unexpected error parsing values: %q", err) - } - - outputDir := ensure.TempDir(t) - - if len(tc.flags) == 0 { - tc.flags = make(map[string]string) - } - tc.flags["destination"] = outputDir - - if len(valueFiles) > 0 { - tc.flags["values"] = valueFiles - } - - cmd := newPackageCmd(&bytes.Buffer{}) - setFlags(cmd, tc.flags) - if err := cmd.RunE(cmd, tc.args); err != nil { - t.Fatalf("unexpected error: %q", err) - } - - outputFile := filepath.Join(outputDir, "alpine-0.1.0.tgz") - verifyOutputChartExists(t, outputFile) - - actual, err := getChartValues(outputFile) - if err != nil { - t.Fatalf("unexpected error extracting chart values: %q", err) - } - - verifyValues(t, actual, expected) - } -} - -func TestNonExistentDirAndBadPermission(t *testing.T) { - nonExistentDir := "testdata/testcharts/non-existent-directory" - - tests := []struct { - name string - flags map[string]string - args []string - expect string - hasfile string - err bool - }{ - { - name: "package testdata/testcharts/non-existent-directory", - args: []string{"testdata/testcharts/non-existent-directory"}, - expect: fmt.Sprintf("stat %s: no such file or directory", nonExistentDir), - err: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var buf bytes.Buffer - c := newPackageCmd(&buf) - re := regexp.MustCompile(tt.expect) - err := c.RunE(c, tt.args) - if err != nil { - if tt.err && re.MatchString(err.Error()) { - return - } - t.Fatalf("%q: expected error %q, got %q", tt.name, tt.expect, err) - } - }) - } -} - -func createValuesFile(t *testing.T, data string) string { - outputDir := ensure.TempDir(t) - - outputFile := filepath.Join(outputDir, "values.yaml") - if err := ioutil.WriteFile(outputFile, []byte(data), 0644); err != nil { - t.Fatalf("err: %s", err) - } - return outputFile -} - -func getChartValues(chartPath string) (chartutil.Values, error) { - chart, err := loader.Load(chartPath) - if err != nil { - return nil, err - } - 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) - } - } -} - -func verifyOutputChartExists(t *testing.T, chartPath string) { - if chartFile, err := os.Stat(chartPath); err != nil { - t.Errorf("expected file %q, got err %q", chartPath, err) - } else if chartFile.Size() == 0 { - t.Errorf("file %q has zero bytes.", chartPath) - } -} - func setFlags(cmd *cobra.Command, flags map[string]string) { dest := cmd.Flags() for f, v := range flags { diff --git a/pkg/action/package.go b/pkg/action/package.go index 5c85ebe0d..b48fc65f0 100644 --- a/pkg/action/package.go +++ b/pkg/action/package.go @@ -60,12 +60,6 @@ func (p *Package) Run(path string, vals map[string]interface{}) (string, error) return "", err } - combinedVals, err := chartutil.CoalesceValues(ch, vals) - if err != nil { - return "", err - } - ch.Values = combinedVals - // If version is set, modify the version. if p.Version != "" { if err := setVersion(ch, p.Version); err != nil { diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index fb985bb59..be0dfdc24 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -50,11 +50,12 @@ func SaveDir(c *chart.Chart, dest string) error { } // Save values.yaml - if c.Values != nil { - vf := filepath.Join(outdir, ValuesfileName) - b, _ := yaml.Marshal(c.Values) - if err := writeFile(vf, b); err != nil { - return err + for _, f := range c.Raw { + if f.Name == ValuesfileName { + vf := filepath.Join(outdir, ValuesfileName) + if err := writeFile(vf, f.Data); err != nil { + return err + } } } @@ -161,12 +162,12 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { } // Save values.yaml - ydata, err := yaml.Marshal(c.Values) - if err != nil { - return err - } - if err := writeToTar(out, filepath.Join(base, ValuesfileName), ydata); err != nil { - return err + for _, f := range c.Raw { + if f.Name == ValuesfileName { + if err := writeToTar(out, filepath.Join(base, ValuesfileName), f.Data); err != nil { + return err + } + } } // Save values.schema.json if it exists From 93adb35af187d00447a67cdd8bdd2fbeaf5c2ccc Mon Sep 17 00:00:00 2001 From: Mike Tougeron Date: Mon, 27 Jan 2020 14:06:06 -0800 Subject: [PATCH 195/279] maintain backwards compatibility in the api for the CRDs function Signed-off-by: Mike Tougeron --- pkg/action/install.go | 4 ++-- pkg/chart/chart.go | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 37ead9940..0f48be6ad 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -168,7 +168,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. // Pre-install anything in the crd/ directory. We do this before Helm // contacts the upstream server and builds the capabilities object. - if crds := chrt.CRDs(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { + if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { // On dry run, bail here if i.DryRun { i.cfg.Log("WARNING: This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") @@ -497,7 +497,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values fileWritten := make(map[string]bool) if includeCrds { - for _, crd := range ch.CRDs() { + for _, crd := range ch.CRDObjects() { if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Name, string(crd.File.Data[:])) } else { diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 50b25c9b5..3ea7ea66f 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -129,8 +129,25 @@ func (ch *Chart) AppVersion() string { return ch.Metadata.AppVersion } -// CRDs returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts -func (ch *Chart) CRDs() []CRD { +// CRDs returns a list of File objects in the 'crds/' directory of a Helm chart. +// Deprecated: use CRDObjects() +func (ch *Chart) CRDs() []*File { + files := []*File{} + // Find all resources in the crds/ directory + for _, f := range ch.Files { + if strings.HasPrefix(f.Name, "crds/") { + files = append(files, f) + } + } + // Get CRDs from dependencies, too. + for _, dep := range ch.Dependencies() { + files = append(files, dep.CRDs()...) + } + return files +} + +// CRDObjects returns a list of CRD objects in the 'crds/' directory of a Helm chart & subcharts +func (ch *Chart) CRDObjects() []CRD { crds := []CRD{} // Find all resources in the crds/ directory for _, f := range ch.Files { @@ -141,7 +158,7 @@ func (ch *Chart) CRDs() []CRD { } // Get CRDs from dependencies, too. for _, dep := range ch.Dependencies() { - crds = append(crds, dep.CRDs()...) + crds = append(crds, dep.CRDObjects()...) } return crds } From a704ba7e203b1ba6336d7b7b4e39094e9079bca0 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 28 Jan 2020 10:58:27 -0500 Subject: [PATCH 196/279] Adding security file This file: - Shows up in the GitHub UI under the new security tab - Points to our common process documented in the community repo. This follows the same pattern we use for the code of conduct Signed-off-by: Matt Farina --- SECURITY.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..c84a6f866 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,3 @@ +# Helm Security Reporting and Policy + +The Helm project has [a common process and policy that can be found here](https://github.com/helm/community/blob/master/SECURITY.md). \ No newline at end of file From 4f4779ca3a456468851f446fd978c4c71563fa96 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 25 Jan 2020 12:42:21 -0500 Subject: [PATCH 197/279] fix(comp): Allow zsh completion to handle -n flag When doing zsh completion, the -n flag would not be handled properly. Doing helm -n would not add the space after the -n. This was caused by the fact that the -n flag was being swallowed by the echo command. To fix this, we use printf instead. Signed-off-by: Marc Khouzam --- cmd/helm/completion.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/helm/completion.go b/cmd/helm/completion.go index a44140d9f..1601cb448 100644 --- a/cmd/helm/completion.go +++ b/cmd/helm/completion.go @@ -139,7 +139,10 @@ __helm_compgen() { fi for w in "${completions[@]}"; do if [[ "${w}" = "$1"* ]]; then - echo "${w}" + # Use printf instead of echo beause it is possible that + # the value to print is -n, which would be interpreted + # as a flag to echo + printf "%s\n" "${w}" fi done } From 8d566c0aded8cc4ab57d6e4d27e121ea836d2ef0 Mon Sep 17 00:00:00 2001 From: Ilya Shaisultanov Date: Wed, 29 Jan 2020 10:27:33 +0100 Subject: [PATCH 198/279] When no resources were created, do not try to clean them up Fixes #7481 Signed-off-by: Ilya Shaisultanov --- pkg/action/upgrade.go | 2 +- pkg/action/upgrade_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index cdc40eaaa..1db4184ff 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -291,7 +291,7 @@ func (u *Upgrade) failRelease(rel *release.Release, created kube.ResourceList, e rel.Info.Status = release.StatusFailed rel.Info.Description = msg u.cfg.recordRelease(rel) - if u.CleanupOnFail { + if u.CleanupOnFail && len(created) > 0 { u.cfg.Log("Cleanup on fail set, cleaning up %d resources", len(created)) _, errs := u.cfg.KubeClient.Delete(created) if errs != nil { diff --git a/pkg/action/upgrade_test.go b/pkg/action/upgrade_test.go index e7bfeefc5..f25d115c4 100644 --- a/pkg/action/upgrade_test.go +++ b/pkg/action/upgrade_test.go @@ -60,6 +60,31 @@ func TestUpgradeRelease_Wait(t *testing.T) { is.Equal(res.Info.Status, release.StatusFailed) } +func TestUpgradeRelease_CleanupOnFail(t *testing.T) { + is := assert.New(t) + req := require.New(t) + + upAction := upgradeAction(t) + rel := releaseStub() + rel.Name = "come-fail-away" + rel.Info.Status = release.StatusDeployed + upAction.cfg.Releases.Create(rel) + + failer := upAction.cfg.KubeClient.(*kubefake.FailingKubeClient) + failer.WaitError = fmt.Errorf("I timed out") + failer.DeleteError = fmt.Errorf("I tried to delete nil") + upAction.cfg.KubeClient = failer + upAction.Wait = true + upAction.CleanupOnFail = true + vals := map[string]interface{}{} + + res, err := upAction.Run(rel.Name, buildChart(), vals) + req.Error(err) + is.NotContains(err.Error(), "unable to cleanup resources") + is.Contains(res.Info.Description, "I timed out") + is.Equal(res.Info.Status, release.StatusFailed) +} + func TestUpgradeRelease_Atomic(t *testing.T) { is := assert.New(t) req := require.New(t) From 1d79ed2c189da65315a597d51a92f0213f224126 Mon Sep 17 00:00:00 2001 From: LongKB Date: Thu, 30 Jan 2020 18:19:10 +0700 Subject: [PATCH 199/279] Fix some spelling errors in comment (#7492) Although it is spelling mistakes, it might make an affects while reading. Signed-off-by: Kim Bao Long --- pkg/action/list.go | 2 +- pkg/getter/getter.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/action/list.go b/pkg/action/list.go index 5d3417203..5be60ac42 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -26,7 +26,7 @@ import ( // ListStates represents zero or more status codes that a list item may have set // -// Because this is used as a bitmask filter, more than one one bit can be flipped +// Because this is used as a bitmask filter, more than one bit can be flipped // in the ListStates. type ListStates uint diff --git a/pkg/getter/getter.go b/pkg/getter/getter.go index e11dbfcae..68638c2ca 100644 --- a/pkg/getter/getter.go +++ b/pkg/getter/getter.go @@ -64,7 +64,7 @@ func WithUserAgent(userAgent string) Option { } } -// WithTLSClientConfig sets the client client auth with the provided credentials. +// WithTLSClientConfig sets the client auth with the provided credentials. func WithTLSClientConfig(certFile, keyFile, caFile string) Option { return func(opts *options) { opts.certFile = certFile From e483dce2895dd23400816b7852405edbf726e396 Mon Sep 17 00:00:00 2001 From: Lee Bontecou Date: Thu, 30 Jan 2020 05:24:09 -0600 Subject: [PATCH 200/279] fix(template): helm template "--show-only" flag producing duplicates when flag used more than once (#7204) * bugfix template show-only duplicates Signed-off-by: Lee Bontecou * 7203 - add unittests Signed-off-by: Lee Bontecou * attempt formatting fix Signed-off-by: Lee Bontecou * gofmt-ed with -s Signed-off-by: Lee Bontecou * goimports-ed with -local helm.sh/helm/v3 and gofmt-ed with -s -w Signed-off-by: Lee Bontecou * Update template_test.go Signed-off-by: Lee Bontecou * Update template_test.go Signed-off-by: Lee Bontecou --- cmd/helm/template.go | 6 +-- cmd/helm/template_test.go | 10 +++++ .../output/template-show-only-multiple.txt | 39 +++++++++++++++++++ .../output/template-show-only-one.txt | 22 +++++++++++ go.mod | 1 + go.sum | 9 +++++ 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 cmd/helm/testdata/output/template-show-only-multiple.txt create mode 100644 cmd/helm/testdata/output/template-show-only-one.txt diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 1c34d7245..dc62c6e95 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -112,9 +112,9 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if missing { return fmt.Errorf("could not find template %s in chart", f) } - for _, m := range manifestsToRender { - fmt.Fprintf(out, "---\n%s\n", m) - } + } + for _, m := range manifestsToRender { + fmt.Fprintf(out, "---\n%s\n", m) } } else { fmt.Fprintf(out, "%s", manifests.String()) diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 35a8e996b..dc7987d01 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -84,6 +84,16 @@ func TestTemplateCmd(t *testing.T) { cmd: fmt.Sprintf("template '%s' --include-crds", chartPath), golden: "output/template-with-crds.txt", }, + { + name: "template with show-only one", + cmd: fmt.Sprintf("template '%s' --show-only templates/service.yaml", chartPath), + golden: "output/template-show-only-one.txt", + }, + { + name: "template with show-only multiple", + cmd: fmt.Sprintf("template '%s' --show-only templates/service.yaml --show-only charts/subcharta/templates/service.yaml", chartPath), + golden: "output/template-show-only-multiple.txt", + }, { name: "sorted output of manifests (order of filenames, then order of objects within each YAML file)", cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/object-order"), diff --git a/cmd/helm/testdata/output/template-show-only-multiple.txt b/cmd/helm/testdata/output/template-show-only-multiple.txt new file mode 100644 index 000000000..abb9a2e10 --- /dev/null +++ b/cmd/helm/testdata/output/template-show-only-multiple.txt @@ -0,0 +1,39 @@ +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "RELEASE-NAME" + kube-version/major: "1" + kube-version/minor: "16" + kube-version/version: "v1.16.0" + kube-api-version/test: v1 +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app.kubernetes.io/name: subchart1 +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + helm.sh/chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app.kubernetes.io/name: subcharta diff --git a/cmd/helm/testdata/output/template-show-only-one.txt b/cmd/helm/testdata/output/template-show-only-one.txt new file mode 100644 index 000000000..f0dd0834e --- /dev/null +++ b/cmd/helm/testdata/output/template-show-only-one.txt @@ -0,0 +1,22 @@ +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + helm.sh/chart: "subchart1-0.1.0" + app.kubernetes.io/instance: "RELEASE-NAME" + kube-version/major: "1" + kube-version/minor: "16" + kube-version/version: "v1.16.0" + kube-api-version/test: v1 +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app.kubernetes.io/name: subchart1 diff --git a/go.mod b/go.mod index c7b25ac13..626df86bb 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,7 @@ require ( golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 // indirect golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + golang.org/x/tools v0.0.0-20191218225520-84f0c7cf60ea // indirect google.golang.org/appengine v1.6.5 // indirect google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect google.golang.org/grpc v1.24.0 // indirect diff --git a/go.sum b/go.sum index 312152e1f..914ccd116 100644 --- a/go.sum +++ b/go.sum @@ -520,6 +520,7 @@ golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 h1:ZC1Xn5A1nlpSmQCIva4bZ3ob3lmhYIefc+GU+DLg1Ow= golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -532,6 +533,7 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -549,6 +551,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68= +golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -609,6 +613,11 @@ golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191218225520-84f0c7cf60ea h1:mtRJM/ln5qwEigajtnZtuARALEPOooGf5lwkM5a9tt4= +golang.org/x/tools v0.0.0-20191218225520-84f0c7cf60ea/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 45d986327a544689d9199b2d71183d7d9f21e696 Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Thu, 30 Jan 2020 12:00:57 +0000 Subject: [PATCH 201/279] Tidy up go dependencies (#7494) Signed-off-by: Martin Hickey --- go.mod | 1 - go.sum | 9 --------- 2 files changed, 10 deletions(-) diff --git a/go.mod b/go.mod index 626df86bb..c7b25ac13 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,6 @@ require ( golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 // indirect golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect - golang.org/x/tools v0.0.0-20191218225520-84f0c7cf60ea // indirect google.golang.org/appengine v1.6.5 // indirect google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect google.golang.org/grpc v1.24.0 // indirect diff --git a/go.sum b/go.sum index 914ccd116..312152e1f 100644 --- a/go.sum +++ b/go.sum @@ -520,7 +520,6 @@ golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 h1:ZC1Xn5A1nlpSmQCIva4bZ3ob3lmhYIefc+GU+DLg1Ow= golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -533,7 +532,6 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -551,8 +549,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68= -golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -613,11 +609,6 @@ golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20191218225520-84f0c7cf60ea h1:mtRJM/ln5qwEigajtnZtuARALEPOooGf5lwkM5a9tt4= -golang.org/x/tools v0.0.0-20191218225520-84f0c7cf60ea/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From d70b50b3a11b62efe942d0429d1d7c54f8656a52 Mon Sep 17 00:00:00 2001 From: Jon Huhn Date: Thu, 30 Jan 2020 09:50:59 -0600 Subject: [PATCH 202/279] Fix typo Signed-off-by: Jon Huhn --- pkg/chart/chart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index c3e99eae6..5eb4d4d94 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -33,7 +33,7 @@ type Chart struct { Raw []*File `json:"-"` // Metadata is the contents of the Chartfile. Metadata *Metadata `json:"metadata"` - // LocK is the contents of Chart.lock. + // Lock is the contents of Chart.lock. Lock *Lock `json:"lock"` // Templates for this chart. Templates []*File `json:"templates"` From 1b1d6bba9cec81a6bbc77dd948779a45bc8a63c8 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 27 Jan 2020 14:44:12 -0800 Subject: [PATCH 203/279] fix(lookup_func): do not return error when object is not found Signed-off-by: Matthew Fisher --- pkg/engine/lookup_func.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 14f2351b4..5dde29443 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/discovery" @@ -30,6 +31,8 @@ import ( type lookupFunc = func(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) +// NewLookupFunction returns a function for looking up objects in the cluster. If the resource does not exist, no error +// is raised. func NewLookupFunction(config *rest.Config) lookupFunc { return func(apiversion string, resource string, namespace string, name string) (map[string]interface{}, error) { var client dynamic.ResourceInterface @@ -43,9 +46,14 @@ func NewLookupFunction(config *rest.Config) lookupFunc { client = c } if name != "" { - //this will return a single object + // this will return a single object obj, err := client.Get(name, metav1.GetOptions{}) if err != nil { + if apierrors.IsNotFound(err) { + // Just return an empty interface when the object was not found. + // That way, users can use `if not (lookup ...)` in their templates. + return map[string]interface{}{}, nil + } return map[string]interface{}{}, err } return obj.UnstructuredContent(), nil @@ -53,6 +61,11 @@ func NewLookupFunction(config *rest.Config) lookupFunc { //this will return a list obj, err := client.List(metav1.ListOptions{}) if err != nil { + if apierrors.IsNotFound(err) { + // Just return an empty interface when the object was not found. + // That way, users can use `if not (lookup ...)` in their templates. + return map[string]interface{}{}, nil + } return map[string]interface{}{}, err } return obj.UnstructuredContent(), nil From 9a790c21dd868d43df06216badb4c638f74b2fdd Mon Sep 17 00:00:00 2001 From: Nick Lee Date: Thu, 30 Jan 2020 15:37:16 -0500 Subject: [PATCH 204/279] style(cmd/lint): removed slash in subcharts fp Signed-off-by: Nick Lee --- cmd/helm/lint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index b53309b20..bc0d1852b 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -55,7 +55,7 @@ func newLintCmd(out io.Writer) *cobra.Command { } if client.WithSubcharts { for _, p := range paths { - filepath.Walk(filepath.Join(p, "/charts"), func(path string, info os.FileInfo, err error) error { + filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, err error) error { if info != nil { if info.Name() == "Chart.yaml" { paths = append(paths, filepath.Dir(path)) From df20164cd27f12d8f4cadda608ca1caea5c25759 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Fri, 31 Jan 2020 04:59:35 -0500 Subject: [PATCH 205/279] Fix tests on arm64 and ppc64le (#7500) Signed-off-by: Yaakov Selkowitz --- pkg/plugin/plugin_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/plugin/plugin_test.go b/pkg/plugin/plugin_test.go index 076ae1187..c869e4c86 100644 --- a/pkg/plugin/plugin_test.go +++ b/pkg/plugin/plugin_test.go @@ -87,6 +87,8 @@ func TestPlatformPrepareCommand(t *testing.T) { PlatformCommand: []PlatformCommand{ {OperatingSystem: "linux", Architecture: "i386", Command: "echo -n linux-i386"}, {OperatingSystem: "linux", Architecture: "amd64", Command: "echo -n linux-amd64"}, + {OperatingSystem: "linux", Architecture: "arm64", Command: "echo -n linux-arm64"}, + {OperatingSystem: "linux", Architecture: "ppc64le", Command: "echo -n linux-ppc64le"}, {OperatingSystem: "linux", Architecture: "s390x", Command: "echo -n linux-s390x"}, {OperatingSystem: "windows", Architecture: "amd64", Command: "echo -n win-64"}, }, @@ -99,6 +101,10 @@ func TestPlatformPrepareCommand(t *testing.T) { osStrCmp = "linux-i386" } else if os == "linux" && arch == "amd64" { osStrCmp = "linux-amd64" + } else if os == "linux" && arch == "arm64" { + osStrCmp = "linux-arm64" + } else if os == "linux" && arch == "ppc64le" { + osStrCmp = "linux-ppc64le" } else if os == "linux" && arch == "s390x" { osStrCmp = "linux-s390x" } else if os == "windows" && arch == "amd64" { From 6cfcc96cea4344b9b1003eafbf4cbe670494d5b0 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Sat, 1 Feb 2020 14:26:50 +0530 Subject: [PATCH 206/279] fix(test) use newly created index instead of ignoring it Signed-off-by: Karuppiah Natarajan --- cmd/helm/repo_index_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/helm/repo_index_test.go b/cmd/helm/repo_index_test.go index 51c5db80a..e04ae1b59 100644 --- a/cmd/helm/repo_index_test.go +++ b/cmd/helm/repo_index_test.go @@ -119,7 +119,7 @@ func TestRepoIndexCmd(t *testing.T) { t.Error(err) } - _, err = repo.LoadIndexFile(destIndex) + index, err = repo.LoadIndexFile(destIndex) if err != nil { t.Fatal(err) } @@ -130,8 +130,8 @@ func TestRepoIndexCmd(t *testing.T) { } vs = index.Entries["compressedchart"] - if len(vs) != 3 { - t.Errorf("expected 3 versions, got %d: %#v", len(vs), vs) + if len(vs) != 1 { + t.Errorf("expected 1 versions, got %d: %#v", len(vs), vs) } expectedVersion = "0.3.0" From d03db32c250bc7906c9d4b0e0858b0412c55dfcf Mon Sep 17 00:00:00 2001 From: Florian Hopfensperger Date: Mon, 3 Feb 2020 11:10:52 +0100 Subject: [PATCH 207/279] fixed dependencies processing in case of helm install or upgrade for disabled/enabled sub charts Signed-off-by: Florian Hopfensperger --- pkg/chartutil/dependencies.go | 11 +++++++ pkg/chartutil/dependencies_test.go | 30 ++++++++++++++++++ .../parent-chart/Chart.lock | 9 ++++++ .../parent-chart/Chart.yaml | 22 +++++++++++++ .../parent-chart/charts/dev-v0.1.0.tgz | Bin 0 -> 333 bytes .../parent-chart/charts/prod-v0.1.0.tgz | Bin 0 -> 336 bytes .../parent-chart/envs/dev/Chart.yaml | 4 +++ .../parent-chart/envs/dev/values.yaml | 9 ++++++ .../parent-chart/envs/prod/Chart.yaml | 4 +++ .../parent-chart/envs/prod/values.yaml | 9 ++++++ .../parent-chart/templates/autoscaler.yaml | 16 ++++++++++ .../parent-chart/values.yaml | 10 ++++++ 12 files changed, 124 insertions(+) create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/prod-v0.1.0.tgz create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml create mode 100644 pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml diff --git a/pkg/chartutil/dependencies.go b/pkg/chartutil/dependencies.go index 4b389dc22..8783b89bd 100644 --- a/pkg/chartutil/dependencies.go +++ b/pkg/chartutil/dependencies.go @@ -173,6 +173,14 @@ Loop: cd = append(cd, n) } } + // don't keep disabled charts in metadata + cdMetadata := []*chart.Dependency{} + copy(cdMetadata, c.Metadata.Dependencies[:0]) + for _, n := range c.Metadata.Dependencies { + if _, ok := rm[n.Name]; !ok { + cdMetadata = append(cdMetadata, n) + } + } // recursively call self to process sub dependencies for _, t := range cd { @@ -181,6 +189,9 @@ Loop: return err } } + // set the correct dependencies in metadata + c.Metadata.Dependencies = nil + c.Metadata.Dependencies = append(c.Metadata.Dependencies, cdMetadata...) c.SetDependencies(cd...) return nil diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chartutil/dependencies_test.go index ecd632540..342d7fe87 100644 --- a/pkg/chartutil/dependencies_test.go +++ b/pkg/chartutil/dependencies_test.go @@ -239,6 +239,36 @@ func TestProcessDependencyImportValues(t *testing.T) { } } +func TestProcessDependencyImportValuesForEnabledCharts(t *testing.T) { + c := loadChart(t, "testdata/import-values-from-enabled-subchart/parent-chart") + nameOverride := "parent-chart-prod" + + if err := processDependencyImportValues(c); err != nil { + t.Fatalf("processing import values dependencies %v", err) + } + + if len(c.Dependencies()) != 2 { + t.Fatalf("expected 2 dependencies for this chart, but got %d", len(c.Dependencies())) + } + + if err := processDependencyEnabled(c, c.Values, ""); err != nil { + t.Fatalf("expected no errors but got %q", err) + } + + if len(c.Dependencies()) != 1 { + t.Fatal("expected no changes in dependencies") + } + + if len(c.Metadata.Dependencies) != 1 { + t.Fatalf("expected 1 dependency specified in Chart.yaml, got %d", len(c.Metadata.Dependencies)) + } + + prodDependencyValues := c.Dependencies()[0].Values + if prodDependencyValues["nameOverride"] != nameOverride { + t.Fatalf("dependency chart name should be %s but got %s", nameOverride, prodDependencyValues["nameOverride"]) + } +} + func TestGetAliasDependency(t *testing.T) { c := loadChart(t, "testdata/frobnitz") req := c.Metadata.Dependencies diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock new file mode 100644 index 000000000..b2f17fb39 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: dev + repository: file://envs/dev + version: v0.1.0 +- name: prod + repository: file://envs/prod + version: v0.1.0 +digest: sha256:9403fc24f6cf9d6055820126cf7633b4bd1fed3c77e4880c674059f536346182 +generated: "2020-02-03T10:38:51.180474+01:00" diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml new file mode 100644 index 000000000..24b26d9e5 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: parent-chart +version: v0.1.0 +appVersion: v0.1.0 +dependencies: + - name: dev + repository: "file://envs/dev" + version: ">= 0.0.1" + condition: dev.enabled,global.dev.enabled + tags: + - dev + import-values: + - data + + - name: prod + repository: "file://envs/prod" + version: ">= 0.0.1" + condition: prod.enabled,global.prod.enabled + tags: + - prod + import-values: + - data \ No newline at end of file diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/charts/dev-v0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..d28e1621c86a56affb0617a912930d982ee5d09c GIT binary patch literal 333 zcmV-T0kZxdiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PK}PYr`-Mg>%lY5bWGeZqs!5+TB+M-CZQ2GbE0Y9n>MvEZ~_~beXUgrQc z1sW=VuODc zVQyr3R8em|NM&qo0PK~)YJ)%!hCTZf13f1l6W36$d4NhGy$?F13%a|^u9EiYi-y+X zrIcVxVZX~T{~R1){(qg==KlCX61K0@waFSFA{Kc*RYY7?#Dhw*eUYg{p-|-sX1h%7 z6TnrrSY98ByIH2oEUQmBkeoRjtJ5jyR=-iu i)>JGtn?PqS;UNZ5Boc}Ioc90#0RR69wG({+3;+PL5}8~8 literal 0 HcmV?d00001 diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml new file mode 100644 index 000000000..80a52f538 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: dev +version: v0.1.0 +appVersion: v0.1.0 \ No newline at end of file diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml new file mode 100644 index 000000000..38f03484d --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/dev/values.yaml @@ -0,0 +1,9 @@ +# Dev values parent-chart +nameOverride: parent-chart-dev +exports: + data: + resources: + autoscaler: + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml new file mode 100644 index 000000000..bda4be458 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: prod +version: v0.1.0 +appVersion: v0.1.0 \ No newline at end of file diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml new file mode 100644 index 000000000..10cc756b2 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/envs/prod/values.yaml @@ -0,0 +1,9 @@ +# Prod values parent-chart +nameOverride: parent-chart-prod +exports: + data: + resources: + autoscaler: + minReplicas: 2 + maxReplicas: 5 + targetCPUUtilizationPercentage: 90 diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml new file mode 100644 index 000000000..976e5a8f1 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/templates/autoscaler.yaml @@ -0,0 +1,16 @@ +################################################################################################### +# parent-chart horizontal pod autoscaler +################################################################################################### +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }}-autoscaler + namespace: {{ .Release.Namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1beta1 + kind: Deployment + name: {{ .Release.Name }} + minReplicas: {{ required "A valid .Values.resources.autoscaler.minReplicas entry required!" .Values.resources.autoscaler.minReplicas }} + maxReplicas: {{ required "A valid .Values.resources.autoscaler.maxReplicas entry required!" .Values.resources.autoscaler.maxReplicas }} + targetCPUUtilizationPercentage: {{ required "A valid .Values.resources.autoscaler.targetCPUUtilizationPercentage!" .Values.resources.autoscaler.targetCPUUtilizationPercentage }} \ No newline at end of file diff --git a/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml new file mode 100644 index 000000000..b812f0a33 --- /dev/null +++ b/pkg/chartutil/testdata/import-values-from-enabled-subchart/parent-chart/values.yaml @@ -0,0 +1,10 @@ +# Default values for parent-chart. +nameOverride: parent-chart +tags: + dev: false + prod: true +resources: + autoscaler: + minReplicas: 0 + maxReplicas: 0 + targetCPUUtilizationPercentage: 99 \ No newline at end of file From 1897d4d60a387f4b516c2382b5ae2f36abde844c Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sun, 2 Feb 2020 15:10:32 -0500 Subject: [PATCH 208/279] fix(tests): Make tests pass on MacOS This newly added tests was failing on MacOS because /proc does not exist. This commit replaces /proc with /tmp to achieve the same result. Signed-off-by: Marc Khouzam --- internal/resolver/resolver_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/resolver/resolver_test.go b/internal/resolver/resolver_test.go index d93d616ee..bb3d3e6ac 100644 --- a/internal/resolver/resolver_test.go +++ b/internal/resolver/resolver_test.go @@ -227,8 +227,8 @@ func TestGetLocalPath(t *testing.T) { }{ { name: "absolute path", - repo: "file:////proc", - expect: "/proc", + repo: "file:////tmp", + expect: "/tmp", }, { name: "relative path", From 084ab20f671438ac92d37d8a084735975562cbed Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Tue, 4 Feb 2020 17:27:38 +0100 Subject: [PATCH 209/279] feat(template): Allow template output to use release name (#7503) * Allow template output to use release name helm template output command uses the chart name only when writing templates to disk. This changes will also use the release name to avoid colloiding the path when output nore than one release of smae chart. Signed-off-by: Martin Hickey * Update after review Comment: - https://github.com/helm/helm/pull/7503/files#r374130090 Signed-off-by: Martin Hickey --- cmd/helm/template.go | 1 + pkg/action/install.go | 13 ++++++++++--- pkg/action/install_test.go | 40 ++++++++++++++++++++++++++++++++++++++ pkg/action/upgrade.go | 2 +- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index dc62c6e95..36c029e69 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -137,6 +137,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&includeCrds, "include-crds", false, "include CRDs in the templated output") f.BoolVar(&client.IsUpgrade, "is-upgrade", false, "set .Release.IsUpgrade instead of .Release.IsInstall") f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") + f.BoolVar(&client.UseReleaseName, "release-name", false, "use release name in the output-dir path.") return cmd } diff --git a/pkg/action/install.go b/pkg/action/install.go index 292a7ec27..80bd9c88f 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -89,6 +89,9 @@ type Install struct { APIVersions chartutil.VersionSet // Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false IsUpgrade bool + // Used by helm template to add the release as part of OutputDir path + // OutputDir/ + UseReleaseName bool } // ChartPathOptions captures common options used for controlling chart paths @@ -217,7 +220,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. rel := i.createRelease(chrt, vals) var manifestDoc *bytes.Buffer - rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.OutputDir, i.SubNotes) + rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.ReleaseName, i.OutputDir, i.SubNotes, i.UseReleaseName) // Even for errors, attach this if available if manifestDoc != nil { rel.Manifest = manifestDoc.String() @@ -421,7 +424,7 @@ func (i *Install) replaceRelease(rel *release.Release) error { } // renderResources renders the templates in a chart -func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, outputDir string, subNotes bool) ([]*release.Hook, *bytes.Buffer, string, error) { +func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName string, outputDir string, subNotes, useReleaseName bool) ([]*release.Hook, *bytes.Buffer, string, error) { hs := []*release.Hook{} b := bytes.NewBuffer(nil) @@ -498,7 +501,11 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values if outputDir == "" { fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) } else { - err = writeToFile(outputDir, m.Name, m.Content, fileWritten[m.Name]) + newDir := outputDir + if useReleaseName { + newDir = filepath.Join(outputDir, releaseName) + } + err = writeToFile(newDir, m.Name, m.Content, fileWritten[m.Name]) if err != nil { return hs, b, "", err } diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index d6f1c88cd..ba350819d 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -471,6 +471,46 @@ func TestInstallReleaseOutputDir(t *testing.T) { is.True(os.IsNotExist(err)) } +func TestInstallOutputDirWithReleaseName(t *testing.T) { + is := assert.New(t) + instAction := installAction(t) + vals := map[string]interface{}{} + + dir, err := ioutil.TempDir("", "output-dir") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) + + instAction.OutputDir = dir + instAction.UseReleaseName = true + instAction.ReleaseName = "madra" + + newDir := filepath.Join(dir, instAction.ReleaseName) + + _, err = instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals) + if err != nil { + t.Fatalf("Failed install: %s", err) + } + + _, err = os.Stat(filepath.Join(newDir, "hello/templates/goodbye")) + is.NoError(err) + + _, err = os.Stat(filepath.Join(newDir, "hello/templates/hello")) + is.NoError(err) + + _, err = os.Stat(filepath.Join(newDir, "hello/templates/with-partials")) + is.NoError(err) + + _, err = os.Stat(filepath.Join(newDir, "hello/templates/rbac")) + is.NoError(err) + + test.AssertGoldenFile(t, filepath.Join(newDir, "hello/templates/rbac"), "rbac.txt") + + _, err = os.Stat(filepath.Join(newDir, "hello/templates/empty")) + is.True(os.IsNotExist(err)) +} + func TestNameAndChart(t *testing.T) { is := assert.New(t) instAction := installAction(t) diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 1db4184ff..ad3a235e6 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -161,7 +161,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin return nil, nil, err } - hooks, manifestDoc, notesTxt, err := u.cfg.renderResources(chart, valuesToRender, "", u.SubNotes) + hooks, manifestDoc, notesTxt, err := u.cfg.renderResources(chart, valuesToRender, "", "", u.SubNotes, false) if err != nil { return nil, nil, err } From 7ce29e12fa8ac7195613ffa1a76b2914150ff756 Mon Sep 17 00:00:00 2001 From: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> Date: Tue, 4 Feb 2020 13:54:13 -0600 Subject: [PATCH 210/279] ref(go.mod): oras v0.8.1 (#6862) * ref(go.mod): oras v0.8.1 Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> * update various module versions Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> * upgrade oras v0.8.1 Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> * upgrade to oras 0.8.1 release Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> * lock to oras release (0.8.1) Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> --- go.mod | 71 +--- go.sum | 374 ++++++++---------- internal/experimental/registry/client.go | 3 +- internal/experimental/registry/client_test.go | 3 +- pkg/action/action_test.go | 3 +- 5 files changed, 194 insertions(+), 260 deletions(-) diff --git a/go.mod b/go.mod index c7b25ac13..696c2b6d2 100644 --- a/go.mod +++ b/go.mod @@ -4,79 +4,42 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 - github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e // indirect github.com/Masterminds/semver/v3 v3.0.3 github.com/Masterminds/sprig/v3 v3.0.2 - github.com/Masterminds/vcs v1.13.0 - github.com/Microsoft/go-winio v0.4.12 // indirect - github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a - github.com/containerd/containerd v1.3.0 + github.com/Masterminds/vcs v1.13.1 + github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 + github.com/containerd/containerd v1.3.2 github.com/cyphar/filepath-securejoin v0.2.2 - github.com/deislabs/oras v0.7.0 + github.com/deislabs/oras v0.8.1 github.com/docker/distribution v2.7.1+incompatible - github.com/docker/docker v1.4.2-0.20181221150755-2cb26cfe9cbf + github.com/docker/docker v1.4.2-0.20200203170920-46ec8731fbce github.com/docker/go-units v0.4.0 - github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect - github.com/emicklei/go-restful v2.11.1+incompatible // indirect github.com/evanphx/json-patch v4.5.0+incompatible - github.com/go-openapi/spec v0.19.4 // indirect github.com/gobwas/glob v0.2.3 github.com/gofrs/flock v0.7.1 - github.com/gogo/protobuf v1.3.1 // indirect - github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect - github.com/google/go-cmp v0.3.1 // indirect - github.com/googleapis/gnostic v0.3.1 // indirect - github.com/gosuri/uitable v0.0.1 - github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect - github.com/hashicorp/golang-lru v0.5.3 // indirect - github.com/imdario/mergo v0.3.8 // indirect - github.com/mattn/go-runewidth v0.0.4 // indirect - github.com/mattn/go-shellwords v1.0.5 + github.com/gosuri/uitable v0.0.4 + github.com/mattn/go-shellwords v1.0.9 github.com/mitchellh/copystructure v1.0.0 github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/image-spec v1.0.1 - github.com/pkg/errors v0.8.1 - github.com/prometheus/client_golang v1.2.1 // indirect + github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.4.2 github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 - github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.1.0 - github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656 // indirect - golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 - golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 // indirect - golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 // indirect - golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect - google.golang.org/appengine v1.6.5 // indirect - google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 // indirect - google.golang.org/grpc v1.24.0 // indirect - k8s.io/api v0.17.1 - k8s.io/apiextensions-apiserver v0.17.1 - k8s.io/apimachinery v0.17.1 - k8s.io/cli-runtime v0.17.1 - k8s.io/client-go v0.17.1 + golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d + k8s.io/api v0.17.2 + k8s.io/apiextensions-apiserver v0.17.2 + k8s.io/apimachinery v0.17.2 + k8s.io/cli-runtime v0.17.2 + k8s.io/client-go v0.17.2 k8s.io/klog v1.0.0 - k8s.io/kubectl v0.17.1 + k8s.io/kubectl v0.17.2 sigs.k8s.io/yaml v1.1.0 ) replace ( - // github.com/Azure/go-autorest/autorest has different versions for the Go - // modules than it does for releases on the repository. Note the correct - // version when updating. - github.com/Azure/go-autorest/autorest => github.com/Azure/go-autorest/autorest v0.9.0 - github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 - - // Kubernetes imports github.com/miekg/dns at a newer version but it is used - // by a package Helm does not need. Go modules resolves all packages rather - // than just those in use (like Glide and dep do). This sets the version - // to the one oras needs. If oras is updated the version should be updated - // as well. - github.com/miekg/dns => github.com/miekg/dns v0.0.0-20181005163659-0d29b283ac0f - gopkg.in/inf.v0 v0.9.1 => github.com/go-inf/inf v0.9.1 - gopkg.in/square/go-jose.v2 v2.3.0 => github.com/square/go-jose v2.3.0+incompatible - - rsc.io/letsencrypt => github.com/dmcgowan/letsencrypt v0.0.0-20160928181947-1847a81d2087 + github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible + github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d ) diff --git a/go.sum b/go.sum index 312152e1f..cc6b8dd9c 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,13 @@ +bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +github.com/Azure/go-autorest v13.3.2+incompatible h1:VxzPyuhtnlBOzc4IWCZHqpyH2d+QMLQEuy3wREyY4oc= +github.com/Azure/go-autorest v13.3.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= @@ -20,23 +24,20 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= -github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e h1:eb0Pzkt15Bm7f2FFYv7sjY7NPFi3cPkS3tv1CcrFBWA= -github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.0.3 h1:znjIyLfpXEDQjOIEWh+ehwpTU14UzUPub3c3sm36u14= github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/sprig/v3 v3.0.2 h1:wz22D0CiSctrliXiI9ZO3HoNApweeRGftyDN+BQa3B8= github.com/Masterminds/sprig/v3 v3.0.2/go.mod h1:oesJ8kPONMONaZgtiHNzUShJbksypC5kWczhZAf6+aU= -github.com/Masterminds/vcs v1.13.0 h1:USF5TvZGYgIpcbNAEMLfFhHqP08tFZVlUVrmTSpqnyA= -github.com/Masterminds/vcs v1.13.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA= -github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc= -github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/hcsshim v0.8.6 h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA= -github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= +github.com/Masterminds/vcs v1.13.1 h1:NL3G1X7/7xduQtA2sJLpVpfHTNBALVNSjob6KEjPXNQ= +github.com/Masterminds/vcs v1.13.1/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA= +github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 h1:ygIc8M6trr62pF5DucadTWGdEB4mEyvzi0e2nbcmcyA= +github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= +github.com/Microsoft/hcsshim v0.8.7 h1:ptnOoufxGSzauVTsdE+wMYnCWA301PdoN4xg5oRdZpg= +github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -49,56 +50,58 @@ github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/O github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= -github.com/blang/semver v3.5.0+incompatible h1:CGxCgetQ64DKk7rdZ++Vfnb1+ogGNnB17OJKJXD2Cfs= +github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bshuster-repo/logrus-logstash-hook v0.4.1 h1:pgAtgj+A31JBVtEHu2uHuEx0n+2ukqUJnS2vVe5pQNA= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= -github.com/bugsnag/bugsnag-go v1.5.0 h1:tP8hiPv1pGGW3LA6LKy5lW6WG+y9J2xWUdPd3WC452k= -github.com/bugsnag/bugsnag-go v1.5.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= -github.com/bugsnag/panicwrap v1.2.0 h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA= -github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= -github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA= -github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= -github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 h1:7aWHqerlJ41y6FOsEUvknqgXnGmJyJSbjhAWq5pO4F8= +github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= +github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= +github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= +github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= +github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= +github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4 h1:aMyA5J7j6D07U7pf8BFEY67BKoDcz0zWleAbQj3zVng= -github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/containerd v1.3.0 h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY= -github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= -github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 h1:4BX8f882bXEDKfWIf0wa8HRvpnBoPszJJXL+TVbBw4M= -github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f h1:tSNMc+rJDfmYntojat8lljbt1mgKNpTxUZJsSzJ9Y1s= +github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= +github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= +github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/containerd v1.3.2 h1:ForxmXkA6tPIvffbrDAcPUIB32QgXkt2XFj+F0UxetA= +github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 h1:kIFnQBO7rQ0XkMe6xEwbybYHBEaWmh/f++laI6Emt7M= +github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41/go.mod h1:Dq467ZllaHgAtVp4p1xUQWBrFXR9s/wyoTpG8zOJGkY= +github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= +github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= +github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= +github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea h1:n2Ltr3SrfQlf/9nOna1DoGKxLx3qTSI8Ttl6Xrqp6mw= github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -110,33 +113,33 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE= -github.com/deislabs/oras v0.7.0 h1:RnDoFd3tQYODMiUqxgQ8JxlrlWL0/VMKIKRD01MmNYk= -github.com/deislabs/oras v0.7.0/go.mod h1:sqMKPG3tMyIX9xwXUBRLhZ24o+uT4y6jgBD2RzUTKDM= +github.com/deislabs/oras v0.8.1 h1:If674KraJVpujYR00rzdi0QAmW4BxzMJPVAZJKuhQ0c= +github.com/deislabs/oras v0.8.1/go.mod h1:Mx0rMSbBNaNfY9hjpccEnxkOqJL6KGjtxNHPLC4G4As= +github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= +github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dmcgowan/letsencrypt v0.0.0-20160928181947-1847a81d2087 h1:8AJxBXuUPcBVAvoz6fi3fpSyozBxvF2DgQ0f/yn9nkE= -github.com/dmcgowan/letsencrypt v0.0.0-20160928181947-1847a81d2087/go.mod h1:pRqVcLnLZeet910LRIAzx73MR48LxCRA84OcsivAkSs= -github.com/docker/cli v0.0.0-20190506213505-d88565df0c2d h1:qdD+BtyCE1XXpDyhvn0yZVcZOLILdj9Cw4pKu0kQbPQ= -github.com/docker/cli v0.0.0-20190506213505-d88565df0c2d/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= -github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker-credential-helpers v0.6.1 h1:Dq4iIfcM7cNtddhLVWe9h4QDjsi4OER3Z8voPu/I52g= -github.com/docker/docker-credential-helpers v0.6.1/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= +github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= +github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 h1:FwssHbCDJD025h+BchanCwE1Q8fyMgqDr2mOQAWOLGw= +github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v0.0.0-20191216044856-a8371794149d h1:jC8tT/S0OGx2cswpeUTn4gOIea8P08lD3VFQT0cOZ50= +github.com/docker/distribution v0.0.0-20191216044856-a8371794149d/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= +github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v1.4.2-0.20200203170920-46ec8731fbce h1:KXS1Jg+ddGcWA8e1N7cupxaHHZhit5rB9tfDU+mfjyY= +github.com/docker/docker v1.4.2-0.20200203170920-46ec8731fbce/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker-credential-helpers v0.6.3 h1:zI2p9+1NQYdnG6sMU26EX4aVGlqbInSQxQXLvzJ4RPQ= +github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 h1:X0fj836zx99zFu83v/M79DuBn84IL/Syx1SY6Y5ZEMA= -github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI= -github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= +github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916 h1:yWHOI+vFjEsAakUTSrtqc/SAHrhSkmn48pqjidZX3QA= +github.com/docker/go-metrics v0.0.0-20180209012529-399ea8c73916/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= -github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= +github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arXfYcAtECDFgAgHklGI8CxgjHnXKJ4= +github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= +github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= -github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e h1:p1yVGRW3nmb85p1Sh1ZJSDm4A4iKLS5QNbvUHMgGu/M= @@ -144,116 +147,95 @@ github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkg github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.11.1+incompatible h1:CjKsv3uWcCMvySPQYKxO8XX3f9zD4FeZRsW4G0B4ffE= -github.com/emicklei/go-restful v2.11.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc= -github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= +github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7 h1:LofdAjjjqCSXMwLGgOgnE+rdPuvX9DxCqaHwKy7i/ko= +github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-inf/inf v0.9.1 h1:F4sloU4SED74gTeM3mWLrf8yyMAgVCV0puw3vhtKWrk= -github.com/go-inf/inf v0.9.1/go.mod h1:ZWwB6rTV+0pO94RdIMKue59tExzQp6/pj/BMuPQkXaA= +github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.19.2 h1:ophLETFestFZHk3ji7niPEL4d466QjW+0Tdg5VyDq7E= github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY= github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.19.2 h1:rf5ArTHmIJxyV5Oiks+Su0mUens1+AjpkPoWr5xFRcI= github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk= github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= -github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.2 h1:SStNd1jRcYtfKCN7R0laGNs80WYYvn5CbBjM2sOmCrE= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= +github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo= -github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.2 h1:jvO6bCMBEilGwMfHhrd61zIID4oIFdwb76V17SM88dE= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= -github.com/go-openapi/validate v0.19.2 h1:ky5l57HjyVRrsJfd2+Ro5Z9PjGuKbsmftwyMtk8H7js= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc= github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= -github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903 h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE= -github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -264,10 +246,9 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -277,32 +258,29 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= -github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/gophercloud/gophercloud v0.1.0 h1:P/nh25+rzXouhytV2pUHBb65fnds26Ghl8/391+sT5o= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA= -github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= -github.com/gorilla/mux v1.7.0 h1:tOSd0UKHQd6urX6ApfOn4XdBMY6Sh1MfxV3kmaazO+U= -github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33 h1:893HsJqtxp9z1SF76gg6hY70hRY1wVlTSnC/h1yUDCo= +github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= +github.com/gorilla/mux v1.7.2 h1:zoNxOV7WjqXptQOVngLmcSQgXmgk4NMz1HibBchjl/I= +github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gosuri/uitable v0.0.1 h1:M9sMNgSZPyAu1FJZJLpJ16ofL8q5ko2EDUkICsynvlY= -github.com/gosuri/uitable v0.0.1/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= +github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= +github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM= -github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -311,22 +289,19 @@ github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63 github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ= -github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro= -github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -346,33 +321,31 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-shellwords v1.0.5 h1:JhhFTIOslh5ZsPrpa3Wdg8bF0WI3b44EMblmU9wIsXc= -github.com/mattn/go-shellwords v1.0.5/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= +github.com/mattn/go-shellwords v1.0.9 h1:eaB5JspOwiKKcHdqcjbfe5lA9cNn/4NRRtddXJCimqk= +github.com/mattn/go-shellwords v1.0.9/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v0.0.0-20181005163659-0d29b283ac0f h1:wVzAD6PG9MIDNQMZ6zc2YpzE/9hhJ3EN+b+a4B1thVs= -github.com/miekg/dns v0.0.0-20181005163659-0d29b283ac0f/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f h1:2+myh5ml7lgEU/51gbeLHfKGNfgEQQIWrlbdaOsidbQ= +github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 h1:cvy4lBOYN3gKfKj8Lzz5Q9TfviP+L7koMHY7SvkyTKs= -github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -380,13 +353,13 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c h1:nXxl5PrvVm2L/wCy8dQu6DMTwH4oIuGN8GJDAlqDdVE= -github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -395,50 +368,47 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= +github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/phayes/freeport v0.0.0-20171002181615-b8543db493a5 h1:rZQtoozkfsiNs36c7Tdv/gyGNzD1X1XWKO8rptVNZuM= -github.com/phayes/freeport v0.0.0-20171002181615-b8543db493a5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= +github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= +github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= +github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.2.1 h1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI= -github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= +github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0 h1:kUZDBDTdBVBYBj5Tmh2NZLlF60mfjA27rM34b+cVwNU= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY= -github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190129233650-316cf8ccfec5 h1:Etei0Wx6pooT/DeOKcGTr1M/01ggz95Ajq8BBwCOKBU= -github.com/prometheus/procfs v0.0.0-20190129233650-316cf8ccfec5/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= @@ -446,23 +416,28 @@ github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uY github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -472,32 +447,30 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 h1:ndzgwNDnKIqyCvHTXaCqh9KlOWKvBry6nuXMJmonVsE= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg= github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= -github.com/xenolf/lego v0.0.0-20160613233155-a9d8cec0e656/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY= -github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656 h1:BTvU+npm3/yjuBd53EvgiFLl5+YLikf2WvHsjRQ4KrY= -github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 h1:p7OofyZ509h8DmPLh8Hn+EIIZm/xYhdZHJ9GnXHdr6U= -github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= -github.com/yvasiyarov/gorelic v0.0.6 h1:qMJQYPNdtJ7UNYHjX38KXZtltKTqimMuoQjNnSVIuJg= -github.com/yvasiyarov/gorelic v0.0.6/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= +github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI= +github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= +github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE= +github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -506,27 +479,27 @@ go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qL go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152 h1:ZC1Xn5A1nlpSmQCIva4bZ3ob3lmhYIefc+GU+DLg1Ow= -golang.org/x/crypto v0.0.0-20191028145041-f83a4685e152/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d h1:9FCpayM9Egr1baVnV1SX0H87m+XB0B8S0hAMi99X/3U= +golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -537,23 +510,21 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 h1:N66aaryRB3Ax92gH0v3hp1QYZ3zWWCCUR/j8Ifh45Ss= -golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= @@ -561,10 +532,10 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -578,25 +549,23 @@ golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934 h1:u/E0NqCIWRDAo9WCFo6Ko49njPFDLSd3z+X1HgWDMpE= -golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3 h1:7TYNF4UdlohbFwpNH04CoPMp1cHUZgO1Ebq5r2hIjfo= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -607,82 +576,80 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485 h1:OB/uP/Puiu5vS5QMRPrXCDWUPb+kt8f1KW8oQzFejQw= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ= +google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8/go.mod h1:0H1ncTHf11KCFhTc/+EFRbzSCOZx+VUbRMk55Yv5MYk= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190128161407-8ac453e89fca/go.mod h1:L3J43x8/uS+qIUoksaLKe6OS3nUKxOKuIFz1sl2/jx4= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7 h1:ZUjXAXmrAyrmmCPHgCA/vChHcpsX27MZ3yBonD/z1KE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 h1:nfPFGzJkUDX6uBmpN/pSw7MbOAWegH5QDQuoXFHedLg= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6 h1:UXl+Zk3jqqcbEVV7ace5lrt4YdA4tXiz3f/KbmD29Vo= -google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= -google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v1 v1.1.2 h1:/5jmADZB+RiKtZGr4HxsEFOEfbfsjTKsVnqpThUpE30= -gopkg.in/square/go-jose.v1 v1.1.2/go.mod h1:QpYS+a4WhS+DTlyQIi6Ka7MS3SuR9a055rgXNEe6EiA= -gopkg.in/square/go-jose.v2 v2.2.2 h1:orlkJ3myw8CN1nVQHBFfloD+L3egixIa4FvUP6RosSA= gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.17.1 h1:i46MidoDOE9tvQ0TTEYggf3ka/pziP1+tHI/GFVeJao= -k8s.io/api v0.17.1/go.mod h1:zxiAc5y8Ngn4fmhWUtSxuUlkfz1ixT7j9wESokELzOg= -k8s.io/apiextensions-apiserver v0.17.1 h1:Gw6zQgmKyyNrFMtVpRBNEKE8p35sDBI7Tq1ImxGS+zU= -k8s.io/apiextensions-apiserver v0.17.1/go.mod h1:DRIFH5x3jalE4rE7JP0MQKby9zdYk9lUJQuMmp+M/L0= -k8s.io/apimachinery v0.17.1 h1:zUjS3szTxoUjTDYNvdFkYt2uMEXLcthcbp+7uZvWhYM= -k8s.io/apimachinery v0.17.1/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apiserver v0.17.1/go.mod h1:BQEUObJv8H6ZYO7DeKI5vb50tjk6paRJ4ZhSyJsiSco= -k8s.io/cli-runtime v0.17.1 h1:VoZRWJNRyrxuM5SIRozYhT/EtcZ6jiS+KBCxRw66p1g= -k8s.io/cli-runtime v0.17.1/go.mod h1:e5847Iy85W9uWH3rZofXTG/9nOUyGKGTVnObYF7zSik= -k8s.io/client-go v0.17.1 h1:LbbuZ5tI7OYx4et5DfRFcJuoojvpYO0c7vps2rgJsHY= -k8s.io/client-go v0.17.1/go.mod h1:HZtHJSC/VuSHcETN9QA5QDZky1tXiYrkF/7t7vRpO1A= -k8s.io/code-generator v0.17.1/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= -k8s.io/component-base v0.17.1 h1:lK/lUzZZQK+DlH0XD+gq610OUEmjWOyDuUYOTGetw10= -k8s.io/component-base v0.17.1/go.mod h1:LrBPZkXtlvGjBzDJa0+b7E5Ij4VoAAKrOGudRC5z2eY= +k8s.io/api v0.17.2 h1:NF1UFXcKN7/OOv1uxdRz3qfra8AHsPav5M93hlV9+Dc= +k8s.io/api v0.17.2/go.mod h1:BS9fjjLc4CMuqfSO8vgbHPKMt5+SF0ET6u/RVDihTo4= +k8s.io/apiextensions-apiserver v0.17.2 h1:cP579D2hSZNuO/rZj9XFRzwJNYb41DbNANJb6Kolpss= +k8s.io/apiextensions-apiserver v0.17.2/go.mod h1:4KdMpjkEjjDI2pPfBA15OscyNldHWdBCfsWMDWAmSTs= +k8s.io/apimachinery v0.17.2 h1:hwDQQFbdRlpnnsR64Asdi55GyCaIP/3WQpMmbNBeWr4= +k8s.io/apimachinery v0.17.2/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= +k8s.io/apiserver v0.17.2/go.mod h1:lBmw/TtQdtxvrTk0e2cgtOxHizXI+d0mmGQURIHQZlo= +k8s.io/cli-runtime v0.17.2 h1:YH4txSplyGudvxjhAJeHEtXc7Tr/16clKGfN076ydGk= +k8s.io/cli-runtime v0.17.2/go.mod h1:aa8t9ziyQdbkuizkNLAw3qe3srSyWh9zlSB7zTqRNPI= +k8s.io/client-go v0.17.2 h1:ndIfkfXEGrNhLIgkr0+qhRguSD3u6DCmonepn1O6NYc= +k8s.io/client-go v0.17.2/go.mod h1:QAzRgsa0C2xl4/eVpeVAZMvikCn8Nm81yqVx3Kk9XYI= +k8s.io/code-generator v0.17.2/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= +k8s.io/component-base v0.17.2 h1:0XHf+cerTvL9I5Xwn9v+0jmqzGAZI7zNydv4tL6Cw6A= +k8s.io/component-base v0.17.2/go.mod h1:zMPW3g5aH7cHJpKYQ/ZsGMcgbsA/VyhEugF3QT1awLs= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20190822140433-26a664648505 h1:ZY6yclUKVbZ+SdWnkfY+Je5vrMpKOxmGeKRbsXVmqYM= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= @@ -690,9 +657,10 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kubectl v0.17.1 h1:+gI5hPZVEXN5wWybrzX3tu3f9af54sUNcALhg86upCY= -k8s.io/kubectl v0.17.1/go.mod h1:ZmbAdEQm+SLA/3s3eWJ3g+liXb5eT6mA85jYj52LMXw= -k8s.io/metrics v0.17.1/go.mod h1:dphDhzjA1KR/nQXtXEQzoQyQXk5ViSJO85Ky8QKwBPM= +k8s.io/kubectl v0.17.2 h1:QZR8Q6lWiVRjwKslekdbN5WPMp53dS/17j5e+oi5XVU= +k8s.io/kubectl v0.17.2/go.mod h1:y4rfLV0n6aPmvbRCqZQjvOp3ezxsFgpqL+zF5jH/lxk= +k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= +k8s.io/metrics v0.17.2/go.mod h1:3TkNHET4ROd+NfzNxkjoVfQ0Ob4iZnaHmSEA4vYpwLw= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= diff --git a/internal/experimental/registry/client.go b/internal/experimental/registry/client.go index d52d9f3e0..f664c9f38 100644 --- a/internal/experimental/registry/client.go +++ b/internal/experimental/registry/client.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "io/ioutil" + "net/http" "sort" auth "github.com/deislabs/oras/pkg/auth/docker" @@ -69,7 +70,7 @@ func NewClient(opts ...ClientOption) (*Client, error) { } } if client.resolver == nil { - resolver, err := client.authorizer.Resolver(context.Background()) + resolver, err := client.authorizer.Resolver(context.Background(), http.DefaultClient, false) if err != nil { return nil, err } diff --git a/internal/experimental/registry/client_test.go b/internal/experimental/registry/client_test.go index 0861c8984..33799f5fa 100644 --- a/internal/experimental/registry/client_test.go +++ b/internal/experimental/registry/client_test.go @@ -23,6 +23,7 @@ import ( "io" "io/ioutil" "net" + "net/http" "os" "path/filepath" "testing" @@ -66,7 +67,7 @@ func (suite *RegistryClientTestSuite) SetupSuite() { client, err := auth.NewClient(credentialsFile) suite.Nil(err, "no error creating auth client") - resolver, err := client.Resolver(context.Background()) + resolver, err := client.Resolver(context.Background(), http.DefaultClient, false) suite.Nil(err, "no error creating resolver") // create cache diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index a5baec97d..df6a48e7f 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -19,6 +19,7 @@ import ( "context" "flag" "io/ioutil" + "net/http" "path/filepath" "testing" @@ -45,7 +46,7 @@ func actionConfigFixture(t *testing.T) *Configuration { t.Fatal(err) } - resolver, err := client.Resolver(context.Background()) + resolver, err := client.Resolver(context.Background(), http.DefaultClient, false) if err != nil { t.Fatal(err) } From a9171fe2caef41acd945120202920db4f8a6b59f Mon Sep 17 00:00:00 2001 From: Thilak Somasundaram Date: Tue, 4 Feb 2020 22:24:57 -0800 Subject: [PATCH 211/279] Create a single shasums.txt Signed-off-by: Thilak Somasundaram --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ec4911fb7..a063c388a 100644 --- a/Makefile +++ b/Makefile @@ -163,8 +163,9 @@ sign: .PHONY: checksum checksum: + if [ -f "_dist/shasums.txt" ]; then >_dist/shasums.txt; fi for f in _dist/*.{gz,zip} ; do \ - shasum -a 256 "$${f}" | sed 's/_dist\///' | tee "$${f}.sha256sum" | awk '{print $$1}' > "$${f}.sha256" ; \ + shasum -a 256 "$${f}" | sed 's/_dist\///' | tee -a "_dist/shasums.txt" | awk '{print $$1}' > "$${f}.sha256" ; \ done # ------------------------------------------------------------------------------ From 691eff46dc729f512629dfe141e37ea3cc24cf78 Mon Sep 17 00:00:00 2001 From: Thilak Somasundaram Date: Tue, 4 Feb 2020 22:34:10 -0800 Subject: [PATCH 212/279] Create a single shasums.txt Signed-off-by: Thilak Somasundaram --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a063c388a..379a7486b 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,7 @@ sign: .PHONY: checksum checksum: - if [ -f "_dist/shasums.txt" ]; then >_dist/shasums.txt; fi + @if [ -f "_dist/shasums.txt" ]; then >_dist/shasums.txt; fi for f in _dist/*.{gz,zip} ; do \ shasum -a 256 "$${f}" | sed 's/_dist\///' | tee -a "_dist/shasums.txt" | awk '{print $$1}' > "$${f}.sha256" ; \ done From 5ec70ab27fbf54ab529984db154953cbf68da78f Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Wed, 5 Feb 2020 09:38:30 +0100 Subject: [PATCH 213/279] fix(chart): lock digest differs when dependency build with Helm 2 and then Helm 3 (#7261) * Fix issue with apiVersion v1 lock digest When apiVersion v1 chart dependencies are built with Helm 2 and then built with Helm 3, the lock digests differ. To avoid this issue, a depdendency update is forced. Signed-off-by: Martin Hickey * Check against Helm v2 hash Handle scenario where dependency hash was generated by Helm v2 but need to do a dependency build with Helm v3. Signed-off-by: Martin Hickey * Add unit test Signed-off-by: Martin Hickey * Refactor unit test Refactor unit test to use an existing chart as dependency Signed-off-by: Martin Hickey * Update after review Comments: - https://github.com/helm/helm/pull/7261#discussion_r373827088 - https://github.com/helm/helm/pull/7261#discussion_r373827250 Signed-off-by: Martin Hickey --- cmd/helm/dependency_build_test.go | 13 +++++++++++ .../testcharts/issue-7233/.helmignore | 22 ++++++++++++++++++ .../testdata/testcharts/issue-7233/Chart.yaml | 5 ++++ .../issue-7233/charts/alpine-0.1.0.tgz | Bin 0 -> 1167 bytes .../testcharts/issue-7233/requirements.lock | 6 +++++ .../testcharts/issue-7233/requirements.yaml | 4 ++++ .../issue-7233/templates/configmap.yaml | 7 ++++++ .../testcharts/issue-7233/values.yaml | 1 + internal/resolver/resolver.go | 16 +++++++++++++ pkg/downloader/manager.go | 13 ++++++++++- 10 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 cmd/helm/testdata/testcharts/issue-7233/.helmignore create mode 100644 cmd/helm/testdata/testcharts/issue-7233/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz create mode 100644 cmd/helm/testdata/testcharts/issue-7233/requirements.lock create mode 100644 cmd/helm/testdata/testcharts/issue-7233/requirements.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-7233/values.yaml diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index 58ef3d3a1..eeca12fa6 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -100,3 +100,16 @@ func TestDependencyBuildCmd(t *testing.T) { t.Errorf("mismatched versions. Expected %q, got %q", "0.1.0", v) } } + +func TestDependencyBuildCmdWithHelmV2Hash(t *testing.T) { + chartName := "testdata/testcharts/issue-7233" + + cmd := fmt.Sprintf("dependency build '%s'", chartName) + _, out, err := executeActionCommand(cmd) + + // Want to make sure the build can verify Helm v2 hash + if err != nil { + t.Logf("Output: %s", out) + t.Fatal(err) + } +} diff --git a/cmd/helm/testdata/testcharts/issue-7233/.helmignore b/cmd/helm/testdata/testcharts/issue-7233/.helmignore new file mode 100644 index 000000000..50af03172 --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-7233/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml b/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml new file mode 100644 index 000000000..b31997acb --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: issue-7233 +version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz b/cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a64d9ed46a25dec2446050321772fc2d1d35417a GIT binary patch literal 1167 zcmV;A1aSKwiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI*zkJ~mA-m`wiK)J@U{EhgwcoX0a+6KY42v8J7J(k86u@tG2 zl(nkk|6Y)kylZWg!7!$MJkRbge~so=5(gf(iGz_kk=_?C(C4hoqDnapVknK6Z44u=`>Jkpta z1_JFTA8vt`rAkOIgTZm~mYJ+vM~Tece7|Vd>JmqzC=OoQS^q+5_`gG5l0H)cc#i+^ zIPUU)F`D%Jzl3~nw9M;4!_1e~ryp+aFSq$YwYL(@PhZ-xeh0+nG&$x*qzER-T$ zNTJ!9lf{eNqNi+F!UNZQPin^!g3s`4DGkBl@U$zK&;~_9AtX}lNZ3vba=axC%mAUT zolh76wt6>!MgnpUaswtK_~wXe4e$*Xm<$b6qzDp4Xsq+JGuf}|I^;{HwmO~|YLC2Y z<>RHt7H+?X$X_$Ak4@%7=P>=)YAjP`{5eCZaoZ@^HkR@{4IAC~^T*~SMZfbVjg z5hr0A=zImL%tdUHEkOnrg6zOX_-~jD*_Bd18V98ChqXXOT+rjVy?MQ_Xod6#W z785~pw#^K$K^BJP>^DlGIfW)x99k}IR2)MNIp|s#ymRh3!G+Jz+1MT1$(-dMY1cTp zqhtVfTZ2rHa(QCVB$x`BA>~er<+!ye$5*4}7h=bsY9jL-ZQA-N9IlxdYED#yufsQS z9EU&m9nF){)c>1z*Kfaj7vNZo@w6-Hvw@O-F+A0SXGZ|oz$kKk28(ZKoCqqiN;1BM%E7&kj_rQ;m zt#-Wco9@kRCq%=e#V>v8_tNm6?u^1;&h!`H z+57)w(&7JfG#>Z-zl0dl#@1l}AHapdz=y%#C`fxbn>75l&EUD{|0nq0z5h=Z)41pV hCFGR Date: Wed, 5 Feb 2020 16:21:01 +0100 Subject: [PATCH 214/279] fix(helm): Don't wait for service to be ready when external IP are set Resolves #7513 As the externalIPs are not managed by k8s (according to the doc: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#servicespec-v1-core) helm should not wait for services which set al least one externalIPs. Signed-off-by: Federico Bevione --- pkg/kube/wait.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index f0005a61e..74b1fe6fb 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -188,12 +188,24 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { } // Make sure the service is not explicitly set to "None" before checking the IP - if (s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "") || - // This checks if the service has a LoadBalancer and that balancer has an Ingress defined - (s.Spec.Type == corev1.ServiceTypeLoadBalancer && s.Status.LoadBalancer.Ingress == nil) { - w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + if s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "" { return false } + + // This checks if the service has a LoadBalancer and that balancer has an Ingress defined + if s.Spec.Type == corev1.ServiceTypeLoadBalancer { + // do not wait when at least 1 external IP is set + if len(s.Spec.ExternalIPs) > 0 { + w.log("Service has externaIPs addresses: %s/%s (%v)", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) + return true + } + + if s.Status.LoadBalancer.Ingress == nil { + w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + return false + } + } + return true } From 15e2659191cdba73afc8c5c08d2645f8b32d3433 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Wed, 5 Feb 2020 16:47:05 +0100 Subject: [PATCH 215/279] fix(tests): Ignores tarball that will change on dep update The unit test added to cover #7233 was causing changes to show up in git when tests were ran. This was due to the dependency build creating a new tarball. These changes would cause a dirty build when we build our major versions, so I removed the subchart tarball from git and added the charts folder for that test chart to the gitignore to avoid any future problems. Based on all I can see, this should have any impact on the test itself Signed-off-by: Taylor Thomas --- .gitignore | 2 ++ .../issue-7233/charts/alpine-0.1.0.tgz | Bin 1167 -> 0 bytes 2 files changed, 2 insertions(+) delete mode 100644 cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz diff --git a/.gitignore b/.gitignore index d32d1b6dc..8f2ae2c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ _dist/ bin/ vendor/ +# Ignores charts pulled for dependency build tests +cmd/helm/testdata/testcharts/issue-7233/charts/* diff --git a/cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz b/cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz deleted file mode 100644 index a64d9ed46a25dec2446050321772fc2d1d35417a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1167 zcmV;A1aSKwiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI*zkJ~mA-m`wiK)J@U{EhgwcoX0a+6KY42v8J7J(k86u@tG2 zl(nkk|6Y)kylZWg!7!$MJkRbge~so=5(gf(iGz_kk=_?C(C4hoqDnapVknK6Z44u=`>Jkpta z1_JFTA8vt`rAkOIgTZm~mYJ+vM~Tece7|Vd>JmqzC=OoQS^q+5_`gG5l0H)cc#i+^ zIPUU)F`D%Jzl3~nw9M;4!_1e~ryp+aFSq$YwYL(@PhZ-xeh0+nG&$x*qzER-T$ zNTJ!9lf{eNqNi+F!UNZQPin^!g3s`4DGkBl@U$zK&;~_9AtX}lNZ3vba=axC%mAUT zolh76wt6>!MgnpUaswtK_~wXe4e$*Xm<$b6qzDp4Xsq+JGuf}|I^;{HwmO~|YLC2Y z<>RHt7H+?X$X_$Ak4@%7=P>=)YAjP`{5eCZaoZ@^HkR@{4IAC~^T*~SMZfbVjg z5hr0A=zImL%tdUHEkOnrg6zOX_-~jD*_Bd18V98ChqXXOT+rjVy?MQ_Xod6#W z785~pw#^K$K^BJP>^DlGIfW)x99k}IR2)MNIp|s#ymRh3!G+Jz+1MT1$(-dMY1cTp zqhtVfTZ2rHa(QCVB$x`BA>~er<+!ye$5*4}7h=bsY9jL-ZQA-N9IlxdYED#yufsQS z9EU&m9nF){)c>1z*Kfaj7vNZo@w6-Hvw@O-F+A0SXGZ|oz$kKk28(ZKoCqqiN;1BM%E7&kj_rQ;m zt#-Wco9@kRCq%=e#V>v8_tNm6?u^1;&h!`H z+57)w(&7JfG#>Z-zl0dl#@1l}AHapdz=y%#C`fxbn>75l&EUD{|0nq0z5h=Z)41pV hCFGR Date: Thu, 6 Feb 2020 12:01:03 -0500 Subject: [PATCH 216/279] Fixes issue where is left in starter values file This is a leftover bug from #7201. Closes #7532 Signed-off-by: Matt Farina --- pkg/chartutil/create.go | 9 +++++++++ pkg/chartutil/create_test.go | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 496f20166..24eb1e277 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -445,6 +445,15 @@ func CreateFrom(chartfile *chart.Metadata, dest, src string) error { } schart.Values = m + // SaveDir looks for the file values.yaml when saving rather than the values + // key in order to preserve the comments in the YAML. The name placeholder + // needs to be replaced on that file. + for _, f := range schart.Raw { + if f.Name == ValuesfileName { + f.Data = transform(string(f.Data), schart.Name()) + } + } + return SaveDir(schart, dest) } diff --git a/pkg/chartutil/create_test.go b/pkg/chartutil/create_test.go index 82fde586c..d2a3b0a20 100644 --- a/pkg/chartutil/create_test.go +++ b/pkg/chartutil/create_test.go @@ -17,6 +17,7 @@ limitations under the License. package chartutil import ( + "bytes" "io/ioutil" "os" "path/filepath" @@ -105,5 +106,14 @@ func TestCreateFrom(t *testing.T) { if _, err := os.Stat(filepath.Join(dir, f)); err != nil { t.Errorf("Expected %s file: %s", f, err) } + + // Check each file to make sure has been replaced + b, err := ioutil.ReadFile(filepath.Join(dir, f)) + if err != nil { + t.Errorf("Unable to read file %s: %s", f, err) + } + if bytes.Contains(b, []byte("")) { + t.Errorf("File %s contains ", f) + } } } From 43e628599564bafd5b16514fae799eab9fbc5ffd Mon Sep 17 00:00:00 2001 From: Jon Huhn Date: Thu, 6 Feb 2020 10:45:15 -0600 Subject: [PATCH 217/279] Fix engine.newFiles doc comment Signed-off-by: Jon Huhn --- pkg/engine/files.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/engine/files.go b/pkg/engine/files.go index 3a6659d11..d7e62da5a 100644 --- a/pkg/engine/files.go +++ b/pkg/engine/files.go @@ -30,7 +30,7 @@ import ( type files map[string][]byte // NewFiles creates a new files from chart files. -// Given an []*any.Any (the format for files in a chart.Chart), extract a map of files. +// Given an []*chart.File (the format for files in a chart.Chart), extract a map of files. func newFiles(from []*chart.File) files { files := make(map[string][]byte) for _, f := range from { From ed80cf4548712cb779bd1607f98dff21d905d346 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 6 Feb 2020 12:26:23 -0500 Subject: [PATCH 218/279] Fixes issue where non-CRDs are read in from the crd directory For example, a readme markdown is read in and parsed Closes #7536 Signed-off-by: Matt Farina --- pkg/chart/chart.go | 9 +++++++-- pkg/chart/chart_test.go | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 1a85373b9..bd75375a4 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -135,7 +135,7 @@ func (ch *Chart) CRDs() []*File { files := []*File{} // Find all resources in the crds/ directory for _, f := range ch.Files { - if strings.HasPrefix(f.Name, "crds/") { + if strings.HasPrefix(f.Name, "crds/") && hasManifestExtension(f.Name) { files = append(files, f) } } @@ -151,7 +151,7 @@ func (ch *Chart) CRDObjects() []CRD { crds := []CRD{} // Find all resources in the crds/ directory for _, f := range ch.Files { - if strings.HasPrefix(f.Name, "crds/") { + if strings.HasPrefix(f.Name, "crds/") && hasManifestExtension(f.Name) { mycrd := CRD{Name: f.Name, Filename: filepath.Join(ch.ChartFullPath(), f.Name), File: f} crds = append(crds, mycrd) } @@ -162,3 +162,8 @@ func (ch *Chart) CRDObjects() []CRD { } return crds } + +func hasManifestExtension(fname string) bool { + ext := filepath.Ext(fname) + return strings.EqualFold(ext, ".yaml") || strings.EqualFold(ext, ".yml") || strings.EqualFold(ext, ".json") +} diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go index 724e52933..ef623fff6 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -41,6 +41,10 @@ func TestCRDs(t *testing.T) { Name: "crdsfoo/bar/baz.yaml", Data: []byte("hello"), }, + { + Name: "crds/README.md", + Data: []byte("# hello"), + }, }, } From e6d2d10bad8a872478783b0b1483cf467c05741b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 16 Jan 2020 16:07:25 -0500 Subject: [PATCH 219/279] fix(tests): Add namespace support to memory driver Signed-off-by: Marc Khouzam --- cmd/helm/helm_test.go | 3 + cmd/helm/list_test.go | 15 +++ cmd/helm/testdata/output/list-namespace.txt | 2 + pkg/action/action.go | 1 + pkg/storage/driver/memory.go | 127 ++++++++++++++------ pkg/storage/driver/memory_test.go | 92 +++++++++++--- pkg/storage/driver/mock_test.go | 5 + 7 files changed, 190 insertions(+), 55 deletions(-) create mode 100644 cmd/helm/testdata/output/list-namespace.txt diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 5f9d80a3a..8c6c492f8 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -143,6 +143,9 @@ func executeActionCommandC(store *storage.Storage, cmd string) (*cobra.Command, root.SetOutput(buf) root.SetArgs(args) + if mem, ok := store.Driver.(*driver.Memory); ok { + mem.SetNamespace(settings.Namespace()) + } c, err := root.ExecuteC() return c, buf.String(), err diff --git a/cmd/helm/list_test.go b/cmd/helm/list_test.go index 127a8a980..fe773a803 100644 --- a/cmd/helm/list_test.go +++ b/cmd/helm/list_test.go @@ -131,6 +131,16 @@ func TestListCmd(t *testing.T) { }, Chart: chartInfo, }, + { + Name: "starlord", + Version: 2, + Namespace: "milano", + Info: &release.Info{ + LastDeployed: timestamp1, + Status: release.StatusDeployed, + }, + Chart: chartInfo, + }, } tests := []cmdTestCase{{ @@ -203,6 +213,11 @@ func TestListCmd(t *testing.T) { cmd: "list --uninstalling", golden: "output/list-uninstalling.txt", rels: releaseFixture, + }, { + name: "list releases in another namespace", + cmd: "list -n milano", + golden: "output/list-namespace.txt", + rels: releaseFixture, }} runTestCmd(t, tests) } diff --git a/cmd/helm/testdata/output/list-namespace.txt b/cmd/helm/testdata/output/list-namespace.txt new file mode 100644 index 000000000..9382327d6 --- /dev/null +++ b/cmd/helm/testdata/output/list-namespace.txt @@ -0,0 +1,2 @@ +NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION +starlord milano 2 2016-01-16 00:00:01 +0000 UTC deployed chickadee-1.0.0 0.0.1 diff --git a/pkg/action/action.go b/pkg/action/action.go index 9405cc401..a97533696 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -241,6 +241,7 @@ func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespac store = storage.Init(d) case "memory": d := driver.NewMemory() + d.SetNamespace(namespace) store = storage.Init(d) default: // Not sure what to do here. diff --git a/pkg/storage/driver/memory.go b/pkg/storage/driver/memory.go index ca8756c0c..a99b36ef0 100644 --- a/pkg/storage/driver/memory.go +++ b/pkg/storage/driver/memory.go @@ -26,18 +26,33 @@ import ( var _ Driver = (*Memory)(nil) -// MemoryDriverName is the string name of this driver. -const MemoryDriverName = "Memory" +const ( + // MemoryDriverName is the string name of this driver. + MemoryDriverName = "Memory" + + defaultNamespace = "default" +) + +// A map of release names to list of release records +type memReleases map[string]records // Memory is the in-memory storage driver implementation. type Memory struct { sync.RWMutex - cache map[string]records + namespace string + // A map of namespaces to releases + cache map[string]memReleases } // NewMemory initializes a new memory driver. func NewMemory() *Memory { - return &Memory{cache: map[string]records{}} + return &Memory{cache: map[string]memReleases{}, namespace: "default"} +} + +// SetNamespace sets a specific namespace in which releases will be accessed. +// An empty string indicates all namespaces (for the list operation) +func (mem *Memory) SetNamespace(ns string) { + mem.namespace = ns } // Name returns the name of the driver. @@ -56,7 +71,7 @@ func (mem *Memory) Get(key string) (*rspb.Release, error) { if _, err := strconv.Atoi(ver); err != nil { return nil, ErrInvalidKey } - if recs, ok := mem.cache[name]; ok { + if recs, ok := mem.cache[mem.namespace][name]; ok { if r := recs.Get(key); r != nil { return r.rls, nil } @@ -72,13 +87,23 @@ func (mem *Memory) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error defer unlock(mem.rlock()) var ls []*rspb.Release - for _, recs := range mem.cache { - recs.Iter(func(_ int, rec *record) bool { - if filter(rec.rls) { - ls = append(ls, rec.rls) - } - return true - }) + for namespace := range mem.cache { + if mem.namespace != "" { + // Should only list releases of this namespace + namespace = mem.namespace + } + for _, recs := range mem.cache[namespace] { + recs.Iter(func(_ int, rec *record) bool { + if filter(rec.rls) { + ls = append(ls, rec.rls) + } + return true + }) + } + if mem.namespace != "" { + // Should only list releases of this namespace + break + } } return ls, nil } @@ -93,18 +118,28 @@ func (mem *Memory) Query(keyvals map[string]string) ([]*rspb.Release, error) { lbs.fromMap(keyvals) var ls []*rspb.Release - for _, recs := range mem.cache { - recs.Iter(func(_ int, rec *record) bool { - // A query for a release name that doesn't exist (has been deleted) - // can cause rec to be nil. - if rec == nil { - return false - } - if rec.lbs.match(lbs) { - ls = append(ls, rec.rls) - } - return true - }) + for namespace := range mem.cache { + if mem.namespace != "" { + // Should only query releases of this namespace + namespace = mem.namespace + } + for _, recs := range mem.cache[namespace] { + recs.Iter(func(_ int, rec *record) bool { + // A query for a release name that doesn't exist (has been deleted) + // can cause rec to be nil. + if rec == nil { + return false + } + if rec.lbs.match(lbs) { + ls = append(ls, rec.rls) + } + return true + }) + } + if mem.namespace != "" { + // Should only query releases of this namespace + break + } } return ls, nil } @@ -113,14 +148,25 @@ func (mem *Memory) Query(keyvals map[string]string) ([]*rspb.Release, error) { func (mem *Memory) Create(key string, rls *rspb.Release) error { defer unlock(mem.wlock()) - if recs, ok := mem.cache[rls.Name]; ok { + // For backwards compatibility, we protect against an unset namespace + namespace := rls.Namespace + if namespace == "" { + namespace = defaultNamespace + } + mem.SetNamespace(namespace) + + if _, ok := mem.cache[namespace]; !ok { + mem.cache[namespace] = memReleases{} + } + + if recs, ok := mem.cache[namespace][rls.Name]; ok { if err := recs.Add(newRecord(key, rls)); err != nil { return err } - mem.cache[rls.Name] = recs + mem.cache[namespace][rls.Name] = recs return nil } - mem.cache[rls.Name] = records{newRecord(key, rls)} + mem.cache[namespace][rls.Name] = records{newRecord(key, rls)} return nil } @@ -128,9 +174,18 @@ func (mem *Memory) Create(key string, rls *rspb.Release) error { func (mem *Memory) Update(key string, rls *rspb.Release) error { defer unlock(mem.wlock()) - if rs, ok := mem.cache[rls.Name]; ok && rs.Exists(key) { - rs.Replace(key, newRecord(key, rls)) - return nil + // For backwards compatibility, we protect against an unset namespace + namespace := rls.Namespace + if namespace == "" { + namespace = defaultNamespace + } + mem.SetNamespace(namespace) + + if _, ok := mem.cache[namespace]; ok { + if rs, ok := mem.cache[namespace][rls.Name]; ok && rs.Exists(key) { + rs.Replace(key, newRecord(key, rls)) + return nil + } } return ErrReleaseNotFound } @@ -150,11 +205,13 @@ func (mem *Memory) Delete(key string) (*rspb.Release, error) { if _, err := strconv.Atoi(ver); err != nil { return nil, ErrInvalidKey } - if recs, ok := mem.cache[name]; ok { - if r := recs.Remove(key); r != nil { - // recs.Remove changes the slice reference, so we have to re-assign it. - mem.cache[name] = recs - return r.rls, nil + if _, ok := mem.cache[mem.namespace]; ok { + if recs, ok := mem.cache[mem.namespace][name]; ok { + if r := recs.Remove(key); r != nil { + // recs.Remove changes the slice reference, so we have to re-assign it. + mem.cache[mem.namespace][name] = recs + return r.rls, nil + } } } return nil, ErrReleaseNotFound diff --git a/pkg/storage/driver/memory_test.go b/pkg/storage/driver/memory_test.go index e9d709c1f..e86a798f3 100644 --- a/pkg/storage/driver/memory_test.go +++ b/pkg/storage/driver/memory_test.go @@ -37,7 +37,7 @@ func TestMemoryCreate(t *testing.T) { err bool }{ { - "create should success", + "create should succeed", releaseStub("rls-c", 1, "default", rspb.StatusDeployed), false, }, @@ -46,6 +46,16 @@ func TestMemoryCreate(t *testing.T) { releaseStub("rls-a", 1, "default", rspb.StatusDeployed), true, }, + { + "create in namespace should succeed", + releaseStub("rls-a", 1, "mynamespace", rspb.StatusDeployed), + false, + }, + { + "create in other namespace should fail (release already exists)", + releaseStub("rls-c", 1, "mynamespace", rspb.StatusDeployed), + true, + }, } ts := tsFixtureMemory(t) @@ -57,26 +67,34 @@ func TestMemoryCreate(t *testing.T) { if !tt.err { t.Fatalf("failed to create %q: %s", tt.desc, err) } + } else if tt.err { + t.Fatalf("Did not get expected error for %q\n", tt.desc) } } } func TestMemoryGet(t *testing.T) { var tests = []struct { - desc string - key string - err bool + desc string + key string + namespace string + err bool }{ - {"release key should exist", "rls-a.v1", false}, - {"release key should not exist", "rls-a.v5", true}, + {"release key should exist", "rls-a.v1", "default", false}, + {"release key should not exist", "rls-a.v5", "default", true}, + {"release key in namespace should exist", "rls-c.v1", "mynamespace", false}, + {"release key in namespace should not exist", "rls-a.v1", "mynamespace", true}, } ts := tsFixtureMemory(t) for _, tt := range tests { + ts.SetNamespace(tt.namespace) if _, err := ts.Get(tt.key); err != nil { if !tt.err { t.Fatalf("Failed %q to get '%s': %q\n", tt.desc, tt.key, err) } + } else if tt.err { + t.Fatalf("Did not get expected error for %q '%s'\n", tt.desc, tt.key) } } } @@ -123,19 +141,28 @@ func TestMemoryList(t *testing.T) { func TestMemoryQuery(t *testing.T) { var tests = []struct { - desc string - xlen int - lbs map[string]string + desc string + xlen int + namespace string + lbs map[string]string }{ { "should be 2 query results", 2, + "default", + map[string]string{"status": "deployed"}, + }, + { + "should be 1 query result", + 1, + "mynamespace", map[string]string{"status": "deployed"}, }, } ts := tsFixtureMemory(t) for _, tt := range tests { + ts.SetNamespace(tt.namespace) l, err := ts.Query(tt.lbs) if err != nil { t.Fatalf("Failed to query: %s\n", err) @@ -162,8 +189,20 @@ func TestMemoryUpdate(t *testing.T) { }, { "update release does not exist", - "rls-z.v1", - releaseStub("rls-z", 1, "default", rspb.StatusUninstalled), + "rls-c.v1", + releaseStub("rls-c", 1, "default", rspb.StatusUninstalled), + true, + }, + { + "update release status in namespace", + "rls-c.v4", + releaseStub("rls-c", 4, "mynamespace", rspb.StatusSuperseded), + false, + }, + { + "update release in namespace does not exist", + "rls-a.v1", + releaseStub("rls-a", 1, "mynamespace", rspb.StatusUninstalled), true, }, } @@ -175,8 +214,11 @@ func TestMemoryUpdate(t *testing.T) { t.Fatalf("Failed %q: %s\n", tt.desc, err) } continue + } else if tt.err { + t.Fatalf("Did not get expected error for %q '%s'\n", tt.desc, tt.key) } + ts.SetNamespace(tt.rls.Namespace) r, err := ts.Get(tt.key) if err != nil { t.Fatalf("Failed to get: %s\n", err) @@ -190,26 +232,35 @@ func TestMemoryUpdate(t *testing.T) { func TestMemoryDelete(t *testing.T) { var tests = []struct { - desc string - key string - err bool + desc string + key string + namespace string + err bool }{ - {"release key should exist", "rls-a.v1", false}, - {"release key should not exist", "rls-a.v5", true}, + {"release key should exist", "rls-a.v4", "default", false}, + {"release key should not exist", "rls-a.v5", "default", true}, + {"release key from other namespace should not exist", "rls-c.v4", "default", true}, + {"release key from namespace should exist", "rls-c.v4", "mynamespace", false}, + {"release key from namespace should not exist", "rls-c.v5", "mynamespace", true}, + {"release key from namespace2 should not exist", "rls-a.v4", "mynamespace", true}, } ts := tsFixtureMemory(t) - start, err := ts.Query(map[string]string{"name": "rls-a"}) + ts.SetNamespace("") + start, err := ts.Query(map[string]string{"status": "deployed"}) if err != nil { t.Errorf("Query failed: %s", err) } startLen := len(start) for _, tt := range tests { + ts.SetNamespace(tt.namespace) if rel, err := ts.Delete(tt.key); err != nil { if !tt.err { t.Fatalf("Failed %q to get '%s': %q\n", tt.desc, tt.key, err) } continue + } else if tt.err { + t.Fatalf("Did not get expected error for %q '%s'\n", tt.desc, tt.key) } else if fmt.Sprintf("%s.v%d", rel.Name, rel.Version) != tt.key { t.Fatalf("Asked for delete on %s, but deleted %d", tt.key, rel.Version) } @@ -220,14 +271,15 @@ func TestMemoryDelete(t *testing.T) { } // Make sure that the deleted records are gone. - end, err := ts.Query(map[string]string{"name": "rls-a"}) + ts.SetNamespace("") + end, err := ts.Query(map[string]string{"status": "deployed"}) if err != nil { t.Errorf("Query failed: %s", err) } endLen := len(end) - if startLen <= endLen { - t.Errorf("expected start %d to be less than end %d", startLen, endLen) + if startLen-2 != endLen { + t.Errorf("expected end to be %d instead of %d", startLen-2, endLen) for _, ee := range end { t.Logf("Name: %s, Version: %d", ee.Name, ee.Version) } diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index 4c9b4ef9c..3cb3773c2 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -53,6 +53,11 @@ func tsFixtureMemory(t *testing.T) *Memory { releaseStub("rls-b", 1, "default", rspb.StatusSuperseded), releaseStub("rls-b", 3, "default", rspb.StatusSuperseded), releaseStub("rls-b", 2, "default", rspb.StatusSuperseded), + // rls-c in other namespace + releaseStub("rls-c", 4, "mynamespace", rspb.StatusDeployed), + releaseStub("rls-c", 1, "mynamespace", rspb.StatusSuperseded), + releaseStub("rls-c", 3, "mynamespace", rspb.StatusSuperseded), + releaseStub("rls-c", 2, "mynamespace", rspb.StatusSuperseded), } mem := NewMemory() From be7de1c376347b3f97d24aab85270ced0c039a58 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 29 Jan 2020 22:56:19 -0500 Subject: [PATCH 220/279] fix(cmd): Specify namespace for template command The template command uses the memory driver. This driver now supports namespaces, so the template code-path now specifies the namespace as required by the memory driver. Signed-off-by: Marc Khouzam --- pkg/action/install.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 78021dc8c..55a44aaed 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -187,7 +187,10 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. i.cfg.Capabilities = chartutil.DefaultCapabilities i.cfg.Capabilities.APIVersions = append(i.cfg.Capabilities.APIVersions, i.APIVersions...) i.cfg.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard} - i.cfg.Releases = storage.Init(driver.NewMemory()) + + mem := driver.NewMemory() + mem.SetNamespace(i.Namespace) + i.cfg.Releases = storage.Init(mem) } else if !i.ClientOnly && len(i.APIVersions) > 0 { i.cfg.Log("API Version list given outside of client only mode, this list will be ignored") } From 8e1fc4bc6fb871af3aa73fc79a2ca86901092610 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 7 Feb 2020 09:23:53 -0800 Subject: [PATCH 221/279] fix(memory_test): rebase master Signed-off-by: Matthew Fisher --- pkg/storage/driver/memory_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/storage/driver/memory_test.go b/pkg/storage/driver/memory_test.go index e86a798f3..7a2e8578e 100644 --- a/pkg/storage/driver/memory_test.go +++ b/pkg/storage/driver/memory_test.go @@ -101,6 +101,7 @@ func TestMemoryGet(t *testing.T) { func TestMemoryList(t *testing.T) { ts := tsFixtureMemory(t) + ts.SetNamespace("default") // list all deployed releases dpl, err := ts.List(func(rel *rspb.Release) bool { From 08fc12a8c3cb278e90ca0a44460faf91ca9affb7 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Mon, 23 Sep 2019 11:29:24 -0600 Subject: [PATCH 222/279] Adds post-render support Signed-off-by: Taylor Thomas --- cmd/helm/flags.go | 32 ++++++++++++ cmd/helm/install.go | 1 + cmd/helm/upgrade.go | 2 + pkg/action/install.go | 17 ++++++- pkg/action/upgrade.go | 4 +- pkg/postrender/exec.go | 99 ++++++++++++++++++++++++++++++++++++ pkg/postrender/postrender.go | 29 +++++++++++ 7 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 pkg/postrender/exec.go create mode 100644 pkg/postrender/postrender.go diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 65575a5c1..dfaef04a1 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -27,9 +27,11 @@ import ( "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli/output" "helm.sh/helm/v3/pkg/cli/values" + "helm.sh/helm/v3/pkg/postrender" ) const outputFlag = "output" +const postRenderFlag = "post-renderer" func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL (can specify multiple)") @@ -94,3 +96,33 @@ func (o *outputValue) Set(s string) error { *o = outputValue(outfmt) return nil } + +func bindPostRenderFlag(cmd *cobra.Command, varRef *postrender.PostRenderer) { + cmd.Flags().Var(&postRenderer{varRef}, postRenderFlag, "the path to an executable to be used for post rendering. If a non-absolute path is provided, the plugin directory and $PATH will be searched") + // Setup shell completion for the flag + cmd.MarkFlagCustom(outputFlag, "__helm_output_options") +} + +type postRenderer struct { + renderer *postrender.PostRenderer +} + +func (p postRenderer) String() string { + return "exec" +} + +func (p postRenderer) Type() string { + return "postrenderer" +} + +func (p postRenderer) Set(s string) error { + if s == "" { + return nil + } + pr, err := postrender.NewExec(s) + if err != nil { + return err + } + *p.renderer = pr + return nil +} diff --git a/cmd/helm/install.go b/cmd/helm/install.go index dbdfb3418..ec2c75a12 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -130,6 +130,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { addInstallFlags(cmd.Flags(), client, valueOpts) bindOutputFlag(cmd, &outfmt) + bindPostRenderFlag(cmd, &client.PostRenderer) return cmd } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 6c967b796..54badb32c 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -108,6 +108,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { instClient.Devel = client.Devel instClient.Namespace = client.Namespace instClient.Atomic = client.Atomic + instClient.PostRenderer = client.PostRenderer rel, err := runInstall(args, instClient, valueOpts, out) if err != nil { @@ -176,6 +177,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { addChartPathOptionsFlags(f, &client.ChartPathOptions) addValueOptionsFlags(f, valueOpts) bindOutputFlag(cmd, &outfmt) + bindPostRenderFlag(cmd, &client.PostRenderer) return cmd } diff --git a/pkg/action/install.go b/pkg/action/install.go index 55a44aaed..49c9b5728 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -39,6 +39,7 @@ import ( "helm.sh/helm/v3/pkg/engine" "helm.sh/helm/v3/pkg/getter" kubefake "helm.sh/helm/v3/pkg/kube/fake" + "helm.sh/helm/v3/pkg/postrender" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/releaseutil" "helm.sh/helm/v3/pkg/repo" @@ -94,6 +95,7 @@ type Install struct { // Used by helm template to add the release as part of OutputDir path // OutputDir/ UseReleaseName bool + PostRenderer postrender.PostRenderer } // ChartPathOptions captures common options used for controlling chart paths @@ -225,7 +227,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. rel := i.createRelease(chrt, vals) var manifestDoc *bytes.Buffer - rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.ReleaseName, i.OutputDir, i.SubNotes, i.UseReleaseName, i.IncludeCRDs) + rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.ReleaseName, i.OutputDir, i.SubNotes, i.UseReleaseName, i.IncludeCRDs, i.PostRenderer) // Even for errors, attach this if available if manifestDoc != nil { rel.Manifest = manifestDoc.String() @@ -429,7 +431,7 @@ func (i *Install) replaceRelease(rel *release.Release) error { } // renderResources renders the templates in a chart -func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName string, outputDir string, subNotes, useReleaseName bool, includeCrds bool) ([]*release.Hook, *bytes.Buffer, string, error) { +func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values, releaseName, outputDir string, subNotes, useReleaseName, includeCrds bool, pr postrender.PostRenderer) ([]*release.Hook, *bytes.Buffer, string, error) { hs := []*release.Hook{} b := bytes.NewBuffer(nil) @@ -525,6 +527,10 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values if useReleaseName { newDir = filepath.Join(outputDir, releaseName) } + // NOTE: We do not have to worry about the post-renderer because + // output dir is only used by `helm template`. In the next major + // release, we should move this logic to template only as it is not + // used by install or upgrade err = writeToFile(newDir, m.Name, m.Content, fileWritten[m.Name]) if err != nil { return hs, b, "", err @@ -533,6 +539,13 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values } } + if pr != nil { + b, err = pr.Run(b) + if err != nil { + return hs, b, notes, errors.Wrap(err, "error while running post render on files") + } + } + return hs, b, notes, nil } diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 3e8a04a56..825920793 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -29,6 +29,7 @@ import ( "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/kube" + "helm.sh/helm/v3/pkg/postrender" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/releaseutil" ) @@ -59,6 +60,7 @@ type Upgrade struct { CleanupOnFail bool SubNotes bool Description string + PostRenderer postrender.PostRenderer } // NewUpgrade creates a new Upgrade object with the given configuration. @@ -161,7 +163,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin return nil, nil, err } - hooks, manifestDoc, notesTxt, err := u.cfg.renderResources(chart, valuesToRender, "", "", u.SubNotes, false, false) + hooks, manifestDoc, notesTxt, err := u.cfg.renderResources(chart, valuesToRender, "", "", u.SubNotes, false, false, u.PostRenderer) if err != nil { return nil, nil, err } diff --git a/pkg/postrender/exec.go b/pkg/postrender/exec.go new file mode 100644 index 000000000..dde30f6e3 --- /dev/null +++ b/pkg/postrender/exec.go @@ -0,0 +1,99 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package postrender + +import ( + "bytes" + "io" + "os" + "os/exec" + "path/filepath" + "strings" + + "github.com/pkg/errors" + + "helm.sh/helm/v3/pkg/helmpath" +) + +type execRender struct { + binaryPath string +} + +// NewExec returns a PostRenderer implementation that calls the provided binary. +// It returns an error if the binary cannot be found. If the provided path does +// not contain any separators, it will search first in the plugins directory, +// then in $PATH, otherwise it will resolve any relative paths to a fully +// qualified path +func NewExec(binaryPath string) (PostRenderer, error) { + fullPath, err := getFullPath(binaryPath) + if err != nil { + return nil, err + } + return &execRender{fullPath}, nil +} + +// Run the configured binary for the post render +func (p *execRender) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error) { + cmd := exec.Command(p.binaryPath) + stdin, err := cmd.StdinPipe() + if err != nil { + return nil, err + } + + var postRendered = &bytes.Buffer{} + var stderr = &bytes.Buffer{} + cmd.Stdout = postRendered + cmd.Stderr = stderr + + go func() { + defer stdin.Close() + io.Copy(stdin, renderedManifests) + }() + err = cmd.Run() + if err != nil { + return nil, errors.Wrapf(err, "error while running command %s. error output:\n%s", p.binaryPath, stderr.String()) + } + + return postRendered, nil +} + +// getFullPath returns the full filepath to the binary to execute. If the path +// does not contain any separators, it will search first in the plugins +// directory, then in $PATH, otherwise it will resolve any relative paths to a +// fully qualified path +func getFullPath(binaryPath string) (string, error) { + // Manually check the plugin dir first + if !strings.Contains(binaryPath, string(filepath.Separator)) { + // First check the plugin dir + pluginDir := helmpath.DataPath("plugins") + _, err := os.Stat(filepath.Join(pluginDir, binaryPath)) + if err != nil && !os.IsNotExist(err) { + return "", err + } else if err == nil { + binaryPath = filepath.Join(pluginDir, binaryPath) + } + } + + // Now check for the binary using the given path or check if it exists in + // the path and is executable + checkedPath, err := exec.LookPath(binaryPath) + if err != nil { + return "", errors.Wrapf(err, "unable to find binary at %s", binaryPath) + } + + return filepath.Abs(checkedPath) +} diff --git a/pkg/postrender/postrender.go b/pkg/postrender/postrender.go new file mode 100644 index 000000000..76f0f5a74 --- /dev/null +++ b/pkg/postrender/postrender.go @@ -0,0 +1,29 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// package postrender contains an interface that can be implemented for custom +// post-renderers and an exec implementation that can be used for arbitrary +// binaries and scripts +package postrender + +import "bytes" + +type PostRenderer interface { + // Run expects a single buffer filled with Helm rendered manifests. It + // expects the modified results to be returned on a separate buffer or an + // error if there was an issue or failure while running the post render step + Run(renderedManifests *bytes.Buffer) (modifiedManifests *bytes.Buffer, err error) +} From 7a3049a418bd78f3cbfc0e479797865e895261af Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Tue, 28 Jan 2020 12:55:17 +0100 Subject: [PATCH 223/279] chore(postrender): Adds unit tests for exec post renderer Signed-off-by: Taylor Thomas --- cmd/helm/template.go | 1 + pkg/postrender/exec.go | 25 ++++-- pkg/postrender/exec_test.go | 152 ++++++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 8 deletions(-) create mode 100644 pkg/postrender/exec_test.go diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 5c1ba33d1..320718344 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -132,6 +132,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.IsUpgrade, "is-upgrade", false, "set .Release.IsUpgrade instead of .Release.IsInstall") f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") f.BoolVar(&client.UseReleaseName, "release-name", false, "use release name in the output-dir path.") + bindPostRenderFlag(cmd, &client.PostRenderer) return cmd } diff --git a/pkg/postrender/exec.go b/pkg/postrender/exec.go index dde30f6e3..bcf3ef64d 100644 --- a/pkg/postrender/exec.go +++ b/pkg/postrender/exec.go @@ -73,18 +73,27 @@ func (p *execRender) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error) // getFullPath returns the full filepath to the binary to execute. If the path // does not contain any separators, it will search first in the plugins -// directory, then in $PATH, otherwise it will resolve any relative paths to a -// fully qualified path +// directory (or directories if multiple are specified. In which case, it will +// return the first result), then in $PATH, otherwise it will resolve any +// relative paths to a fully qualified path func getFullPath(binaryPath string) (string, error) { // Manually check the plugin dir first if !strings.Contains(binaryPath, string(filepath.Separator)) { // First check the plugin dir - pluginDir := helmpath.DataPath("plugins") - _, err := os.Stat(filepath.Join(pluginDir, binaryPath)) - if err != nil && !os.IsNotExist(err) { - return "", err - } else if err == nil { - binaryPath = filepath.Join(pluginDir, binaryPath) + pluginDir := helmpath.DataPath("plugins") // Default location + // If location for plugins is explicitly set, check there + if v, ok := os.LookupEnv("HELM_PLUGINS"); ok { + pluginDir = v + } + // The plugins variable can actually contain multple paths, so loop through those + for _, p := range filepath.SplitList(pluginDir) { + _, err := os.Stat(filepath.Join(p, binaryPath)) + if err != nil && !os.IsNotExist(err) { + return "", err + } else if err == nil { + binaryPath = filepath.Join(p, binaryPath) + break + } } } diff --git a/pkg/postrender/exec_test.go b/pkg/postrender/exec_test.go new file mode 100644 index 000000000..684a0642b --- /dev/null +++ b/pkg/postrender/exec_test.go @@ -0,0 +1,152 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package postrender + +import ( + "bytes" + "io/ioutil" + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "helm.sh/helm/v3/internal/test/ensure" +) + +const testingScript = `#!/bin/sh +sed s/FOOTEST/BARTEST/g <&0 +` + +func TestGetFullPath(t *testing.T) { + is := assert.New(t) + t.Run("full path resolves correctly", func(t *testing.T) { + testpath, cleanup := setupTestingScript(t) + defer cleanup() + + fullPath, err := getFullPath(testpath) + is.NoError(err) + is.Equal(testpath, fullPath) + }) + + t.Run("relative path resolves correctly", func(t *testing.T) { + testpath, cleanup := setupTestingScript(t) + defer cleanup() + + currentDir, err := os.Getwd() + require.NoError(t, err) + relative, err := filepath.Rel(currentDir, testpath) + require.NoError(t, err) + fullPath, err := getFullPath(relative) + is.NoError(err) + is.Equal(testpath, fullPath) + }) + + t.Run("binary in PATH resolves correctly", func(t *testing.T) { + testpath, cleanup := setupTestingScript(t) + defer cleanup() + + realPath := os.Getenv("PATH") + os.Setenv("PATH", filepath.Dir(testpath)) + defer func() { + os.Setenv("PATH", realPath) + }() + + fullPath, err := getFullPath(filepath.Base(testpath)) + is.NoError(err) + is.Equal(testpath, fullPath) + }) + + t.Run("binary in plugin path resolves correctly", func(t *testing.T) { + testpath, cleanup := setupTestingScript(t) + defer cleanup() + + realPath := os.Getenv("HELM_PLUGINS") + os.Setenv("HELM_PLUGINS", filepath.Dir(testpath)) + defer func() { + os.Setenv("HELM_PLUGINS", realPath) + }() + + fullPath, err := getFullPath(filepath.Base(testpath)) + is.NoError(err) + is.Equal(testpath, fullPath) + }) + + t.Run("binary in multiple plugin paths resolves correctly", func(t *testing.T) { + testpath, cleanup := setupTestingScript(t) + defer cleanup() + + realPath := os.Getenv("HELM_PLUGINS") + os.Setenv("HELM_PLUGINS", filepath.Dir(testpath)+string(os.PathListSeparator)+"/another/dir") + defer func() { + os.Setenv("HELM_PLUGINS", realPath) + }() + + fullPath, err := getFullPath(filepath.Base(testpath)) + is.NoError(err) + is.Equal(testpath, fullPath) + }) +} + +func TestExecRun(t *testing.T) { + if runtime.GOOS == "windows" { + // the actual Run test uses a basic sed example, so skip this test on windows + t.Skip("skipping on windows") + } + is := assert.New(t) + testpath, cleanup := setupTestingScript(t) + defer cleanup() + + renderer, err := NewExec(testpath) + require.NoError(t, err) + + output, err := renderer.Run(bytes.NewBufferString("FOOTEST")) + is.NoError(err) + is.Contains(output.String(), "BARTEST") +} + +func setupTestingScript(t *testing.T) (filepath string, cleanup func()) { + t.Helper() + + tempdir := ensure.TempDir(t) + + f, err := ioutil.TempFile(tempdir, "post-render-test.sh") + if err != nil { + t.Fatalf("unable to create tempfile for testing: %s", err) + } + + _, err = f.WriteString(testingScript) + if err != nil { + t.Fatalf("unable to write tempfile for testing: %s", err) + } + + err = f.Chmod(0755) + if err != nil { + t.Fatalf("unable to make tempfile executable for testing: %s", err) + } + + err = f.Close() + if err != nil { + t.Fatalf("unable to close tempfile after writing: %s", err) + } + + return f.Name(), func() { + os.RemoveAll(tempdir) + } +} From cf7a02fac75415c22e420072ed3c17dbd7b53cae Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Thu, 6 Feb 2020 12:14:22 -0700 Subject: [PATCH 224/279] chore(*): Removes support for searching the plugin dir Signed-off-by: Taylor Thomas --- cmd/helm/flags.go | 2 +- pkg/postrender/exec.go | 60 ++++++++++++++++++------------------ pkg/postrender/exec_test.go | 61 +++++++++++++++++++------------------ 3 files changed, 63 insertions(+), 60 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index dfaef04a1..86ed53d51 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -98,7 +98,7 @@ func (o *outputValue) Set(s string) error { } func bindPostRenderFlag(cmd *cobra.Command, varRef *postrender.PostRenderer) { - cmd.Flags().Var(&postRenderer{varRef}, postRenderFlag, "the path to an executable to be used for post rendering. If a non-absolute path is provided, the plugin directory and $PATH will be searched") + cmd.Flags().Var(&postRenderer{varRef}, postRenderFlag, "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path") // Setup shell completion for the flag cmd.MarkFlagCustom(outputFlag, "__helm_output_options") } diff --git a/pkg/postrender/exec.go b/pkg/postrender/exec.go index bcf3ef64d..0860e7c35 100644 --- a/pkg/postrender/exec.go +++ b/pkg/postrender/exec.go @@ -19,14 +19,10 @@ package postrender import ( "bytes" "io" - "os" "os/exec" "path/filepath" - "strings" "github.com/pkg/errors" - - "helm.sh/helm/v3/pkg/helmpath" ) type execRender struct { @@ -34,10 +30,9 @@ type execRender struct { } // NewExec returns a PostRenderer implementation that calls the provided binary. -// It returns an error if the binary cannot be found. If the provided path does -// not contain any separators, it will search first in the plugins directory, -// then in $PATH, otherwise it will resolve any relative paths to a fully -// qualified path +// It returns an error if the binary cannot be found. If the path does not +// contain any separators, it will search in $PATH, otherwise it will resolve +// any relative paths to a fully qualified path func NewExec(binaryPath string) (PostRenderer, error) { fullPath, err := getFullPath(binaryPath) if err != nil { @@ -72,30 +67,35 @@ func (p *execRender) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error) } // getFullPath returns the full filepath to the binary to execute. If the path -// does not contain any separators, it will search first in the plugins -// directory (or directories if multiple are specified. In which case, it will -// return the first result), then in $PATH, otherwise it will resolve any -// relative paths to a fully qualified path +// does not contain any separators, it will search in $PATH, otherwise it will +// resolve any relative paths to a fully qualified path func getFullPath(binaryPath string) (string, error) { + // NOTE(thomastaylor312): I am leaving this code commented out here. During + // the implementation of post-render, it was brought up that if we are + // relying on plguins, we should actually use the plugin system so it can + // properly handle multiple OSs. This will be a feature add in the future, + // so I left this code for reference. It can be deleted or reused once the + // feature is implemented + // Manually check the plugin dir first - if !strings.Contains(binaryPath, string(filepath.Separator)) { - // First check the plugin dir - pluginDir := helmpath.DataPath("plugins") // Default location - // If location for plugins is explicitly set, check there - if v, ok := os.LookupEnv("HELM_PLUGINS"); ok { - pluginDir = v - } - // The plugins variable can actually contain multple paths, so loop through those - for _, p := range filepath.SplitList(pluginDir) { - _, err := os.Stat(filepath.Join(p, binaryPath)) - if err != nil && !os.IsNotExist(err) { - return "", err - } else if err == nil { - binaryPath = filepath.Join(p, binaryPath) - break - } - } - } + // if !strings.Contains(binaryPath, string(filepath.Separator)) { + // // First check the plugin dir + // pluginDir := helmpath.DataPath("plugins") // Default location + // // If location for plugins is explicitly set, check there + // if v, ok := os.LookupEnv("HELM_PLUGINS"); ok { + // pluginDir = v + // } + // // The plugins variable can actually contain multple paths, so loop through those + // for _, p := range filepath.SplitList(pluginDir) { + // _, err := os.Stat(filepath.Join(p, binaryPath)) + // if err != nil && !os.IsNotExist(err) { + // return "", err + // } else if err == nil { + // binaryPath = filepath.Join(p, binaryPath) + // break + // } + // } + // } // Now check for the binary using the given path or check if it exists in // the path and is executable diff --git a/pkg/postrender/exec_test.go b/pkg/postrender/exec_test.go index 684a0642b..ef0956949 100644 --- a/pkg/postrender/exec_test.go +++ b/pkg/postrender/exec_test.go @@ -73,35 +73,38 @@ func TestGetFullPath(t *testing.T) { is.Equal(testpath, fullPath) }) - t.Run("binary in plugin path resolves correctly", func(t *testing.T) { - testpath, cleanup := setupTestingScript(t) - defer cleanup() - - realPath := os.Getenv("HELM_PLUGINS") - os.Setenv("HELM_PLUGINS", filepath.Dir(testpath)) - defer func() { - os.Setenv("HELM_PLUGINS", realPath) - }() - - fullPath, err := getFullPath(filepath.Base(testpath)) - is.NoError(err) - is.Equal(testpath, fullPath) - }) - - t.Run("binary in multiple plugin paths resolves correctly", func(t *testing.T) { - testpath, cleanup := setupTestingScript(t) - defer cleanup() - - realPath := os.Getenv("HELM_PLUGINS") - os.Setenv("HELM_PLUGINS", filepath.Dir(testpath)+string(os.PathListSeparator)+"/another/dir") - defer func() { - os.Setenv("HELM_PLUGINS", realPath) - }() - - fullPath, err := getFullPath(filepath.Base(testpath)) - is.NoError(err) - is.Equal(testpath, fullPath) - }) + // NOTE(thomastaylor312): See note in getFullPath for more details why this + // is here + + // t.Run("binary in plugin path resolves correctly", func(t *testing.T) { + // testpath, cleanup := setupTestingScript(t) + // defer cleanup() + + // realPath := os.Getenv("HELM_PLUGINS") + // os.Setenv("HELM_PLUGINS", filepath.Dir(testpath)) + // defer func() { + // os.Setenv("HELM_PLUGINS", realPath) + // }() + + // fullPath, err := getFullPath(filepath.Base(testpath)) + // is.NoError(err) + // is.Equal(testpath, fullPath) + // }) + + // t.Run("binary in multiple plugin paths resolves correctly", func(t *testing.T) { + // testpath, cleanup := setupTestingScript(t) + // defer cleanup() + + // realPath := os.Getenv("HELM_PLUGINS") + // os.Setenv("HELM_PLUGINS", filepath.Dir(testpath)+string(os.PathListSeparator)+"/another/dir") + // defer func() { + // os.Setenv("HELM_PLUGINS", realPath) + // }() + + // fullPath, err := getFullPath(filepath.Base(testpath)) + // is.NoError(err) + // is.Equal(testpath, fullPath) + // }) } func TestExecRun(t *testing.T) { From 077503f17502ea2ad59d73a08897f238dc72ebb0 Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Fri, 7 Feb 2020 19:28:30 +0100 Subject: [PATCH 225/279] fix(helm): Reworded logs for clarity Signed-off-by: Federico Bevione --- pkg/kube/wait.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 74b1fe6fb..7ea02d382 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -189,6 +189,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { // Make sure the service is not explicitly set to "None" before checking the IP if s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "" { + w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) return false } @@ -196,7 +197,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { if s.Spec.Type == corev1.ServiceTypeLoadBalancer { // do not wait when at least 1 external IP is set if len(s.Spec.ExternalIPs) > 0 { - w.log("Service has externaIPs addresses: %s/%s (%v)", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) + w.log("Service %s/%s has external IP addresses (%v), marking as ready", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) return true } From 8b6233fc3ef50903bd527605ffe9a2f617b3e616 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 7 Feb 2020 10:32:37 -0800 Subject: [PATCH 226/279] fix(version): fix typo in doc comment Signed-off-by: Matthew Fisher --- internal/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/version/version.go b/internal/version/version.go index 22439d11b..ff0df0f95 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -23,7 +23,7 @@ import ( ) var ( - // version is the current version of the Helm. + // version is the current version of Helm. // Update this whenever making a new release. // The version is of the format Major.Minor.Patch[-Prerelease][+BuildMetadata] // From 0977ded29a00383db5cbfd91ae220d30457f6ddb Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 7 Feb 2020 10:33:31 -0800 Subject: [PATCH 227/279] bump version to v3.1 Signed-off-by: Matthew Fisher --- cmd/helm/testdata/output/version-client-shorthand.txt | 2 +- cmd/helm/testdata/output/version-client.txt | 2 +- cmd/helm/testdata/output/version-short.txt | 2 +- cmd/helm/testdata/output/version-template.txt | 2 +- cmd/helm/testdata/output/version.txt | 2 +- internal/version/version.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/helm/testdata/output/version-client-shorthand.txt b/cmd/helm/testdata/output/version-client-shorthand.txt index 4b493d31c..8f9ed6136 100644 --- a/cmd/helm/testdata/output/version-client-shorthand.txt +++ b/cmd/helm/testdata/output/version-client-shorthand.txt @@ -1 +1 @@ -version.BuildInfo{Version:"v3.0", GitCommit:"", GitTreeState:"", GoVersion:""} +version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/output/version-client.txt b/cmd/helm/testdata/output/version-client.txt index 4b493d31c..8f9ed6136 100644 --- a/cmd/helm/testdata/output/version-client.txt +++ b/cmd/helm/testdata/output/version-client.txt @@ -1 +1 @@ -version.BuildInfo{Version:"v3.0", GitCommit:"", GitTreeState:"", GoVersion:""} +version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/cmd/helm/testdata/output/version-short.txt b/cmd/helm/testdata/output/version-short.txt index d9fb9c736..861668947 100644 --- a/cmd/helm/testdata/output/version-short.txt +++ b/cmd/helm/testdata/output/version-short.txt @@ -1 +1 @@ -v3.0 +v3.1 diff --git a/cmd/helm/testdata/output/version-template.txt b/cmd/helm/testdata/output/version-template.txt index 776c1919b..e5a779bbf 100644 --- a/cmd/helm/testdata/output/version-template.txt +++ b/cmd/helm/testdata/output/version-template.txt @@ -1 +1 @@ -Version: v3.0 \ No newline at end of file +Version: v3.1 \ No newline at end of file diff --git a/cmd/helm/testdata/output/version.txt b/cmd/helm/testdata/output/version.txt index 4b493d31c..8f9ed6136 100644 --- a/cmd/helm/testdata/output/version.txt +++ b/cmd/helm/testdata/output/version.txt @@ -1 +1 @@ -version.BuildInfo{Version:"v3.0", GitCommit:"", GitTreeState:"", GoVersion:""} +version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""} diff --git a/internal/version/version.go b/internal/version/version.go index ff0df0f95..fd0616920 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -30,7 +30,7 @@ var ( // Increment major number for new feature additions and behavioral changes. // Increment minor number for bug fixes and performance enhancements. // Increment patch number for critical fixes to existing releases. - version = "v3.0" + version = "v3.1" // metadata is extra build time data metadata = "" From 593ea3fb12d145aefcf390643551a35eee05b782 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 7 Feb 2020 11:52:04 -0700 Subject: [PATCH 228/279] Add ADOPTERS file, per CNCF requirements (#7507) * Add ADOPTERS file, per CNCF requirements Signed-off-by: Matt Butcher * Update ADOPTERS.md Co-Authored-By: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> Signed-off-by: Matt Butcher * Update ADOPTERS.md Co-Authored-By: Martin Hickey Signed-off-by: Matt Butcher * Update ADOPTERS.md Signed-off-by: Marc Khouzam marc.khouzam@montreal.ca Co-Authored-By: Marc Khouzam Signed-off-by: Matt Butcher Co-authored-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com> Co-authored-by: Martin Hickey Co-authored-by: Marc Khouzam --- ADOPTERS.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 ADOPTERS.md diff --git a/ADOPTERS.md b/ADOPTERS.md new file mode 100644 index 000000000..5dccb8fc6 --- /dev/null +++ b/ADOPTERS.md @@ -0,0 +1,12 @@ + To add your organization to this list, simply add your organization's name, + optionally with a link. The list is in alphabetical order. + +# Organizations Using Helm + +- [Blood Orange](https://bloodorange.io) +- [Microsoft](https://microsoft.com) +- [IBM](https://www.ibm.com) +- [Qovery](https://www.qovery.com/) +- [Samsung SDS](https://www.samsungsds.com/) +[Ville de Montreal](https://montreal.ca) +_This file is part of the CNCF official documentation for projects._ From 9daca76f16b7b17c6ecb36b30ff7832a4b83b70f Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 7 Feb 2020 11:53:41 -0700 Subject: [PATCH 229/279] fixed missing bullet Signed-off-by: Matt Butcher --- ADOPTERS.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ADOPTERS.md b/ADOPTERS.md index 5dccb8fc6..a72f51e09 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -1,5 +1,7 @@ - To add your organization to this list, simply add your organization's name, - optionally with a link. The list is in alphabetical order. + To add your organization to this list, open a pull request that adds your + organization's name, optionally with a link. The list is in alphabetical order. + + (Remember to use `git commit --signoff` to comply with the DCO) # Organizations Using Helm @@ -8,5 +10,6 @@ - [IBM](https://www.ibm.com) - [Qovery](https://www.qovery.com/) - [Samsung SDS](https://www.samsungsds.com/) -[Ville de Montreal](https://montreal.ca) +- [Ville de Montreal](https://montreal.ca) + _This file is part of the CNCF official documentation for projects._ From 2a73967ca214d38ed22f5f3ecfda3d1dcc2b4773 Mon Sep 17 00:00:00 2001 From: Reinhard Naegele Date: Fri, 7 Feb 2020 19:52:58 +0100 Subject: [PATCH 230/279] Fix 'helm template' to also print invalid yaml Signed-off-by: Reinhard Naegele --- cmd/helm/template.go | 81 ++++++++++--------- cmd/helm/template_test.go | 6 ++ .../output/template-with-invalid-yaml.txt | 13 +++ .../Chart.yaml | 8 ++ .../README.md | 13 +++ .../templates/alpine-pod.yaml | 10 +++ .../values.yaml | 1 + 7 files changed, 92 insertions(+), 40 deletions(-) create mode 100644 cmd/helm/testdata/output/template-with-invalid-yaml.txt create mode 100644 cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md create mode 100644 cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 320718344..54c3426c7 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -64,57 +64,58 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client.APIVersions = chartutil.VersionSet(extraAPIs) client.IncludeCRDs = includeCrds rel, err := runInstall(args, client, valueOpts, out) - if err != nil { - return err - } - var manifests bytes.Buffer - fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) + // We ignore a potential error here because we always want to print the YAML, + // even if it is not valid. The error is still returned afterwards. + if rel != nil { + var manifests bytes.Buffer + fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) - if !client.DisableHooks { - for _, m := range rel.Hooks { - fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) + if !client.DisableHooks { + for _, m := range rel.Hooks { + fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) + } } - } - // if we have a list of files to render, then check that each of the - // provided files exists in the chart. - if len(showFiles) > 0 { - splitManifests := releaseutil.SplitManifests(manifests.String()) - manifestNameRegex := regexp.MustCompile("# Source: [^/]+/(.+)") - var manifestsToRender []string - for _, f := range showFiles { - missing := true - for _, manifest := range splitManifests { - submatch := manifestNameRegex.FindStringSubmatch(manifest) - if len(submatch) == 0 { - continue + // if we have a list of files to render, then check that each of the + // provided files exists in the chart. + if len(showFiles) > 0 { + splitManifests := releaseutil.SplitManifests(manifests.String()) + manifestNameRegex := regexp.MustCompile("# Source: [^/]+/(.+)") + var manifestsToRender []string + for _, f := range showFiles { + missing := true + for _, manifest := range splitManifests { + submatch := manifestNameRegex.FindStringSubmatch(manifest) + if len(submatch) == 0 { + continue + } + manifestName := submatch[1] + // manifest.Name is rendered using linux-style filepath separators on Windows as + // well as macOS/linux. + manifestPathSplit := strings.Split(manifestName, "/") + manifestPath := filepath.Join(manifestPathSplit...) + + // if the filepath provided matches a manifest path in the + // chart, render that manifest + if f == manifestPath { + manifestsToRender = append(manifestsToRender, manifest) + missing = false + } } - manifestName := submatch[1] - // manifest.Name is rendered using linux-style filepath separators on Windows as - // well as macOS/linux. - manifestPathSplit := strings.Split(manifestName, "/") - manifestPath := filepath.Join(manifestPathSplit...) - - // if the filepath provided matches a manifest path in the - // chart, render that manifest - if f == manifestPath { - manifestsToRender = append(manifestsToRender, manifest) - missing = false + if missing { + return fmt.Errorf("could not find template %s in chart", f) } } - if missing { - return fmt.Errorf("could not find template %s in chart", f) + for _, m := range manifestsToRender { + fmt.Fprintf(out, "---\n%s\n", m) } + } else { + fmt.Fprintf(out, "%s", manifests.String()) } - for _, m := range manifestsToRender { - fmt.Fprintf(out, "---\n%s\n", m) - } - } else { - fmt.Fprintf(out, "%s", manifests.String()) } - return nil + return err }, } diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index dc7987d01..9e3087596 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -102,6 +102,12 @@ func TestTemplateCmd(t *testing.T) { // don't accidentally get the expected result. repeat: 10, }, + { + name: "chart with template with invalid yaml", + cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/chart-with-template-with-invalid-yaml"), + wantError: true, + golden: "output/template-with-invalid-yaml.txt", + }, } runTestCmd(t, tests) } diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml.txt b/cmd/helm/testdata/output/template-with-invalid-yaml.txt new file mode 100644 index 000000000..c1f51185c --- /dev/null +++ b/cmd/helm/testdata/output/template-with-invalid-yaml.txt @@ -0,0 +1,13 @@ +--- +# Source: chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml +apiVersion: v1 +kind: Pod +metadata: + name: "RELEASE-NAME-my-alpine" +spec: + containers: + - name: waiter + image: "alpine:3.9" + command: ["/bin/sleep","9000"] +invalid +Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':' diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml new file mode 100644 index 000000000..29b477b06 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +description: Deploy a basic Alpine Linux pod +home: https://helm.sh/helm +name: chart-with-template-with-invalid-yaml +sources: + - https://github.com/helm/helm +version: 0.1.0 +type: application diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md new file mode 100644 index 000000000..fcf7ee017 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/README.md @@ -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 ./alpine`. diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml new file mode 100644 index 000000000..697cb50fe --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{.Release.Name}}-{{.Values.Name}}" +spec: + containers: + - name: waiter + image: "alpine:3.9" + command: ["/bin/sleep","9000"] +invalid diff --git a/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml new file mode 100644 index 000000000..807e12aea --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-with-template-with-invalid-yaml/values.yaml @@ -0,0 +1 @@ +Name: my-alpine From 8528548441b826533d896ebf01b6a0c911eff6d8 Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Fri, 7 Feb 2020 18:16:16 -0500 Subject: [PATCH 231/279] fix recursion count in templates Signed-off-by: Daniel Cheng --- pkg/engine/engine.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 490561037..1cc94d685 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -120,6 +120,7 @@ func (e Engine) initFunMap(t *template.Template, referenceTpls map[string]render includedNames[name] = 1 } err := t.ExecuteTemplate(&buf, name, data) + includedNames[name]-- return buf.String(), err } From 206d4a90539e09c4d36aec6cebbdd6f96279b34a Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Mon, 10 Feb 2020 12:25:41 -0500 Subject: [PATCH 232/279] add test for template recursion Signed-off-by: Daniel Cheng --- pkg/engine/engine_test.go | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go index f3609fcbd..d5f36aac8 100644 --- a/pkg/engine/engine_test.go +++ b/pkg/engine/engine_test.go @@ -643,3 +643,58 @@ func TestAlterFuncMap_tplinclude(t *testing.T) { } } + +func TestRenderRecursionLimit(t *testing.T) { + // endless recursion should produce an error + c := &chart.Chart{ + Metadata: &chart.Metadata{Name: "bad"}, + Templates: []*chart.File{ + {Name: "templates/base", Data: []byte(`{{include "recursion" . }}`)}, + {Name: "templates/recursion", Data: []byte(`{{define "recursion"}}{{include "recursion" . }}{{end}}`)}, + }, + } + v := chartutil.Values{ + "Values": "", + "Chart": c.Metadata, + "Release": chartutil.Values{ + "Name": "TestRelease", + }, + } + expectErr := "rendering template has a nested reference name: recursion: unable to execute template" + + _, err := Render(c, v) + if err == nil || !strings.HasSuffix(err.Error(), expectErr) { + t.Errorf("Expected err with suffix: %s", expectErr) + } + + // calling the same function many times is ok + times := 4000 + phrase := "All work and no play makes Jack a dull boy" + printFunc := `{{define "overlook"}}{{printf "` + phrase + `\n"}}{{end}}` + var repeatedIncl string + for i := 0; i < times; i++ { + repeatedIncl += `{{include "overlook" . }}` + } + + d := &chart.Chart{ + Metadata: &chart.Metadata{Name: "overlook"}, + Templates: []*chart.File{ + {Name: "templates/quote", Data: []byte(repeatedIncl)}, + {Name: "templates/_function", Data: []byte(printFunc)}, + }, + } + + out, err := Render(d, v) + if err != nil { + t.Fatal(err) + } + + var expect string + for i := 0; i < times; i++ { + expect += phrase + "\n" + } + if got := out["overlook/templates/quote"]; got != expect { + t.Errorf("Expected %q, got %q (%v)", expect, got, out) + } + +} From e3965e11852f908646d2c02f55fd463c4b755538 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 7 Feb 2020 20:27:39 -0500 Subject: [PATCH 233/279] fix(comp): Fix broken completion for --output flag For commands using the new post-render flag, the completion for the --output flag was broken. For example: helm install -o __helm_handle_reply:47: command not found: __helm_output_options The bash __helm_output_options function is no longer used but was referred to by mistake. This commit removes the offending code. Signed-off-by: Marc Khouzam --- cmd/helm/flags.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 86ed53d51..246cb0dd5 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -99,8 +99,6 @@ func (o *outputValue) Set(s string) error { func bindPostRenderFlag(cmd *cobra.Command, varRef *postrender.PostRenderer) { cmd.Flags().Var(&postRenderer{varRef}, postRenderFlag, "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path") - // Setup shell completion for the flag - cmd.MarkFlagCustom(outputFlag, "__helm_output_options") } type postRenderer struct { From 8e9c62b1bc3c557a1d2cc88a8e4fdc83ef498cb5 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 10 Feb 2020 13:32:23 -0500 Subject: [PATCH 234/279] Fix shasums to be usable by shasum and sha256sum applications When #7277 was merged is was intended to create shasums accessible in a way shasum -c or sha256sum could use to verify the files the Helm project ships. The solution created a new file named shasums.txt. This setup contained a few problems: 1. The new file file was not uploaded to get.helm.sh for someone to download and use. 2. The file had not version in the naming or path. This means that each new release of Helm will overwrite it. Downloading and validating an old file is impossible. 3. If one downloads a single file, the shasums.txt file, and uses shasum -c it will return an exit code that is 1. This is because of missing files as it is looking for all the files from the release. 4. The shasums.txt file is not signed for verification like the other files. This change fixes these problems with the following changes: * Instead of a shasums.txt file there is a .sha256sum file for each package. For example, helm-3.1.0-linux-amd64.zip.sha256sum. This file will can be used with `shasum -a 256 -c` to verify the single file helm-3.1.0-linux-amd64.zip. The exit code of checking a single file is 0 if the file passes. * This new .sha256sum file is signed just like the .tar.gz, .zip, and .sha256 files. The provenance can be verified. * The file name starts with `helm-` meaning the existing upload script in the deploy.sh file will move it to get.helm.sh. Note, the existing .sha256 file can be deprecated and removed in Helm v4 with the new .sha256sum file taking over. But, for backwards compatibility with scripts it needs to be kept during v3. Closes #7567 Signed-off-by: Matt Farina --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 379a7486b..eea3b1e9c 100644 --- a/Makefile +++ b/Makefile @@ -157,15 +157,22 @@ fetch-dist: .PHONY: sign sign: - for f in _dist/*.{gz,zip,sha256} ; do \ + for f in _dist/*.{gz,zip,sha256,sha256sum} ; do \ gpg --armor --detach-sign $${f} ; \ done +# The contents of the .sha256sum file are compatible with tools like +# shasum. For example, using the following command will verify +# the file helm-3.1.0-rc.1-darwin-amd64.tar.gz: +# shasum -a 256 -c helm-3.1.0-rc.1-darwin-amd64.tar.gz.sha256sum +# The .sha256 files hold only the hash and are not compatible with +# verification tools like shasum or sha256sum. This method and file can be +# removed in Helm v4. .PHONY: checksum checksum: - @if [ -f "_dist/shasums.txt" ]; then >_dist/shasums.txt; fi for f in _dist/*.{gz,zip} ; do \ - shasum -a 256 "$${f}" | sed 's/_dist\///' | tee -a "_dist/shasums.txt" | awk '{print $$1}' > "$${f}.sha256" ; \ + shasum -a 256 "$${f}" | sed 's/_dist\///' > "$${f}.sha256sum" ; \ + shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \ done # ------------------------------------------------------------------------------ From af0007c9087c3e714aafc2bdac80bb55df6dbffd Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Tue, 11 Feb 2020 09:53:32 +0100 Subject: [PATCH 235/279] fix(helm): improved logs Signed-off-by: Federico Bevione --- pkg/kube/wait.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 7ea02d382..0254a60bb 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -189,7 +189,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { // Make sure the service is not explicitly set to "None" before checking the IP if s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "" { - w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + w.log("Service does not have cluster IP address: %s/%s", s.GetNamespace(), s.GetName()) return false } @@ -202,7 +202,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { } if s.Status.LoadBalancer.Ingress == nil { - w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + w.log("Service does not have load balancer ingress IP address: %s/%s", s.GetNamespace(), s.GetName()) return false } } From 5e638e3587bff303cd54fe34066d8687a1a60165 Mon Sep 17 00:00:00 2001 From: Benn Linger Date: Tue, 11 Feb 2020 15:46:28 -0500 Subject: [PATCH 236/279] Revert "Do not delete templated CRDs" This reverts commit 9711d1c6bfd9cd0cebe47b069a18cfc83ac3bfee. Resolves issue #7505. Signed-off-by: Benn Linger --- pkg/kube/client.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 215fc8308..9243f4361 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -209,11 +209,6 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err } for _, info := range original.Difference(target) { - if info.Mapping.GroupVersionKind.Kind == "CustomResourceDefinition" { - c.Log("Skipping the deletion of CustomResourceDefinition %q", info.Name) - continue - } - c.Log("Deleting %q in %s...", info.Name, info.Namespace) res.Deleted = append(res.Deleted, info) if err := deleteResource(info); err != nil { @@ -236,11 +231,6 @@ func (c *Client) Delete(resources ResourceList) (*Result, []error) { var errs []error res := &Result{} err := perform(resources, func(info *resource.Info) error { - if info.Mapping.GroupVersionKind.Kind == "CustomResourceDefinition" { - c.Log("Skipping the deletion of CustomResourceDefinition %q", info.Name) - return nil - } - c.Log("Starting delete for %q %s", info.Name, info.Mapping.GroupVersionKind.Kind) if err := c.skipIfNotFound(deleteResource(info)); err != nil { // Collect the error and continue on From b55224ebb9541b690daca59f6d85867c6e275d75 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Tue, 14 Jan 2020 17:08:44 +0100 Subject: [PATCH 237/279] fix(kube): use non global Scheme to convert But instead use a newly initialized Scheme with only Kubernetes native resources added. This ensures the 3-way-merge patch strategy is not accidentally chosen for custom resources due to them being added to the global Scheme by e.g. versioned clients while using Helm as a package, and not a self-contained binary. Signed-off-by: Hidde Beydals --- pkg/kube/converter.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/kube/converter.go b/pkg/kube/converter.go index a5a6ae1f7..7f062213c 100644 --- a/pkg/kube/converter.go +++ b/pkg/kube/converter.go @@ -17,9 +17,12 @@ limitations under the License. package kube // import "helm.sh/helm/v3/pkg/kube" import ( + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes/scheme" ) @@ -33,12 +36,28 @@ func AsVersioned(info *resource.Info) runtime.Object { // convertWithMapper converts the given object with the optional provided // RESTMapping. If no mapping is provided, the default schema versioner is used func convertWithMapper(obj runtime.Object, mapping *meta.RESTMapping) runtime.Object { - var gv = runtime.GroupVersioner(schema.GroupVersions(scheme.Scheme.PrioritizedVersionsAllGroups())) + s := kubernetesNativeScheme() + var gv = runtime.GroupVersioner(schema.GroupVersions(s.PrioritizedVersionsAllGroups())) if mapping != nil { gv = mapping.GroupVersionKind.GroupVersion() } - if obj, err := runtime.ObjectConvertor(scheme.Scheme).ConvertToVersion(obj, gv); err == nil { + if obj, err := runtime.ObjectConvertor(s).ConvertToVersion(obj, gv); err == nil { return obj } return obj } + +// kubernetesNativeScheme returns a clean *runtime.Scheme with _only_ Kubernetes +// native resources added to it. This is required to break free of custom resources +// that may have been added to scheme.Scheme due to Helm being used as a package in +// combination with e.g. a versioned kube client. If we would not do this, the client +// may attempt to perform e.g. a 3-way-merge strategy patch for custom resources. +func kubernetesNativeScheme() *runtime.Scheme { + s := runtime.NewScheme() + utilruntime.Must(scheme.AddToScheme(s)) + // API extensions are not in the above scheme set, + // and must thus be added separately. + utilruntime.Must(apiextensionsv1beta1.AddToScheme(s)) + utilruntime.Must(apiextensionsv1.AddToScheme(s)) + return s +} From e41184a585800dd672856d422b4f8a2bd3d430e0 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Tue, 11 Feb 2020 23:52:00 +0100 Subject: [PATCH 238/279] fix(kube): generate k8s native scheme only once Signed-off-by: Hidde Beydals --- pkg/kube/converter.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/kube/converter.go b/pkg/kube/converter.go index 7f062213c..3bf0e358c 100644 --- a/pkg/kube/converter.go +++ b/pkg/kube/converter.go @@ -17,16 +17,20 @@ limitations under the License. package kube // import "helm.sh/helm/v3/pkg/kube" import ( + "sync" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/kubernetes/scheme" ) +var k8sNativeScheme *runtime.Scheme +var k8sNativeSchemeOnce sync.Once + // AsVersioned converts the given info into a runtime.Object with the correct // group and version set func AsVersioned(info *resource.Info) runtime.Object { @@ -53,11 +57,13 @@ func convertWithMapper(obj runtime.Object, mapping *meta.RESTMapping) runtime.Ob // combination with e.g. a versioned kube client. If we would not do this, the client // may attempt to perform e.g. a 3-way-merge strategy patch for custom resources. func kubernetesNativeScheme() *runtime.Scheme { - s := runtime.NewScheme() - utilruntime.Must(scheme.AddToScheme(s)) - // API extensions are not in the above scheme set, - // and must thus be added separately. - utilruntime.Must(apiextensionsv1beta1.AddToScheme(s)) - utilruntime.Must(apiextensionsv1.AddToScheme(s)) - return s + k8sNativeSchemeOnce.Do(func() { + k8sNativeScheme = runtime.NewScheme() + scheme.AddToScheme(k8sNativeScheme) + // API extensions are not in the above scheme set, + // and must thus be added separately. + apiextensionsv1beta1.AddToScheme(k8sNativeScheme) + apiextensionsv1.AddToScheme(k8sNativeScheme) + }) + return k8sNativeScheme } From a35e124b6674d303dbed1c2b27b4b7728b379a55 Mon Sep 17 00:00:00 2001 From: Reinhard Naegele Date: Wed, 12 Feb 2020 20:28:46 +0100 Subject: [PATCH 239/279] Place rendering invalid YAML under --debug flag Signed-off-by: Reinhard Naegele --- cmd/helm/template.go | 11 +++++++++-- cmd/helm/template_test.go | 6 ++++++ .../output/template-with-invalid-yaml-debug.txt | 13 +++++++++++++ .../testdata/output/template-with-invalid-yaml.txt | 14 ++------------ 4 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 54c3426c7..22565d3e3 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -65,8 +65,15 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client.IncludeCRDs = includeCrds rel, err := runInstall(args, client, valueOpts, out) - // We ignore a potential error here because we always want to print the YAML, - // even if it is not valid. The error is still returned afterwards. + if err != nil && !settings.Debug { + if rel != nil { + return fmt.Errorf("%w\n\nUse --debug flag to render out invalid YAML", err) + } + return err + } + + // We ignore a potential error here because, when the --debug flag was specified, + // we always want to print the YAML, even if it is not valid. The error is still returned afterwards. if rel != nil { var manifests bytes.Buffer fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 9e3087596..3fd139fad 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -108,6 +108,12 @@ func TestTemplateCmd(t *testing.T) { wantError: true, golden: "output/template-with-invalid-yaml.txt", }, + { + name: "chart with template with invalid yaml (--debug)", + cmd: fmt.Sprintf("template '%s' --debug", "testdata/testcharts/chart-with-template-with-invalid-yaml"), + wantError: true, + golden: "output/template-with-invalid-yaml-debug.txt", + }, } runTestCmd(t, tests) } diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt b/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt new file mode 100644 index 000000000..c1f51185c --- /dev/null +++ b/cmd/helm/testdata/output/template-with-invalid-yaml-debug.txt @@ -0,0 +1,13 @@ +--- +# Source: chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml +apiVersion: v1 +kind: Pod +metadata: + name: "RELEASE-NAME-my-alpine" +spec: + containers: + - name: waiter + image: "alpine:3.9" + command: ["/bin/sleep","9000"] +invalid +Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':' diff --git a/cmd/helm/testdata/output/template-with-invalid-yaml.txt b/cmd/helm/testdata/output/template-with-invalid-yaml.txt index c1f51185c..687227b90 100644 --- a/cmd/helm/testdata/output/template-with-invalid-yaml.txt +++ b/cmd/helm/testdata/output/template-with-invalid-yaml.txt @@ -1,13 +1,3 @@ ---- -# Source: chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "RELEASE-NAME-my-alpine" -spec: - containers: - - name: waiter - image: "alpine:3.9" - command: ["/bin/sleep","9000"] -invalid Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':' + +Use --debug flag to render out invalid YAML From afdfb75234af3907b5e7fdf19b92ea4f6ce35126 Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Sat, 14 Dec 2019 05:59:32 +0530 Subject: [PATCH 240/279] Pass kube user token via cli, introduce HELM_KUBETOKEN envvar Signed-off-by: Vibhav Bobade --- pkg/cli/environment.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 5f947aec7..16127c1cd 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -46,6 +46,8 @@ type EnvSettings struct { KubeConfig string // KubeContext is the name of the kubeconfig context. KubeContext string + // Bearer Token used for authentication + Token string // Debug indicates whether or not Helm is running in Debug mode. Debug bool // RegistryConfig is the path to the registry config file. @@ -77,6 +79,7 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) { fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request") fs.StringVar(&s.KubeConfig, "kubeconfig", "", "path to the kubeconfig file") fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use") + fs.StringVar(&s.Token, "token", s.Token, "bearer token used for authentication") fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output") fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file") fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs") @@ -100,6 +103,7 @@ func (s *EnvSettings) EnvVars() map[string]string { "HELM_REPOSITORY_CONFIG": s.RepositoryConfig, "HELM_NAMESPACE": s.Namespace(), "HELM_KUBECONTEXT": s.KubeContext, + "HELM_KUBETOKEN": s.Token, } if s.KubeConfig != "" { @@ -124,7 +128,9 @@ func (s *EnvSettings) Namespace() string { //RESTClientGetter gets the kubeconfig from EnvSettings func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { s.configOnce.Do(func() { - s.config = kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace) + clientConfig := kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace) + clientConfig.BearerToken = &s.Token + s.config = clientConfig }) return s.config } From 89fdbdf3d0cd4777c961330a8f0de7628a461768 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Thu, 13 Feb 2020 12:02:23 -0500 Subject: [PATCH 241/279] Making fetch-dist get the sha256sum files Fetching these files is part of the release process. When the new file type was added this step was missed. It will cause the sign make target to fail. Signed-off-by: Matt Farina --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eea3b1e9c..d7954de50 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BINDIR := $(CURDIR)/bin DIST_DIRS := find * -type d -exec TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64 -TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-386.tar.gz linux-386.tar.gz.sha256 linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 linux-s390x.tar.gz linux-s390x.tar.gz.sha256 windows-amd64.zip windows-amd64.zip.sha256 +TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 darwin-amd64.tar.gz.sha256sum linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-amd64.tar.gz.sha256sum linux-386.tar.gz linux-386.tar.gz.sha256 linux-386.tar.gz.sha256sum linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm.tar.gz.sha256sum linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-arm64.tar.gz.sha256sum linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 linux-ppc64le.tar.gz.sha256sum linux-s390x.tar.gz linux-s390x.tar.gz.sha256 linux-s390x.tar.gz.sha256sum windows-amd64.zip windows-amd64.zip.sha256 windows-amd64.zip.sha256sum BINNAME ?= helm GOPATH = $(shell go env GOPATH) From 2a7421299148694471ded8e2f60a82e8c74c7fc8 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Thu, 13 Feb 2020 12:19:05 -0500 Subject: [PATCH 242/279] ref(go.mod): k8s api 0.17.3 Signed-off-by: Rui Chen --- go.mod | 12 ++++++------ go.sum | 36 +++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 696c2b6d2..9c22ea9e5 100644 --- a/go.mod +++ b/go.mod @@ -29,13 +29,13 @@ require ( github.com/stretchr/testify v1.4.0 github.com/xeipuuv/gojsonschema v1.1.0 golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d - k8s.io/api v0.17.2 - k8s.io/apiextensions-apiserver v0.17.2 - k8s.io/apimachinery v0.17.2 - k8s.io/cli-runtime v0.17.2 - k8s.io/client-go v0.17.2 + k8s.io/api v0.17.3 + k8s.io/apiextensions-apiserver v0.17.3 + k8s.io/apimachinery v0.17.3 + k8s.io/cli-runtime v0.17.3 + k8s.io/client-go v0.17.3 k8s.io/klog v1.0.0 - k8s.io/kubectl v0.17.2 + k8s.io/kubectl v0.17.3 sigs.k8s.io/yaml v1.1.0 ) diff --git a/go.sum b/go.sum index cc6b8dd9c..89c7762d5 100644 --- a/go.sum +++ b/go.sum @@ -630,25 +630,27 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.17.2 h1:NF1UFXcKN7/OOv1uxdRz3qfra8AHsPav5M93hlV9+Dc= -k8s.io/api v0.17.2/go.mod h1:BS9fjjLc4CMuqfSO8vgbHPKMt5+SF0ET6u/RVDihTo4= -k8s.io/apiextensions-apiserver v0.17.2 h1:cP579D2hSZNuO/rZj9XFRzwJNYb41DbNANJb6Kolpss= -k8s.io/apiextensions-apiserver v0.17.2/go.mod h1:4KdMpjkEjjDI2pPfBA15OscyNldHWdBCfsWMDWAmSTs= -k8s.io/apimachinery v0.17.2 h1:hwDQQFbdRlpnnsR64Asdi55GyCaIP/3WQpMmbNBeWr4= -k8s.io/apimachinery v0.17.2/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apiserver v0.17.2/go.mod h1:lBmw/TtQdtxvrTk0e2cgtOxHizXI+d0mmGQURIHQZlo= -k8s.io/cli-runtime v0.17.2 h1:YH4txSplyGudvxjhAJeHEtXc7Tr/16clKGfN076ydGk= -k8s.io/cli-runtime v0.17.2/go.mod h1:aa8t9ziyQdbkuizkNLAw3qe3srSyWh9zlSB7zTqRNPI= -k8s.io/client-go v0.17.2 h1:ndIfkfXEGrNhLIgkr0+qhRguSD3u6DCmonepn1O6NYc= -k8s.io/client-go v0.17.2/go.mod h1:QAzRgsa0C2xl4/eVpeVAZMvikCn8Nm81yqVx3Kk9XYI= -k8s.io/code-generator v0.17.2/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= -k8s.io/component-base v0.17.2 h1:0XHf+cerTvL9I5Xwn9v+0jmqzGAZI7zNydv4tL6Cw6A= -k8s.io/component-base v0.17.2/go.mod h1:zMPW3g5aH7cHJpKYQ/ZsGMcgbsA/VyhEugF3QT1awLs= +k8s.io/api v0.17.3 h1:XAm3PZp3wnEdzekNkcmj/9Y1zdmQYJ1I4GKSBBZ8aG0= +k8s.io/api v0.17.3/go.mod h1:YZ0OTkuw7ipbe305fMpIdf3GLXZKRigjtZaV5gzC2J0= +k8s.io/apiextensions-apiserver v0.17.3 h1:WDZWkPcbgvchEdDd7ysL21GGPx3UKZQLDZXEkevT6n4= +k8s.io/apiextensions-apiserver v0.17.3/go.mod h1:CJbCyMfkKftAd/X/V6OTHYhVn7zXnDdnkUjS1h0GTeY= +k8s.io/apimachinery v0.17.3 h1:f+uZV6rm4/tHE7xXgLyToprg6xWairaClGVkm2t8omg= +k8s.io/apimachinery v0.17.3/go.mod h1:gxLnyZcGNdZTCLnq3fgzyg2A5BVCHTNDFrw8AmuJ+0g= +k8s.io/apiserver v0.17.3/go.mod h1:iJtsPpu1ZpEnHaNawpSV0nYTGBhhX2dUlnn7/QS7QiY= +k8s.io/cli-runtime v0.17.3 h1:0ZlDdJgJBKsu77trRUynNiWsRuAvAVPBNaQfnt/1qtc= +k8s.io/cli-runtime v0.17.3/go.mod h1:X7idckYphH4SZflgNpOOViSxetiMj6xI0viMAjM81TA= +k8s.io/client-go v0.17.3 h1:deUna1Ksx05XeESH6XGCyONNFfiQmDdqeqUvicvP6nU= +k8s.io/client-go v0.17.3/go.mod h1:cLXlTMtWHkuK4tD360KpWz2gG2KtdWEr/OT02i3emRQ= +k8s.io/code-generator v0.17.3/go.mod h1:l8BLVwASXQZTo2xamW5mQNFCe1XPiAesVq7Y1t7PiQQ= +k8s.io/component-base v0.17.3 h1:hQzTSshY14aLSR6WGIYvmw+w+u6V4d+iDR2iDGMrlUg= +k8s.io/component-base v0.17.3/go.mod h1:GeQf4BrgelWm64PXkIXiPh/XS0hnO42d9gx9BtbZRp8= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= @@ -657,10 +659,10 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kubectl v0.17.2 h1:QZR8Q6lWiVRjwKslekdbN5WPMp53dS/17j5e+oi5XVU= -k8s.io/kubectl v0.17.2/go.mod h1:y4rfLV0n6aPmvbRCqZQjvOp3ezxsFgpqL+zF5jH/lxk= +k8s.io/kubectl v0.17.3 h1:9HHYj07kuFkM+sMJMOyQX29CKWq4lvKAG1UIPxNPMQ4= +k8s.io/kubectl v0.17.3/go.mod h1:NUn4IBY7f7yCMwSop2HCXlw/MVYP4HJBiUmOR3n9w28= k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= -k8s.io/metrics v0.17.2/go.mod h1:3TkNHET4ROd+NfzNxkjoVfQ0Ob4iZnaHmSEA4vYpwLw= +k8s.io/metrics v0.17.3/go.mod h1:HEJGy1fhHOjHggW9rMDBJBD3YuGroH3Y1pnIRw9FFaI= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= From 561971c381bfee69fbfae1c396641856f7bb2c9e Mon Sep 17 00:00:00 2001 From: Sebastian Voinea Date: Tue, 11 Feb 2020 21:44:15 +0100 Subject: [PATCH 243/279] feat(upgrade): introduce --disable-openapi-validation: This is a copy of the --disable-openapi-validation flag from the install command as introduced by Matthew Fisher. See commit 67e57a5fbb7b210e534157b8f67c15ffc3445453 It allows upgrading releases without the need to validate the Kubernetes OpenAPI Schema. Signed-off-by: Sebastian Voinea --- cmd/helm/upgrade.go | 2 ++ pkg/action/upgrade.go | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 54badb32c..119d79f8f 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -109,6 +109,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { instClient.Namespace = client.Namespace instClient.Atomic = client.Atomic instClient.PostRenderer = client.PostRenderer + instClient.DisableOpenAPIValidation = client.DisableOpenAPIValidation rel, err := runInstall(args, instClient, valueOpts, out) if err != nil { @@ -165,6 +166,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.MarkDeprecated("recreate-pods", "functionality will no longer be updated. Consult the documentation for other methods to recreate pods") f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") f.BoolVar(&client.DisableHooks, "no-hooks", false, "disable pre/post upgrade hooks") + f.BoolVar(&client.DisableOpenAPIValidation, "disable-openapi-validation", false, "if set, the upgrade process will not validate rendered templates against the Kubernetes OpenAPI Schema") f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&client.ResetValues, "reset-values", false, "when upgrading, reset the values to the ones built into the chart") f.BoolVar(&client.ReuseValues, "reuse-values", false, "when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored") diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 825920793..08b638171 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -55,12 +55,13 @@ type Upgrade struct { // Recreate will (if true) recreate pods after a rollback. Recreate bool // MaxHistory limits the maximum number of revisions saved per release - MaxHistory int - Atomic bool - CleanupOnFail bool - SubNotes bool - Description string - PostRenderer postrender.PostRenderer + MaxHistory int + Atomic bool + CleanupOnFail bool + SubNotes bool + Description string + PostRenderer postrender.PostRenderer + DisableOpenAPIValidation bool } // NewUpgrade creates a new Upgrade object with the given configuration. @@ -188,7 +189,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin if len(notesTxt) > 0 { upgradedRelease.Info.Notes = notesTxt } - err = validateManifest(u.cfg.KubeClient, manifestDoc.Bytes()) + err = validateManifest(u.cfg.KubeClient, manifestDoc.Bytes(), !u.DisableOpenAPIValidation) return currentRelease, upgradedRelease, err } @@ -197,7 +198,7 @@ func (u *Upgrade) performUpgrade(originalRelease, upgradedRelease *release.Relea if err != nil { return upgradedRelease, errors.Wrap(err, "unable to build kubernetes objects from current release manifest") } - target, err := u.cfg.KubeClient.Build(bytes.NewBufferString(upgradedRelease.Manifest), true) + target, err := u.cfg.KubeClient.Build(bytes.NewBufferString(upgradedRelease.Manifest), !u.DisableOpenAPIValidation) if err != nil { return upgradedRelease, errors.Wrap(err, "unable to build kubernetes objects from new release manifest") } @@ -383,8 +384,8 @@ func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release, newV return newVals, nil } -func validateManifest(c kube.Interface, manifest []byte) error { - _, err := c.Build(bytes.NewReader(manifest), true) +func validateManifest(c kube.Interface, manifest []byte, openAPIValidation bool) error { + _, err := c.Build(bytes.NewReader(manifest), openAPIValidation) return err } From 0087d838073abcc93fb9ea694256e0b93238ae23 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 13 Feb 2020 16:20:15 -0800 Subject: [PATCH 244/279] fix(scripts): scrape for the latest v2/v3 release from the releases page Signed-off-by: Matthew Fisher --- scripts/get | 16 +++++++--------- scripts/get-helm-3 | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/get b/scripts/get index 711635ee3..3da11d4a4 100755 --- a/scripts/get +++ b/scripts/get @@ -78,16 +78,14 @@ verifySupported() { # checkDesiredVersion checks if the desired version is available. checkDesiredVersion() { if [ "x$DESIRED_VERSION" == "x" ]; then - # FIXME(bacongobbler): hard code the desired version for the time being. - # A better fix would be to filter for Helm 2 release pages. - TAG="v2.16.1" # Get tag from release URL - # local latest_release_url="https://github.com/helm/helm/releases/latest" - # if type "curl" > /dev/null; then - # TAG=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) - # elif type "wget" > /dev/null; then - # TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") - # fi + local release_url="https://github.com/helm/helm/releases" + if type "curl" > /dev/null; then + + TAG=$(curl -Ls $release_url | grep 'href="/helm/helm/releases/tag/v2.' | grep -v no-underline | head -n 1 | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}') + elif type "wget" > /dev/null; then + TAG=$(wget $release_url -O - 2>&1 | grep 'href="/helm/helm/releases/tag/v2.' | grep -v no-underline | head -n 1 | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}') + fi else TAG=$DESIRED_VERSION fi diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 index c1655a68e..a974d97b6 100755 --- a/scripts/get-helm-3 +++ b/scripts/get-helm-3 @@ -78,11 +78,11 @@ verifySupported() { checkDesiredVersion() { if [ "x$DESIRED_VERSION" == "x" ]; then # Get tag from release URL - local latest_release_url="https://github.com/helm/helm/releases/latest" + local latest_release_url="https://github.com/helm/helm/releases" if type "curl" > /dev/null; then - TAG=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) + TAG=$(curl -Ls $latest_release_url | grep 'href="/helm/helm/releases/tag/v3.' | grep -v no-underline | head -n 1 | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}') elif type "wget" > /dev/null; then - TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") + TAG=$(wget $latest_release_url -O - 2>&1 | grep 'href="/helm/helm/releases/tag/v3.' | grep -v no-underline | head -n 1 | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}') fi else TAG=$DESIRED_VERSION From 54ca8790955f0393ad60acc36383dba032755c9f Mon Sep 17 00:00:00 2001 From: ylvmw Date: Fri, 14 Feb 2020 09:57:08 +0800 Subject: [PATCH 245/279] IsReachable() needs to give detailed error message. Signed-off-by: ylvmw --- pkg/kube/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 9243f4361..31dabcc5d 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -88,7 +88,7 @@ func (c *Client) IsReachable() error { client, _ := c.Factory.KubernetesClientSet() _, err := client.ServerVersion() if err != nil { - return errors.New("Kubernetes cluster unreachable") + return fmt.Errorf("Kubernetes cluster unreachable: %s", err.Error()) } return nil } From 7b9dc71c25f0dea9013d2174b45f16fa202468c3 Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Fri, 14 Feb 2020 15:30:26 +0000 Subject: [PATCH 246/279] Fix render error not being propogated Signed-off-by: Martin Hickey --- pkg/action/action_test.go | 14 ++++++++++++++ pkg/action/install.go | 2 +- pkg/action/install_test.go | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index df6a48e7f..36ef261a3 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -230,6 +230,20 @@ func withSampleTemplates() chartOption { } } +func withSampleIncludingIncorrectTemplates() chartOption { + return func(opts *chartOptions) { + sampleTemplates := []*chart.File{ + // This adds basic templates and partials. + {Name: "templates/goodbye", Data: []byte("goodbye: world")}, + {Name: "templates/empty", Data: []byte("")}, + {Name: "templates/incorrect", Data: []byte("{{ .Values.bad.doh }}")}, + {Name: "templates/with-partials", Data: []byte(`hello: {{ template "_planet" . }}`)}, + {Name: "templates/partials/_planet", Data: []byte(`{{define "_planet"}}Earth{{end}}`)}, + } + opts.Templates = append(opts.Templates, sampleTemplates...) + } +} + func withMultipleManifestTemplate() chartOption { return func(opts *chartOptions) { sampleTemplates := []*chart.File{ diff --git a/pkg/action/install.go b/pkg/action/install.go index 49c9b5728..79abfae33 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -460,7 +460,7 @@ func (c *Configuration) renderResources(ch *chart.Chart, values chartutil.Values } if err2 != nil { - return hs, b, "", err + return hs, b, "", err2 } // NOTES.txt gets rendered like all the other files, but because it's not a hook nor a resource, diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index ba350819d..bf47895a1 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -240,6 +240,21 @@ func TestInstallRelease_DryRun(t *testing.T) { is.Equal(res.Info.Description, "Dry run complete") } +func TestInstallReleaseIncorrectTemplate_DryRun(t *testing.T) { + is := assert.New(t) + instAction := installAction(t) + instAction.DryRun = true + vals := map[string]interface{}{} + _, err := instAction.Run(buildChart(withSampleIncludingIncorrectTemplates()), vals) + expectedErr := "\"hello/templates/incorrect\" at <.Values.bad.doh>: nil pointer evaluating interface {}.doh" + if err == nil { + t.Fatalf("Install should fail containing error: %s", expectedErr) + } + if err != nil { + is.Contains(err.Error(), expectedErr) + } +} + func TestInstallRelease_NoHooks(t *testing.T) { is := assert.New(t) instAction := installAction(t) From 03b04639f38f11b9f909ac0ddd86a82f7c43bb4c Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 17 Feb 2020 13:48:12 +0800 Subject: [PATCH 247/279] pkg/gates: add unit test for String Signed-off-by: Zhou Hao --- pkg/gates/gates_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/gates/gates_test.go b/pkg/gates/gates_test.go index a71d4905b..6bdd17ed6 100644 --- a/pkg/gates/gates_test.go +++ b/pkg/gates/gates_test.go @@ -45,3 +45,12 @@ func TestError(t *testing.T) { t.Errorf("incorrect error message. Received %s", g.Error().Error()) } } + +func TestString(t *testing.T) { + os.Unsetenv(name) + g := Gate(name) + + if g.String() != "HELM_EXPERIMENTAL_FEATURE" { + t.Errorf("incorrect string representation. Received %s", g.String()) + } +} From e085bfcb462a573aeb6e61613154d21981fe6035 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 17 Feb 2020 14:21:13 +0800 Subject: [PATCH 248/279] cmd/helm/search_repo: print info to stderr Signed-off-by: Zhou Hao --- cmd/helm/search_repo.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/helm/search_repo.go b/cmd/helm/search_repo.go index 9f5af1e3c..8a8ac379d 100644 --- a/cmd/helm/search_repo.go +++ b/cmd/helm/search_repo.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "io/ioutil" + "os" "path/filepath" "strings" @@ -102,7 +103,7 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command { func (o *searchRepoOptions) run(out io.Writer, args []string) error { o.setupSearchedVersion() - index, err := o.buildIndex(out) + index, err := o.buildIndex() if err != nil { return err } @@ -171,7 +172,7 @@ func (o *searchRepoOptions) applyConstraint(res []*search.Result) ([]*search.Res return data, nil } -func (o *searchRepoOptions) buildIndex(out io.Writer) (*search.Index, error) { +func (o *searchRepoOptions) buildIndex() (*search.Index, error) { // Load the repositories.yaml rf, err := repo.LoadFile(o.repoFile) if isNotExist(err) || len(rf.Repositories) == 0 { @@ -184,8 +185,7 @@ func (o *searchRepoOptions) buildIndex(out io.Writer) (*search.Index, error) { f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n)) ind, err := repo.LoadIndexFile(f) if err != nil { - // TODO should print to stderr - fmt.Fprintf(out, "WARNING: Repo %q is corrupt or missing. Try 'helm repo update'.", n) + fmt.Fprintf(os.Stderr, "WARNING: Repo %q is corrupt or missing. Try 'helm repo update'.", n) continue } From e9f40ed7a51b40966e4d91957357e6f6efc60251 Mon Sep 17 00:00:00 2001 From: Song Shukun Date: Tue, 18 Feb 2020 23:15:56 +0900 Subject: [PATCH 249/279] fix golint failure in pkg/action Signed-off-by: Song Shukun --- pkg/action/action.go | 3 ++- pkg/action/lint.go | 1 + pkg/action/list.go | 2 +- pkg/action/package.go | 1 + pkg/action/show.go | 9 +++++++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index a97533696..1af5b3d9a 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -135,6 +135,7 @@ func (c *Configuration) getCapabilities() (*chartutil.Capabilities, error) { return c.Capabilities, nil } +// KubernetesClientSet creates a new kubernetes ClientSet based on the configuration func (c *Configuration) KubernetesClientSet() (kubernetes.Interface, error) { conf, err := c.RESTClientGetter.ToRESTConfig() if err != nil { @@ -219,7 +220,7 @@ func (c *Configuration) recordRelease(r *release.Release) { } } -// InitActionConfig initializes the action configuration +// Init initializes the action configuration func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace string, helmDriver string, log DebugLog) error { kc := kube.New(getter) kc.Log = log diff --git a/pkg/action/lint.go b/pkg/action/lint.go index ddb0101c7..2292c14bf 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -38,6 +38,7 @@ type Lint struct { WithSubcharts bool } +// LintResult is the result of Lint type LintResult struct { TotalChartsLinted int Messages []support.Message diff --git a/pkg/action/list.go b/pkg/action/list.go index 5be60ac42..532f18385 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -238,7 +238,7 @@ func filterList(releases []*release.Release) []*release.Release { return list } -// setStateMask calculates the state mask based on parameters. +// SetStateMask calculates the state mask based on parameters. func (l *List) SetStateMask() { if l.All { l.StateMask = ListAll diff --git a/pkg/action/package.go b/pkg/action/package.go index b48fc65f0..19d845cf3 100644 --- a/pkg/action/package.go +++ b/pkg/action/package.go @@ -112,6 +112,7 @@ func setVersion(ch *chart.Chart, ver string) error { return nil } +// Clearsign signs a chart func (p *Package) Clearsign(filename string) error { // Load keyring signer, err := provenance.NewFromKeyring(p.Keyring, p.Key) diff --git a/pkg/action/show.go b/pkg/action/show.go index b29107d4e..14b59a5ea 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -27,12 +27,17 @@ import ( "helm.sh/helm/v3/pkg/chartutil" ) +// ShowOutputFormat is the format of the output of `helm show` type ShowOutputFormat string const ( - ShowAll ShowOutputFormat = "all" - ShowChart ShowOutputFormat = "chart" + // ShowAll is the format which shows all the information of a chart + ShowAll ShowOutputFormat = "all" + // ShowChart is the format which only shows the chart's definition + ShowChart ShowOutputFormat = "chart" + // ShowValues is the format which only shows the chart's values ShowValues ShowOutputFormat = "values" + // ShowReadme is the format which only shows the chart's README ShowReadme ShowOutputFormat = "readme" ) From eda60a59b61abc7fb20063d9dc0608fe877b3206 Mon Sep 17 00:00:00 2001 From: Song Shukun Date: Wed, 19 Feb 2020 16:52:28 +0900 Subject: [PATCH 250/279] pkg/helmpath: fix unit test for Windows Signed-off-by: Song Shukun --- pkg/helmpath/home_windows_test.go | 6 +++--- pkg/helmpath/lazypath_windows_test.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/helmpath/home_windows_test.go b/pkg/helmpath/home_windows_test.go index af74558a8..796ced62c 100644 --- a/pkg/helmpath/home_windows_test.go +++ b/pkg/helmpath/home_windows_test.go @@ -23,9 +23,9 @@ import ( ) func TestHelmHome(t *testing.T) { - os.Setenv(xdg.XDGCacheHomeEnvVar, "c:\\") - os.Setenv(xdg.XDGConfigHomeEnvVar, "d:\\") - os.Setenv(xdg.XDGDataHomeEnvVar, "e:\\") + os.Setenv(xdg.CacheHomeEnvVar, "c:\\") + os.Setenv(xdg.ConfigHomeEnvVar, "d:\\") + os.Setenv(xdg.DataHomeEnvVar, "e:\\") isEq := func(t *testing.T, a, b string) { if a != b { t.Errorf("Expected %q, got %q", b, a) diff --git a/pkg/helmpath/lazypath_windows_test.go b/pkg/helmpath/lazypath_windows_test.go index d02a0a7f6..866e7b9d9 100644 --- a/pkg/helmpath/lazypath_windows_test.go +++ b/pkg/helmpath/lazypath_windows_test.go @@ -32,7 +32,7 @@ const ( ) func TestDataPath(t *testing.T) { - os.Unsetenv(DataHomeEnvVar) + os.Unsetenv(xdg.DataHomeEnvVar) os.Setenv("APPDATA", filepath.Join(homedir.HomeDir(), "foo")) expected := filepath.Join(homedir.HomeDir(), "foo", appName, testFile) @@ -41,7 +41,7 @@ func TestDataPath(t *testing.T) { t.Errorf("expected '%s', got '%s'", expected, lazy.dataPath(testFile)) } - os.Setenv(DataHomeEnvVar, filepath.Join(homedir.HomeDir(), "xdg")) + os.Setenv(xdg.DataHomeEnvVar, filepath.Join(homedir.HomeDir(), "xdg")) expected = filepath.Join(homedir.HomeDir(), "xdg", appName, testFile) @@ -70,8 +70,8 @@ func TestConfigPath(t *testing.T) { } func TestCachePath(t *testing.T) { - os.Unsetenv(CacheHomeEnvVar) - os.Setenv("APPDATA", filepath.Join(homedir.HomeDir(), "foo")) + os.Unsetenv(xdg.CacheHomeEnvVar) + os.Setenv("TEMP", filepath.Join(homedir.HomeDir(), "foo")) expected := filepath.Join(homedir.HomeDir(), "foo", appName, testFile) @@ -79,7 +79,7 @@ func TestCachePath(t *testing.T) { t.Errorf("expected '%s', got '%s'", expected, lazy.cachePath(testFile)) } - os.Setenv(CacheHomeEnvVar, filepath.Join(homedir.HomeDir(), "xdg")) + os.Setenv(xdg.CacheHomeEnvVar, filepath.Join(homedir.HomeDir(), "xdg")) expected = filepath.Join(homedir.HomeDir(), "xdg", appName, testFile) From 4bd3b8fc06d3750174d52e3950800e67cfc63210 Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Mon, 16 Dec 2019 13:28:36 +0530 Subject: [PATCH 251/279] Pass the apiserver address/port via cli, introduce HELM_KUBEAPISERVER envvar Signed-off-by: Vibhav Bobade --- cmd/helm/load_plugins.go | 2 +- pkg/cli/environment.go | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index f2fb5c01d..610b187d9 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -127,7 +127,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { func manuallyProcessArgs(args []string) ([]string, []string) { known := []string{} unknown := []string{} - kvargs := []string{"--kube-context", "--namespace", "-n", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config"} + kvargs := []string{"--kube-context", "--namespace", "-n", "--kubeconfig", "--kube-apiserver", "--kube-token", "--registry-config", "--repository-cache", "--repository-config"} knownArg := func(a string) bool { for _, pre := range kvargs { if strings.HasPrefix(a, pre+"=") { diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 16127c1cd..1e3b23617 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -46,8 +46,10 @@ type EnvSettings struct { KubeConfig string // KubeContext is the name of the kubeconfig context. KubeContext string - // Bearer Token used for authentication - Token string + // Bearer KubeToken used for authentication + KubeToken string + // Kubernetes API Server Endpoint for authentication + KubeAPIServer string // Debug indicates whether or not Helm is running in Debug mode. Debug bool // RegistryConfig is the path to the registry config file. @@ -65,6 +67,8 @@ func New() *EnvSettings { env := EnvSettings{ namespace: os.Getenv("HELM_NAMESPACE"), KubeContext: os.Getenv("HELM_KUBECONTEXT"), + KubeToken: os.Getenv("HELM_KUBETOKEN"), + KubeAPIServer: os.Getenv("HELM_KUBEAPISERVER"), PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")), RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")), RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")), @@ -79,7 +83,8 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) { fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request") fs.StringVar(&s.KubeConfig, "kubeconfig", "", "path to the kubeconfig file") fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use") - fs.StringVar(&s.Token, "token", s.Token, "bearer token used for authentication") + fs.StringVar(&s.KubeToken, "kube-token", s.KubeToken, "bearer token used for authentication") + fs.StringVar(&s.KubeAPIServer, "kube-apiserver", s.KubeAPIServer, "the address and the port for the Kubernetes API server") fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output") fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file") fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs") @@ -103,7 +108,8 @@ func (s *EnvSettings) EnvVars() map[string]string { "HELM_REPOSITORY_CONFIG": s.RepositoryConfig, "HELM_NAMESPACE": s.Namespace(), "HELM_KUBECONTEXT": s.KubeContext, - "HELM_KUBETOKEN": s.Token, + "HELM_KUBETOKEN": s.KubeToken, + "HELM_KUBEAPISERVER": s.KubeAPIServer, } if s.KubeConfig != "" { @@ -129,7 +135,13 @@ func (s *EnvSettings) Namespace() string { func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { s.configOnce.Do(func() { clientConfig := kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace) - clientConfig.BearerToken = &s.Token + if len(s.KubeToken) > 0 { + clientConfig.BearerToken = &s.KubeToken + } + if len(s.KubeAPIServer) > 0 { + clientConfig.APIServer = &s.KubeAPIServer + } + s.config = clientConfig }) return s.config From 1ff7202a9841b0a6a8d409342305ead6eb1503da Mon Sep 17 00:00:00 2001 From: Song Shukun Date: Thu, 20 Feb 2020 20:52:26 +0900 Subject: [PATCH 252/279] Fix output of list action when it is failed Signed-off-by: Song Shukun --- pkg/action/list.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/action/list.go b/pkg/action/list.go index 532f18385..ac6fd1b75 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -165,6 +165,10 @@ func (l *List) Run() ([]*release.Release, error) { return true }) + if err != nil { + return nil, err + } + if results == nil { return results, nil } From 694cf61aacba6bc4ed59a65d23acd20f6c8b95bd Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 20 Feb 2020 11:56:03 -0800 Subject: [PATCH 253/279] feat(install): introduce --create-namespace Signed-off-by: Matthew Fisher --- cmd/helm/install.go | 1 + cmd/helm/upgrade.go | 3 +++ pkg/action/install.go | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index ec2c75a12..719dc9014 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -136,6 +136,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } func addInstallFlags(f *pflag.FlagSet, client *action.Install, valueOpts *values.Options) { + f.BoolVar(&client.CreateNamespace, "create-namespace", false, "create the release namespace if not present") f.BoolVar(&client.DryRun, "dry-run", false, "simulate an install") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&client.Replace, "replace", false, "re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production") diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 119d79f8f..dea866e4d 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -65,6 +65,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewUpgrade(cfg) valueOpts := &values.Options{} var outfmt output.Format + var createNamespace bool cmd := &cobra.Command{ Use: "upgrade [RELEASE] [CHART]", @@ -100,6 +101,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0]) } instClient := action.NewInstall(cfg) + instClient.CreateNamespace = createNamespace instClient.ChartPathOptions = client.ChartPathOptions instClient.DryRun = client.DryRun instClient.DisableHooks = client.DisableHooks @@ -159,6 +161,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }) f := cmd.Flags() + f.BoolVar(&createNamespace, "create-namespace", false, "if --install is set, create the release namespace if not present") f.BoolVarP(&client.Install, "install", "i", false, "if a release by this name doesn't already exist, run an install") f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") f.BoolVar(&client.DryRun, "dry-run", false, "simulate an upgrade") diff --git a/pkg/action/install.go b/pkg/action/install.go index 79abfae33..e7b481d47 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -29,8 +29,11 @@ import ( "github.com/Masterminds/sprig/v3" "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cli-runtime/pkg/resource" + "sigs.k8s.io/yaml" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chartutil" @@ -69,6 +72,7 @@ type Install struct { ChartPathOptions ClientOnly bool + CreateNamespace bool DryRun bool DisableHooks bool Replace bool @@ -265,6 +269,32 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. return rel, nil } + if i.CreateNamespace { + ns := &v1.Namespace{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "Namespace", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: i.Namespace, + Labels: map[string]string{ + "name": i.Namespace, + }, + }, + } + buf, err := yaml.Marshal(ns) + if err != nil { + return nil, err + } + resourceList, err := i.cfg.KubeClient.Build(bytes.NewBuffer(buf), true) + if err != nil { + return nil, err + } + if _, err := i.cfg.KubeClient.Create(resourceList); err != nil && !apierrors.IsAlreadyExists(err) { + return nil, err + } + } + // If Replace is true, we need to supercede the last release. if i.Replace { if err := i.replaceRelease(rel); err != nil { From d6fad6b3c6aea1ce6ca3d58824dccf62e481bb69 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 14 Feb 2020 21:03:26 -0500 Subject: [PATCH 254/279] feat(comp): Move kube-context completion to Go Signed-off-by: Marc Khouzam --- cmd/helm/helm.go | 11 ++++++ cmd/helm/root.go | 65 +++++++++++++-------------------- internal/completion/complete.go | 10 ++--- 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 112d5123f..0ce40732b 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -30,6 +30,7 @@ import ( // Import to initialize client auth plugins. _ "k8s.io/client-go/plugin/pkg/client/auth" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/gates" @@ -67,6 +68,16 @@ func main() { actionConfig := new(action.Configuration) cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) + if calledCmd, _, err := cmd.Find(os.Args[1:]); err == nil && calledCmd.Name() == completion.CompRequestCmd { + // If completion is being called, we have to check if the completion is for the "--kube-context" + // value; if it is, we cannot call the action.Init() method with an incomplete kube-context value + // or else it will fail immediately. So, we simply unset the invalid kube-context value. + if args := os.Args[1:]; len(args) > 2 && args[len(args)-2] == "--kube-context" { + // We are completing the kube-context value! Reset it as the current value is not valid. + settings.KubeContext = "" + } + } + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil { log.Fatal(err) } diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 6ce1dcbf4..3c6a0d18e 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -24,6 +24,7 @@ import ( "github.com/spf13/cobra" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/clientcmd" "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/internal/completion" @@ -31,30 +32,6 @@ import ( "helm.sh/helm/v3/pkg/action" ) -const ( - contextCompFunc = ` -__helm_get_contexts() -{ - __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - local template out - template="{{ range .contexts }}{{ .name }} {{ end }}" - if out=$(kubectl config -o template --template="${template}" view 2>/dev/null); then - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) - fi -} -` -) - -var ( - // Mapping of global flags that can have dynamic completion and the - // completion function to be used. - bashCompletionFlags = map[string]string{ - // Cannot convert the kube-context flag to Go completion yet because - // an incomplete kube-context will make actionConfig.Init() fail at the very start - "kube-context": "__helm_get_contexts", - } -) - var globalUsage = `The Kubernetes package manager Common actions for Helm: @@ -101,14 +78,14 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Long: globalUsage, SilenceUsage: true, Args: require.NoArgs, - BashCompletionFunction: fmt.Sprintf("%s%s", contextCompFunc, completion.GetBashCustomFunction()), + BashCompletionFunction: completion.GetBashCustomFunction(), } flags := cmd.PersistentFlags() settings.AddFlags(flags) - flag := flags.Lookup("namespace") // Setup shell completion for the namespace flag + flag := flags.Lookup("namespace") completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { if client, err := actionConfig.KubernetesClientSet(); err == nil { // Choose a long enough timeout that the user notices somethings is not working @@ -129,6 +106,29 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string return nil, completion.BashCompDirectiveDefault }) + // Setup shell completion for the kube-context flag + flag = flags.Lookup("kube-context") + completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + completion.CompDebugln("About to get the different kube-contexts") + + loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() + if len(settings.KubeConfig) > 0 { + loadingRules = &clientcmd.ClientConfigLoadingRules{ExplicitPath: settings.KubeConfig} + } + if config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( + loadingRules, + &clientcmd.ConfigOverrides{}).RawConfig(); err == nil { + ctxs := []string{} + for name := range config.Contexts { + if strings.HasPrefix(name, toComplete) { + ctxs = append(ctxs, name) + } + } + return ctxs, completion.BashCompDirectiveNoFileComp + } + return nil, completion.BashCompDirectiveNoFileComp + }) + // We can safely ignore any errors that flags.Parse encounters since // those errors will be caught later during the call to cmd.Execution. // This call is required to gather configuration information prior to @@ -173,19 +173,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string completion.NewCompleteCmd(settings, out), ) - // Add annotation to flags for which we can generate completion choices - for name, completion := range bashCompletionFlags { - if cmd.Flag(name) != nil { - if cmd.Flag(name).Annotations == nil { - cmd.Flag(name).Annotations = map[string][]string{} - } - cmd.Flag(name).Annotations[cobra.BashCompCustom] = append( - cmd.Flag(name).Annotations[cobra.BashCompCustom], - completion, - ) - } - } - // Add *experimental* subcommands registryClient, err := registry.NewClient( registry.ClientOptDebug(settings.Debug), diff --git a/internal/completion/complete.go b/internal/completion/complete.go index a24390fc0..aa0d134b9 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -35,9 +35,9 @@ import ( // This should ultimately be pushed down into Cobra. // ================================================================================== -// compRequestCmd Hidden command to request completion results from the program. +// CompRequestCmd Hidden command to request completion results from the program. // Used by the shell completion script. -const compRequestCmd = "__complete" +const CompRequestCmd = "__complete" // Global map allowing to find completion functions for commands or flags. var validArgsFunctions = map[interface{}]func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective){} @@ -123,7 +123,7 @@ __helm_custom_func() done < <(compgen -W "${out[*]}" -- "$cur") fi } -`, compRequestCmd, BashCompDirectiveError, BashCompDirectiveNoSpace, BashCompDirectiveNoFileComp) +`, CompRequestCmd, BashCompDirectiveError, BashCompDirectiveNoSpace, BashCompDirectiveNoFileComp) } // RegisterValidArgsFunc should be called to register a function to provide argument completion for a command @@ -177,14 +177,14 @@ func (d BashCompDirective) string() string { func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command { debug = settings.Debug return &cobra.Command{ - Use: fmt.Sprintf("%s [command-line]", compRequestCmd), + Use: fmt.Sprintf("%s [command-line]", CompRequestCmd), DisableFlagsInUseLine: true, Hidden: true, DisableFlagParsing: true, Args: require.MinimumNArgs(1), Short: "Request shell completion choices for the specified command-line", Long: fmt.Sprintf("%s is a special command that is used by the shell completion logic\n%s", - compRequestCmd, "to request completion choices for the specified command-line."), + CompRequestCmd, "to request completion choices for the specified command-line."), Run: func(cmd *cobra.Command, args []string) { CompDebugln(fmt.Sprintf("%s was called with args %v", cmd.Name(), args)) From 7654c18c6b561a781f9e7fb7676165ca3ec05a4c Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 25 Nov 2019 21:47:18 -0500 Subject: [PATCH 255/279] feat(comp): Static completion for plugins Allow plugins to optionally specify their sub-cmds and flags through a simple yaml file. When generating the completion script with the command 'helm completion ' (and only then), helm will look for that yaml file in the plugin's directory. If the file exists, helm will create cobra commands and flags so that the completion script will handle them. Signed-off-by: Marc Khouzam --- cmd/helm/load_plugins.go | 128 ++++++++++++++++++ cmd/helm/plugin_test.go | 91 +++++++++++++ .../helm/plugins/echo/completion.yaml | 0 .../helmhome/helm/plugins/env/completion.yaml | 13 ++ .../helm/plugins/exitwith/completion.yaml | 5 + .../helm/plugins/fullenv/completion.yaml | 19 +++ 6 files changed, 256 insertions(+) create mode 100644 cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml create mode 100644 cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml create mode 100644 cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml create mode 100644 cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index f2fb5c01d..b8f34c19f 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -18,6 +18,8 @@ package main import ( "fmt" "io" + "io/ioutil" + "log" "os" "os/exec" "path/filepath" @@ -26,10 +28,13 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "sigs.k8s.io/yaml" "helm.sh/helm/v3/pkg/plugin" ) +const pluginStaticCompletionFile = "completion.yaml" + type pluginError struct { error code int @@ -61,6 +66,13 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { return u, nil } + // If we are dealing with the completion command, we try to load more details about the plugins + // if available, so as to allow for command and flag completion + if subCmd, _, err := baseCmd.Find(os.Args[1:]); err == nil && subCmd.Name() == "completion" { + loadPluginsForCompletion(baseCmd, found) + return + } + // Now we create commands for all of these. for _, plug := range found { plug := plug @@ -180,3 +192,119 @@ func findPlugins(plugdirs string) ([]*plugin.Plugin, error) { } return found, nil } + +// pluginCommand represents the optional completion.yaml file of a plugin +type pluginCommand struct { + Name string `json:"name"` + ValidArgs []string `json:"validArgs"` + Flags []string `json:"flags"` + Commands []pluginCommand `json:"commands"` +} + +// loadPluginsForCompletion will load and parse any completion.yaml provided by the plugins +func loadPluginsForCompletion(baseCmd *cobra.Command, plugins []*plugin.Plugin) { + for _, plug := range plugins { + // Parse the yaml file providing the plugin's subcmds and flags + cmds, err := loadFile(strings.Join( + []string{plug.Dir, pluginStaticCompletionFile}, string(filepath.Separator))) + + if err != nil { + // The file could be missing or invalid. Either way, we at least create the command + // for the plugin name. + if settings.Debug { + log.Output(2, fmt.Sprintf("[info] %s\n", err.Error())) + } + cmds = &pluginCommand{Name: plug.Metadata.Name} + } + + // We know what the plugin name must be. + // Let's set it in case the Name field was not specified correctly in the file. + // This insures that we will at least get the plugin name to complete, even if + // there is a problem with the completion.yaml file + cmds.Name = plug.Metadata.Name + + addPluginCommands(baseCmd, cmds) + } +} + +// addPluginCommands is a recursive method that adds the different levels +// of sub-commands and flags for the plugins that provide such information +func addPluginCommands(baseCmd *cobra.Command, cmds *pluginCommand) { + if cmds == nil { + return + } + + if len(cmds.Name) == 0 { + // Missing name for a command + if settings.Debug { + log.Output(2, fmt.Sprintf("[info] sub-command name field missing for %s", baseCmd.CommandPath())) + } + return + } + + // Create a fake command just so the completion script will include it + c := &cobra.Command{ + Use: cmds.Name, + ValidArgs: cmds.ValidArgs, + // A Run is required for it to be a valid command without subcommands + Run: func(cmd *cobra.Command, args []string) {}, + } + baseCmd.AddCommand(c) + + // Create fake flags. + if len(cmds.Flags) > 0 { + // The flags can be created with any type, since we only need them for completion. + // pflag does not allow to create short flags without a corresponding long form + // so we look for all short flags and match them to any long flag. This will allow + // plugins to provide short flags without a long form. + // If there are more short-flags than long ones, we'll create an extra long flag with + // the same single letter as the short form. + shorts := []string{} + longs := []string{} + for _, flag := range cmds.Flags { + if len(flag) == 1 { + shorts = append(shorts, flag) + } else { + longs = append(longs, flag) + } + } + + f := c.Flags() + if len(longs) >= len(shorts) { + for i := range longs { + if i < len(shorts) { + f.BoolP(longs[i], shorts[i], false, "") + } else { + f.Bool(longs[i], false, "") + } + } + } else { + for i := range shorts { + if i < len(longs) { + f.BoolP(longs[i], shorts[i], false, "") + } else { + // Create a long flag with the same name as the short flag. + // Not a perfect solution, but its better than ignoring the extra short flags. + f.BoolP(shorts[i], shorts[i], false, "") + } + } + } + } + + // Recursively add any sub-commands + for _, cmd := range cmds.Commands { + addPluginCommands(c, &cmd) + } +} + +// loadFile takes a yaml file at the given path, parses it and returns a pluginCommand object +func loadFile(path string) (*pluginCommand, error) { + cmds := new(pluginCommand) + b, err := ioutil.ReadFile(path) + if err != nil { + return cmds, errors.New(fmt.Sprintf("File (%s) not provided by plugin. No plugin auto-completion possible.", path)) + } + + err = yaml.Unmarshal(b, cmds) + return cmds, err +} diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index 3fd3a4197..2d9a24ba9 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -19,10 +19,12 @@ import ( "bytes" "os" "runtime" + "sort" "strings" "testing" "github.com/spf13/cobra" + "github.com/spf13/pflag" ) func TestManuallyProcessArgs(t *testing.T) { @@ -151,6 +153,95 @@ func TestLoadPlugins(t *testing.T) { } } +type staticCompletionDetails struct { + use string + validArgs []string + flags []string + next []staticCompletionDetails +} + +func TestLoadPluginsForCompletion(t *testing.T) { + settings.PluginsDirectory = "testdata/helmhome/helm/plugins" + + var out bytes.Buffer + + cmd := &cobra.Command{ + Use: "completion", + } + + loadPlugins(cmd, &out) + + tests := []staticCompletionDetails{ + {"args", []string{}, []string{}, []staticCompletionDetails{}}, + {"echo", []string{}, []string{}, []staticCompletionDetails{}}, + {"env", []string{}, []string{"global"}, []staticCompletionDetails{ + {"list", []string{}, []string{"a", "all", "log"}, []staticCompletionDetails{}}, + {"remove", []string{"all", "one"}, []string{}, []staticCompletionDetails{}}, + }}, + {"exitwith", []string{}, []string{}, []staticCompletionDetails{ + {"code", []string{}, []string{"a", "b"}, []staticCompletionDetails{}}, + }}, + {"fullenv", []string{}, []string{"q", "z"}, []staticCompletionDetails{ + {"empty", []string{}, []string{}, []staticCompletionDetails{}}, + {"full", []string{}, []string{}, []staticCompletionDetails{ + {"less", []string{}, []string{"a", "all"}, []staticCompletionDetails{}}, + {"more", []string{"one", "two"}, []string{"b", "ball"}, []staticCompletionDetails{}}, + }}, + }}, + } + checkCommand(t, cmd.Commands(), tests) +} + +func checkCommand(t *testing.T, plugins []*cobra.Command, tests []staticCompletionDetails) { + if len(plugins) != len(tests) { + t.Fatalf("Expected commands %v, got %v", tests, plugins) + } + + for i := 0; i < len(plugins); i++ { + pp := plugins[i] + tt := tests[i] + if pp.Use != tt.use { + t.Errorf("%s: Expected Use=%q, got %q", pp.Name(), tt.use, pp.Use) + } + + targs := tt.validArgs + pargs := pp.ValidArgs + if len(targs) != len(pargs) { + t.Fatalf("%s: expected args %v, got %v", pp.Name(), targs, pargs) + } + + sort.Strings(targs) + sort.Strings(pargs) + for j := range targs { + if targs[j] != pargs[j] { + t.Errorf("%s: expected validArg=%q, got %q", pp.Name(), targs[j], pargs[j]) + } + } + + tflags := tt.flags + var pflags []string + pp.LocalFlags().VisitAll(func(flag *pflag.Flag) { + pflags = append(pflags, flag.Name) + if len(flag.Shorthand) > 0 && flag.Shorthand != flag.Name { + pflags = append(pflags, flag.Shorthand) + } + }) + if len(tflags) != len(pflags) { + t.Fatalf("%s: expected flags %v, got %v", pp.Name(), tflags, pflags) + } + + sort.Strings(tflags) + sort.Strings(pflags) + for j := range tflags { + if tflags[j] != pflags[j] { + t.Errorf("%s: expected flag=%q, got %q", pp.Name(), tflags[j], pflags[j]) + } + } + // Check the next level + checkCommand(t, pp.Commands(), tt.next) + } +} + func TestLoadPlugins_HelmNoPlugins(t *testing.T) { settings.PluginsDirectory = "testdata/helmhome/helm/plugins" settings.RepositoryConfig = "testdata/helmhome/helm/repository" diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/echo/completion.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml new file mode 100644 index 000000000..e479a0503 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/env/completion.yaml @@ -0,0 +1,13 @@ +name: env +commands: + - name: list + flags: + - a + - all + - log + - name: remove + validArgs: + - all + - one +flags: +- global diff --git a/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml new file mode 100644 index 000000000..e5bf440f6 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/exitwith/completion.yaml @@ -0,0 +1,5 @@ +commands: + - name: code + flags: + - a + - b diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml new file mode 100644 index 000000000..e0b161c69 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/completion.yaml @@ -0,0 +1,19 @@ +name: wrongname +commands: + - name: empty + - name: full + commands: + - name: more + validArgs: + - one + - two + flags: + - b + - ball + - name: less + flags: + - a + - all +flags: +- z +- q From 97e353bda56f1eff370a14283589be469de2000e Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 21 Jan 2020 22:27:13 -0500 Subject: [PATCH 256/279] feat(comp): Dynamic completion for plugins For each plugin, helm registers a ValidArgsFunction which the completion script will call when it needs dynamic completion. This ValidArgsFunction will setup the plugin environment and then call the executable `plugin.complete`, if it is provided by the plugin. The output of the call to `plugin.complete` will be used as completion choices. The last line of the output can optionally be used by the plugin to specify a completion directive. Signed-off-by: Marc Khouzam --- cmd/helm/load_plugins.go | 105 ++++++++++++++---- cmd/helm/plugin_test.go | 41 +++++++ .../helm/plugins/args/plugin.complete | 13 +++ .../helm/plugins/echo/plugin.complete | 14 +++ cmd/helm/testdata/output/plugin_args_comp.txt | 5 + .../testdata/output/plugin_args_flag_comp.txt | 5 + .../output/plugin_args_many_args_comp.txt | 5 + .../testdata/output/plugin_args_ns_comp.txt | 5 + .../output/plugin_echo_bad_directive.txt | 5 + .../output/plugin_echo_no_directive.txt | 5 + internal/completion/complete.go | 57 ++++++---- 11 files changed, 214 insertions(+), 46 deletions(-) create mode 100755 cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete create mode 100755 cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete create mode 100644 cmd/helm/testdata/output/plugin_args_comp.txt create mode 100644 cmd/helm/testdata/output/plugin_args_flag_comp.txt create mode 100644 cmd/helm/testdata/output/plugin_args_many_args_comp.txt create mode 100644 cmd/helm/testdata/output/plugin_args_ns_comp.txt create mode 100644 cmd/helm/testdata/output/plugin_echo_bad_directive.txt create mode 100644 cmd/helm/testdata/output/plugin_echo_no_directive.txt diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index b8f34c19f..358679302 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -16,6 +16,7 @@ limitations under the License. package main import ( + "bytes" "fmt" "io" "io/ioutil" @@ -23,6 +24,7 @@ import ( "os" "os/exec" "path/filepath" + "strconv" "strings" "syscall" @@ -30,10 +32,14 @@ import ( "github.com/spf13/cobra" "sigs.k8s.io/yaml" + "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/pkg/plugin" ) -const pluginStaticCompletionFile = "completion.yaml" +const ( + pluginStaticCompletionFile = "completion.yaml" + pluginDynamicCompletionExecutable = "plugin.complete" +) type pluginError struct { error @@ -81,6 +87,33 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { md.Usage = fmt.Sprintf("the %q plugin", md.Name) } + // This function is used to setup the environment for the plugin and then + // call the executable specified by the parameter 'main' + callPluginExecutable := func(cmd *cobra.Command, main string, argv []string, out io.Writer) error { + env := os.Environ() + for k, v := range settings.EnvVars() { + env = append(env, fmt.Sprintf("%s=%s", k, v)) + } + + prog := exec.Command(main, argv...) + prog.Env = env + prog.Stdin = os.Stdin + prog.Stdout = out + prog.Stderr = os.Stderr + if err := prog.Run(); err != nil { + if eerr, ok := err.(*exec.ExitError); ok { + os.Stderr.Write(eerr.Stderr) + status := eerr.Sys().(syscall.WaitStatus) + return pluginError{ + error: errors.Errorf("plugin %q exited with error", md.Name), + code: status.ExitStatus(), + } + } + return err + } + return nil + } + c := &cobra.Command{ Use: md.Name, Short: md.Usage, @@ -101,33 +134,59 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { return errors.Errorf("plugin %q exited with error", md.Name) } - env := os.Environ() - for k, v := range settings.EnvVars() { - env = append(env, fmt.Sprintf("%s=%s", k, v)) - } - - prog := exec.Command(main, argv...) - prog.Env = env - prog.Stdin = os.Stdin - prog.Stdout = out - prog.Stderr = os.Stderr - if err := prog.Run(); err != nil { - if eerr, ok := err.(*exec.ExitError); ok { - os.Stderr.Write(eerr.Stderr) - status := eerr.Sys().(syscall.WaitStatus) - return pluginError{ - error: errors.Errorf("plugin %q exited with error", md.Name), - code: status.ExitStatus(), - } - } - return err - } - return nil + return callPluginExecutable(cmd, main, argv, out) }, // This passes all the flags to the subcommand. DisableFlagParsing: true, } + // Setup dynamic completion for the plugin + completion.RegisterValidArgsFunc(c, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) { + u, err := processParent(cmd, args) + if err != nil { + return nil, completion.BashCompDirectiveError + } + + // We will call the dynamic completion script of the plugin + main := strings.Join([]string{plug.Dir, pluginDynamicCompletionExecutable}, string(filepath.Separator)) + + argv := []string{} + if !md.IgnoreFlags { + argv = append(argv, u...) + argv = append(argv, toComplete) + } + plugin.SetupPluginEnv(settings, md.Name, plug.Dir) + + completion.CompDebugln(fmt.Sprintf("calling %s with args %v", main, argv)) + buf := new(bytes.Buffer) + if err := callPluginExecutable(cmd, main, argv, buf); err != nil { + return nil, completion.BashCompDirectiveError + } + + var completions []string + for _, comp := range strings.Split(buf.String(), "\n") { + // Remove any empty lines + if len(comp) > 0 { + completions = append(completions, comp) + } + } + + // Check if the last line of output is of the form :, which + // indicates the BashCompletionDirective. + directive := completion.BashCompDirectiveDefault + if len(completions) > 0 { + lastLine := completions[len(completions)-1] + if len(lastLine) > 1 && lastLine[0] == ':' { + if strInt, err := strconv.Atoi(lastLine[1:]); err == nil { + directive = completion.BashCompDirective(strInt) + completions = completions[:len(completions)-1] + } + } + } + + return completions, directive + }) + // TODO: Make sure a command with this name does not already exist. baseCmd.AddCommand(c) } diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index 2d9a24ba9..e43f277a5 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -25,6 +25,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + + "helm.sh/helm/v3/pkg/release" ) func TestManuallyProcessArgs(t *testing.T) { @@ -242,6 +244,45 @@ func checkCommand(t *testing.T, plugins []*cobra.Command, tests []staticCompleti } } +func TestPluginDynamicCompletion(t *testing.T) { + + tests := []cmdTestCase{{ + name: "completion for plugin", + cmd: "__complete args ''", + golden: "output/plugin_args_comp.txt", + rels: []*release.Release{}, + }, { + name: "completion for plugin with flag", + cmd: "__complete args --myflag ''", + golden: "output/plugin_args_flag_comp.txt", + rels: []*release.Release{}, + }, { + name: "completion for plugin with global flag", + cmd: "__complete args --namespace mynamespace ''", + golden: "output/plugin_args_ns_comp.txt", + rels: []*release.Release{}, + }, { + name: "completion for plugin with multiple args", + cmd: "__complete args --myflag --namespace mynamespace start", + golden: "output/plugin_args_many_args_comp.txt", + rels: []*release.Release{}, + }, { + name: "completion for plugin no directive", + cmd: "__complete echo -n mynamespace ''", + golden: "output/plugin_echo_no_directive.txt", + rels: []*release.Release{}, + }, { + name: "completion for plugin bad directive", + cmd: "__complete echo ''", + golden: "output/plugin_echo_bad_directive.txt", + rels: []*release.Release{}, + }} + for _, test := range tests { + settings.PluginsDirectory = "testdata/helmhome/helm/plugins" + runTestCmd(t, []cmdTestCase{test}) + } +} + func TestLoadPlugins_HelmNoPlugins(t *testing.T) { settings.PluginsDirectory = "testdata/helmhome/helm/plugins" settings.RepositoryConfig = "testdata/helmhome/helm/repository" diff --git a/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete b/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete new file mode 100755 index 000000000..2b00c2281 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/args/plugin.complete @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +echo "plugin.complete was called" +echo "Namespace: ${HELM_NAMESPACE:-NO_NS}" +echo "Num args received: ${#}" +echo "Args received: ${@}" + +# Final printout is the optional completion directive of the form : +if [ "$HELM_NAMESPACE" = "default" ]; then + echo ":4" +else + echo ":2" +fi diff --git a/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete b/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete new file mode 100755 index 000000000..6bc73d130 --- /dev/null +++ b/cmd/helm/testdata/helmhome/helm/plugins/echo/plugin.complete @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +echo "echo plugin.complete was called" +echo "Namespace: ${HELM_NAMESPACE:-NO_NS}" +echo "Num args received: ${#}" +echo "Args received: ${@}" + +# Final printout is the optional completion directive of the form : +if [ "$HELM_NAMESPACE" = "default" ]; then + # Output an invalid directive, which should be ignored + echo ":2222" +# else + # Don't include the directive, to test it is really optional +fi diff --git a/cmd/helm/testdata/output/plugin_args_comp.txt b/cmd/helm/testdata/output/plugin_args_comp.txt new file mode 100644 index 000000000..8fb01cc23 --- /dev/null +++ b/cmd/helm/testdata/output/plugin_args_comp.txt @@ -0,0 +1,5 @@ +plugin.complete was called +Namespace: default +Num args received: 1 +Args received: +:4 diff --git a/cmd/helm/testdata/output/plugin_args_flag_comp.txt b/cmd/helm/testdata/output/plugin_args_flag_comp.txt new file mode 100644 index 000000000..92f0e58a8 --- /dev/null +++ b/cmd/helm/testdata/output/plugin_args_flag_comp.txt @@ -0,0 +1,5 @@ +plugin.complete was called +Namespace: default +Num args received: 2 +Args received: --myflag +:4 diff --git a/cmd/helm/testdata/output/plugin_args_many_args_comp.txt b/cmd/helm/testdata/output/plugin_args_many_args_comp.txt new file mode 100644 index 000000000..86fa768bb --- /dev/null +++ b/cmd/helm/testdata/output/plugin_args_many_args_comp.txt @@ -0,0 +1,5 @@ +plugin.complete was called +Namespace: mynamespace +Num args received: 2 +Args received: --myflag start +:2 diff --git a/cmd/helm/testdata/output/plugin_args_ns_comp.txt b/cmd/helm/testdata/output/plugin_args_ns_comp.txt new file mode 100644 index 000000000..e12867daa --- /dev/null +++ b/cmd/helm/testdata/output/plugin_args_ns_comp.txt @@ -0,0 +1,5 @@ +plugin.complete was called +Namespace: mynamespace +Num args received: 1 +Args received: +:2 diff --git a/cmd/helm/testdata/output/plugin_echo_bad_directive.txt b/cmd/helm/testdata/output/plugin_echo_bad_directive.txt new file mode 100644 index 000000000..f4b86cd47 --- /dev/null +++ b/cmd/helm/testdata/output/plugin_echo_bad_directive.txt @@ -0,0 +1,5 @@ +echo plugin.complete was called +Namespace: default +Num args received: 1 +Args received: +:0 diff --git a/cmd/helm/testdata/output/plugin_echo_no_directive.txt b/cmd/helm/testdata/output/plugin_echo_no_directive.txt new file mode 100644 index 000000000..6266dd4d9 --- /dev/null +++ b/cmd/helm/testdata/output/plugin_echo_no_directive.txt @@ -0,0 +1,5 @@ +echo plugin.complete was called +Namespace: mynamespace +Num args received: 1 +Args received: +:0 diff --git a/internal/completion/complete.go b/internal/completion/complete.go index aa0d134b9..c8f78868a 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -188,29 +188,47 @@ func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command { Run: func(cmd *cobra.Command, args []string) { CompDebugln(fmt.Sprintf("%s was called with args %v", cmd.Name(), args)) - flag, trimmedArgs, toComplete, err := checkIfFlagCompletion(cmd.Root(), args[:len(args)-1], args[len(args)-1]) - if err != nil { - // Error while attempting to parse flags - CompErrorln(err.Error()) - return - } + // The last argument, which is not complete, should not be part of the list of arguments + toComplete := args[len(args)-1] + trimmedArgs := args[:len(args)-1] + // Find the real command for which completion must be performed finalCmd, finalArgs, err := cmd.Root().Find(trimmedArgs) if err != nil { // Unable to find the real command. E.g., helm invalidCmd + CompDebugln(fmt.Sprintf("Unable to find a command for arguments: %v", trimmedArgs)) return } CompDebugln(fmt.Sprintf("Found final command '%s', with finalArgs %v", finalCmd.Name(), finalArgs)) + var flag *pflag.Flag + if !finalCmd.DisableFlagParsing { + // We only do flag completion if we are allowed to parse flags + // This is important for helm plugins which need to do their own flag completion. + flag, finalArgs, toComplete, err = checkIfFlagCompletion(finalCmd, finalArgs, toComplete) + if err != nil { + // Error while attempting to parse flags + CompErrorln(err.Error()) + return + } + } + // Parse the flags and extract the arguments to prepare for calling the completion function if err = finalCmd.ParseFlags(finalArgs); err != nil { CompErrorln(fmt.Sprintf("Error while parsing flags from args %v: %s", finalArgs, err.Error())) return } - argsWoFlags := finalCmd.Flags().Args() - CompDebugln(fmt.Sprintf("Args without flags are '%v' with length %d", argsWoFlags, len(argsWoFlags))) + // We only remove the flags from the arguments if DisableFlagParsing is not set. + // This is important for helm plugins, which need to receive all flags. + // The plugin completion code will do its own flag parsing. + if !finalCmd.DisableFlagParsing { + finalArgs = finalCmd.Flags().Args() + CompDebugln(fmt.Sprintf("Args without flags are '%v' with length %d", finalArgs, len(finalArgs))) + } + + // Find completion function for the flag or command var key interface{} var keyStr string if flag != nil { @@ -220,21 +238,23 @@ func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command { key = finalCmd keyStr = finalCmd.Name() } - - // Find completion function for the flag or command completionFn, ok := validArgsFunctions[key] if !ok { CompErrorln(fmt.Sprintf("Dynamic completion not supported/needed for flag or command: %s", keyStr)) return } - CompDebugln(fmt.Sprintf("Calling completion method for subcommand '%s' with args '%v' and toComplete '%s'", finalCmd.Name(), argsWoFlags, toComplete)) - completions, directive := completionFn(finalCmd, argsWoFlags, toComplete) + CompDebugln(fmt.Sprintf("Calling completion method for subcommand '%s' with args '%v' and toComplete '%s'", finalCmd.Name(), finalArgs, toComplete)) + completions, directive := completionFn(finalCmd, finalArgs, toComplete) for _, comp := range completions { // Print each possible completion to stdout for the completion script to consume. fmt.Fprintln(out, comp) } + if directive > BashCompDirectiveError+BashCompDirectiveNoSpace+BashCompDirectiveNoFileComp { + directive = BashCompDirectiveDefault + } + // As the last printout, print the completion directive for the // completion script to parse. // The directive integer must be that last character following a single : @@ -252,7 +272,7 @@ func isFlag(arg string) bool { return len(arg) > 0 && arg[0] == '-' } -func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string) (*pflag.Flag, []string, string, error) { +func checkIfFlagCompletion(finalCmd *cobra.Command, args []string, lastArg string) (*pflag.Flag, []string, string, error) { var flagName string trimmedArgs := args flagWithEqual := false @@ -287,19 +307,10 @@ func checkIfFlagCompletion(rootCmd *cobra.Command, args []string, lastArg string return nil, trimmedArgs, lastArg, nil } - // Find the real command for which completion must be performed - finalCmd, _, err := rootCmd.Find(trimmedArgs) - if err != nil { - // Unable to find the real command. E.g., helm invalidCmd - return nil, nil, "", errors.New("Unable to find final command for completion") - } - - CompDebugln(fmt.Sprintf("checkIfFlagCompletion: found final command '%s'", finalCmd.Name())) - flag := findFlag(finalCmd, flagName) if flag == nil { // Flag not supported by this command, nothing to complete - err = fmt.Errorf("Subcommand '%s' does not support flag '%s'", finalCmd.Name(), flagName) + err := fmt.Errorf("Subcommand '%s' does not support flag '%s'", finalCmd.Name(), flagName) return nil, nil, "", err } From 7f3339cb4eec9800cb09a46512050fb509480f7e Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 14 Jan 2020 22:44:52 -0500 Subject: [PATCH 257/279] feat(tests): Allow to provision memory driver The memory driver is used for go tests. It can also be used from the command-line by setting the environment variable HELM_DRIVER=memory. In the latter case however, there was no way to pre-provision some releases. This commit introduces the HELM_MEMORY_DRIVER_DATA variable which can be used to provide a colon-separated list of yaml files specifying releases to provision automatically. For example: HELM_DRIVER=memory \ HELM_MEMORY_DRIVER_DATA=./testdata/releases.yaml \ helm list --all-namespaces Signed-off-by: Marc Khouzam --- cmd/helm/helm.go | 49 +++++++++++++++++++++++++++++++++++++++++- pkg/action/action.go | 13 ++++++++++- testdata/releases.yaml | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 testdata/releases.yaml diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 0ce40732b..257387547 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -19,6 +19,7 @@ package main // import "helm.sh/helm/v3/cmd/helm" import ( "flag" "fmt" + "io/ioutil" "log" "os" "strings" @@ -26,6 +27,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "k8s.io/klog" + "sigs.k8s.io/yaml" // Import to initialize client auth plugins. _ "k8s.io/client-go/plugin/pkg/client/auth" @@ -34,6 +36,9 @@ import ( "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/gates" + kubefake "helm.sh/helm/v3/pkg/kube/fake" + "helm.sh/helm/v3/pkg/release" + "helm.sh/helm/v3/pkg/storage/driver" ) // FeatureGateOCI is the feature gate for checking if `helm chart` and `helm registry` commands should work @@ -78,9 +83,13 @@ func main() { } } - if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil { + helmDriver := os.Getenv("HELM_DRIVER") + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, debug); err != nil { log.Fatal(err) } + if helmDriver == "memory" { + loadReleasesInMemory(actionConfig) + } if err := cmd.Execute(); err != nil { debug("%+v", err) @@ -106,3 +115,41 @@ func checkOCIFeatureGate() func(_ *cobra.Command, _ []string) error { return nil } } + +// This function loads releases into the memory storage if the +// environment variable is properly set. +func loadReleasesInMemory(actionConfig *action.Configuration) { + filePaths := strings.Split(os.Getenv("HELM_MEMORY_DRIVER_DATA"), ":") + if len(filePaths) == 0 { + return + } + + store := actionConfig.Releases + mem, ok := store.Driver.(*driver.Memory) + if !ok { + // For an unexpected reason we are not dealing with the memory storage driver. + return + } + + actionConfig.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard} + + for _, path := range filePaths { + b, err := ioutil.ReadFile(path) + if err != nil { + log.Fatal("Unable to read memory driver data", err) + } + + releases := []*release.Release{} + if err := yaml.Unmarshal(b, &releases); err != nil { + log.Fatal("Unable to unmarshal memory driver data: ", err) + } + + for _, rel := range releases { + if err := store.Create(rel); err != nil { + log.Fatal(err) + } + } + } + // Must reset namespace to the proper one + mem.SetNamespace(settings.Namespace()) +} diff --git a/pkg/action/action.go b/pkg/action/action.go index 1af5b3d9a..e4db942c8 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -241,7 +241,18 @@ func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespac d.Log = log store = storage.Init(d) case "memory": - d := driver.NewMemory() + var d *driver.Memory + if c.Releases != nil { + if mem, ok := c.Releases.Driver.(*driver.Memory); ok { + // This function can be called more than once (e.g., helm list --all-namespaces). + // If a memory driver was already initialized, re-use it but set the possibly new namespace. + // We re-use it in case some releases where already created in the existing memory driver. + d = mem + } + } + if d == nil { + d = driver.NewMemory() + } d.SetNamespace(namespace) store = storage.Init(d) default: diff --git a/testdata/releases.yaml b/testdata/releases.yaml new file mode 100644 index 000000000..fef79f424 --- /dev/null +++ b/testdata/releases.yaml @@ -0,0 +1,43 @@ +# This file can be used as input to create test releases: +# HELM_MEMORY_DRIVER_DATA=./testdata/releases.yaml HELM_DRIVER=memory helm list --all-namespaces +- name: athos + version: 1 + namespace: default + info: + status: deployed + chart: + metadata: + name: athos-chart + version: 1.0.0 + appversion: 1.1.0 +- name: porthos + version: 2 + namespace: default + info: + status: deployed + chart: + metadata: + name: prothos-chart + version: 0.2.0 + appversion: 0.2.2 +- name: aramis + version: 3 + namespace: default + info: + status: deployed + chart: + metadata: + name: aramis-chart + version: 0.0.3 + appversion: 3.0.3 +- name: dartagnan + version: 4 + namespace: gascony + info: + status: deployed + chart: + metadata: + name: dartagnan-chart + version: 0.4.4 + appversion: 4.4.4 + From 6b1eebd23a3e56714bb4f5d542acc4d087fa8073 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 24 Feb 2020 11:22:12 +0800 Subject: [PATCH 258/279] pkg/storage/records: add unit test for Get Signed-off-by: Zhou Hao --- pkg/storage/driver/records_test.go | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/storage/driver/records_test.go b/pkg/storage/driver/records_test.go index 79b60044f..030e32e9d 100644 --- a/pkg/storage/driver/records_test.go +++ b/pkg/storage/driver/records_test.go @@ -17,6 +17,7 @@ limitations under the License. package driver // import "helm.sh/helm/v3/pkg/storage/driver" import ( + "reflect" "testing" rspb "helm.sh/helm/v3/pkg/release" @@ -110,3 +111,34 @@ func TestRecordsRemoveAt(t *testing.T) { t.Fatalf("Expected length of rs to be 1, got %d", len(rs)) } } + +func TestRecordsGet(t *testing.T) { + rs := records([]*record{ + newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)), + newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)), + }) + + var tests = []struct { + desc string + key string + rec *record + }{ + { + "get valid key", + "rls-a.v1", + newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)), + }, + { + "get invalid key", + "rls-a.v3", + nil, + }, + } + + for _, tt := range tests { + got := rs.Get(tt.key) + if !reflect.DeepEqual(tt.rec, got) { + t.Fatalf("Expected %v, got %v", tt.rec, got) + } + } +} From c96aff6a43c0da2163e267cc807b5a09a2713ccf Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 24 Feb 2020 11:42:04 +0800 Subject: [PATCH 259/279] pkg/storage/records: add unit test for Index Signed-off-by: Zhou Hao --- pkg/storage/driver/records_test.go | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/storage/driver/records_test.go b/pkg/storage/driver/records_test.go index 030e32e9d..c6c13f28b 100644 --- a/pkg/storage/driver/records_test.go +++ b/pkg/storage/driver/records_test.go @@ -142,3 +142,34 @@ func TestRecordsGet(t *testing.T) { } } } + +func TestRecordsIndex(t *testing.T) { + rs := records([]*record{ + newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)), + newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)), + }) + + var tests = []struct { + desc string + key string + sort int + }{ + { + "get valid key", + "rls-a.v1", + 0, + }, + { + "get invalid key", + "rls-a.v3", + -1, + }, + } + + for _, tt := range tests { + got, _ := rs.Index(tt.key) + if got != tt.sort { + t.Fatalf("Expected %d, got %d", tt.sort, got) + } + } +} From f1f661d4ca28fbbfad75fe706e3eb7a4ce8d9478 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 24 Feb 2020 11:53:04 +0800 Subject: [PATCH 260/279] pkg/storage/records: add unit test for Exists Signed-off-by: Zhou Hao --- pkg/storage/driver/records_test.go | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/storage/driver/records_test.go b/pkg/storage/driver/records_test.go index c6c13f28b..3ede92bcd 100644 --- a/pkg/storage/driver/records_test.go +++ b/pkg/storage/driver/records_test.go @@ -173,3 +173,34 @@ func TestRecordsIndex(t *testing.T) { } } } + +func TestRecordsExists(t *testing.T) { + rs := records([]*record{ + newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)), + newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)), + }) + + var tests = []struct { + desc string + key string + ok bool + }{ + { + "get valid key", + "rls-a.v1", + true, + }, + { + "get invalid key", + "rls-a.v3", + false, + }, + } + + for _, tt := range tests { + got := rs.Exists(tt.key) + if got != tt.ok { + t.Fatalf("Expected %t, got %t", tt.ok, got) + } + } +} From b4f716413c150cb4e9db1f51dad820051896d459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kohout?= Date: Mon, 24 Feb 2020 11:57:18 +0100 Subject: [PATCH 261/279] Printing name of chart that do not have requested import value. Signed-off-by: Tomas Kohout --- pkg/chartutil/dependencies.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chartutil/dependencies.go b/pkg/chartutil/dependencies.go index 4b389dc22..521e2abc4 100644 --- a/pkg/chartutil/dependencies.go +++ b/pkg/chartutil/dependencies.go @@ -233,7 +233,7 @@ func processImportValues(c *chart.Chart) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - log.Printf("Warning: ImportValues missing table: %v", err) + log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent From c235470e59fd4f17149339757940537f95605cef Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 25 Feb 2020 10:42:20 -0800 Subject: [PATCH 262/279] fix(cmd/helm): upgrade go-shellwords Removes workaround introduced in #7323 Signed-off-by: Adam Reese --- cmd/helm/helm_test.go | 29 ----------------------------- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 8c6c492f8..94646a5a3 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -18,7 +18,6 @@ package main import ( "bytes" - "fmt" "io/ioutil" "os" "os/exec" @@ -97,39 +96,11 @@ func storageFixture() *storage.Storage { return storage.Init(driver.NewMemory()) } -// go-shellwords does not handle empty arguments properly -// https://github.com/mattn/go-shellwords/issues/5#issuecomment-573431458 -// -// This method checks if the last argument was an empty one, -// and if go-shellwords missed it, we add it ourselves. -// -// This is important for completion tests as completion often -// uses an empty last parameter. -func checkLastEmpty(in string, out []string) []string { - lastIndex := len(in) - 1 - - if lastIndex >= 1 && (in[lastIndex] == '"' && in[lastIndex-1] == '"' || - in[lastIndex] == '\'' && in[lastIndex-1] == '\'') { - // The last parameter of 'in' was empty ("" or ''), let's make sure it was detected. - if len(out) > 0 && out[len(out)-1] != "" { - // Bug from go-shellwords: - // 'out' does not have the empty parameter. We add it ourselves as a workaround. - out = append(out, "") - } else { - fmt.Println("WARNING: go-shellwords seems to have been fixed. This workaround can be removed.") - } - } - return out -} - func executeActionCommandC(store *storage.Storage, cmd string) (*cobra.Command, string, error) { args, err := shellwords.Parse(cmd) if err != nil { return nil, "", err } - // Workaround the bug in shellwords - args = checkLastEmpty(cmd, args) - buf := new(bytes.Buffer) actionConfig := &action.Configuration{ diff --git a/go.mod b/go.mod index 9c22ea9e5..7ba7a5542 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/gobwas/glob v0.2.3 github.com/gofrs/flock v0.7.1 github.com/gosuri/uitable v0.0.4 - github.com/mattn/go-shellwords v1.0.9 + github.com/mattn/go-shellwords v1.0.10 github.com/mitchellh/copystructure v1.0.0 github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/image-spec v1.0.1 diff --git a/go.sum b/go.sum index 89c7762d5..39b57b4f2 100644 --- a/go.sum +++ b/go.sum @@ -334,6 +334,8 @@ github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.9 h1:eaB5JspOwiKKcHdqcjbfe5lA9cNn/4NRRtddXJCimqk= github.com/mattn/go-shellwords v1.0.9/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= +github.com/mattn/go-shellwords v1.0.10 h1:Y7Xqm8piKOO3v10Thp7Z36h4FYFjt5xB//6XvOrs2Gw= +github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= From f05ffdd2da3bc6acf31747c42c292a8e34cd8697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Mac=C3=ADk?= Date: Wed, 26 Feb 2020 13:24:17 +0100 Subject: [PATCH 263/279] Fix golangci-lint errors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel MacĂ­k --- cmd/helm/template.go | 5 ++--- internal/completion/complete.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 320718344..91a398429 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -24,8 +24,6 @@ import ( "regexp" "strings" - "helm.sh/helm/v3/pkg/releaseutil" - "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" @@ -33,6 +31,7 @@ import ( "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/cli/values" + "helm.sh/helm/v3/pkg/releaseutil" ) const templateDesc = ` @@ -53,7 +52,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "template [NAME] [CHART]", - Short: fmt.Sprintf("locally render templates"), + Short: "locally render templates", Long: templateDesc, Args: require.MinimumNArgs(1), RunE: func(_ *cobra.Command, args []string) error { diff --git a/internal/completion/complete.go b/internal/completion/complete.go index c8f78868a..eaea4e914 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -259,7 +259,7 @@ func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command { // completion script to parse. // The directive integer must be that last character following a single : // The completion script expects :directive - fmt.Fprintln(out, fmt.Sprintf(":%d", directive)) + fmt.Fprintf(out, ":%d\n", directive) // Print some helpful info to stderr for the user to understand. // Output from stderr should be ignored from the completion script. From 8f962a270c65e703b07fb749f80ed67855d92f23 Mon Sep 17 00:00:00 2001 From: Xiangxuan Liu Date: Thu, 21 Nov 2019 16:24:12 +0800 Subject: [PATCH 264/279] Return "unknown command" error for unknown subcommands Signed-off-by: Xiangxuan Liu --- cmd/helm/root.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 3c6a0d18e..3ebea3bae 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -26,7 +26,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" - "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/internal/experimental/registry" "helm.sh/helm/v3/pkg/action" @@ -77,7 +76,6 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Short: "The Helm package manager for Kubernetes.", Long: globalUsage, SilenceUsage: true, - Args: require.NoArgs, BashCompletionFunction: completion.GetBashCustomFunction(), } flags := cmd.PersistentFlags() From d5a2963cc95027951ea9654210786c639d5891ff Mon Sep 17 00:00:00 2001 From: Xiangxuan Liu Date: Fri, 22 Nov 2019 10:56:39 +0800 Subject: [PATCH 265/279] Add test for unknown subcommand Signed-off-by: Xiangxuan Liu --- cmd/helm/root_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/helm/root_test.go b/cmd/helm/root_test.go index df592a96d..e1fa1fc27 100644 --- a/cmd/helm/root_test.go +++ b/cmd/helm/root_test.go @@ -95,3 +95,11 @@ func TestRootCmd(t *testing.T) { }) } } + +func TestUnknownSubCmd(t *testing.T) { + _, _, err := executeActionCommand("foobar") + + if err == nil || err.Error() != `unknown command "foobar" for "helm"` { + t.Errorf("Expect unknown command error, got %q", err) + } +} From ebd48557b103f9da9faefb7ef085b2393f8183c5 Mon Sep 17 00:00:00 2001 From: Evgenii Iablokov Date: Thu, 27 Feb 2020 09:12:09 +0100 Subject: [PATCH 266/279] Update README.md Typo fix: Space missed in Markdown header. Signed-off-by: Evgeniy Yablokov --- cmd/helm/testdata/testcharts/alpine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/testdata/testcharts/alpine/README.md b/cmd/helm/testdata/testcharts/alpine/README.md index fcf7ee017..05d39dbbc 100644 --- a/cmd/helm/testdata/testcharts/alpine/README.md +++ b/cmd/helm/testdata/testcharts/alpine/README.md @@ -1,4 +1,4 @@ -#Alpine: A simple Helm chart +# Alpine: A simple Helm chart Run a single pod of Alpine Linux. From a3f92f65e26323a3f91343c29ee0c4d1b6282d21 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 28 Feb 2020 12:32:45 -0500 Subject: [PATCH 267/279] Fixes verification output on pull command When using the --verify flag on the pull command the output was an internal Go object rather than useful detail. This is a bug. The output new displays who signed the chart along with the hash. Fixes #7624 Signed-off-by: Matt Farina --- cmd/helm/pull_test.go | 18 +++++++++++------- pkg/action/pull.go | 6 +++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index 1aca66100..d4661f928 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -20,7 +20,6 @@ import ( "fmt" "os" "path/filepath" - "regexp" "testing" "helm.sh/helm/v3/pkg/repo/repotest" @@ -37,6 +36,10 @@ func TestPullCmd(t *testing.T) { t.Fatal(err) } + helmTestKeyOut := "Signed by: Helm Testing (This key should only be used for testing. DO NOT TRUST.) \n" + + "Using Key With Fingerprint: 5E615389B53CA37F0EE60BD3843BBF981FC18762\n" + + "Chart Hash Verified: " + // all flags will get "-d outdir" appended. tests := []struct { name string @@ -49,6 +52,7 @@ func TestPullCmd(t *testing.T) { expectFile string expectDir bool expectVerify bool + expectSha string }{ { name: "Basic chart fetch", @@ -77,6 +81,7 @@ func TestPullCmd(t *testing.T) { args: "test/signtest --verify --keyring testdata/helm-test-key.pub", expectFile: "./signtest-0.1.0.tgz", expectVerify: true, + expectSha: "sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55", }, { name: "Fetch and fail verify", @@ -110,6 +115,7 @@ func TestPullCmd(t *testing.T) { expectFile: "./signtest2", expectDir: true, expectVerify: true, + expectSha: "sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55", }, { name: "Chart fetch using repo URL", @@ -171,13 +177,11 @@ func TestPullCmd(t *testing.T) { } if tt.expectVerify { - pointerAddressPattern := "0[xX][A-Fa-f0-9]+" - sha256Pattern := "[A-Fa-f0-9]{64}" - verificationRegex := regexp.MustCompile( - fmt.Sprintf("Verification: &{%s sha256:%s signtest-0.1.0.tgz}\n", pointerAddressPattern, sha256Pattern)) - if !verificationRegex.MatchString(out) { - t.Errorf("%q: expected match for regex %s, got %s", tt.name, verificationRegex, out) + outString := helmTestKeyOut + tt.expectSha + "\n" + if out != outString { + t.Errorf("%q: expected verification output %q, got %q", tt.name, outString, out) } + } ef := filepath.Join(outdir, tt.expectFile) diff --git a/pkg/action/pull.go b/pkg/action/pull.go index 4ff5f5c3e..ee20bbe83 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -101,7 +101,11 @@ func (p *Pull) Run(chartRef string) (string, error) { } if p.Verify { - fmt.Fprintf(&out, "Verification: %v\n", v) + for name := range v.SignedBy.Identities { + fmt.Fprintf(&out, "Signed by: %v\n", name) + } + fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", v.SignedBy.PrimaryKey.Fingerprint) + fmt.Fprintf(&out, "Chart Hash Verified: %s\n", v.FileHash) } // After verification, untar the chart into the requested directory. From af35d61a98412ff56da98c11b603a9ec54f101c1 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 28 Feb 2020 12:52:21 -0500 Subject: [PATCH 268/279] Add verification output to the verify command This complements the verification output fixed in #7706. On verify there should be some detail about the verification rather than no information. Signed-off-by: Matt Farina --- cmd/helm/verify.go | 10 +++++++++- cmd/helm/verify_test.go | 2 +- pkg/action/verify.go | 24 ++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/cmd/helm/verify.go b/cmd/helm/verify.go index d3ae517c9..f26fb377f 100644 --- a/cmd/helm/verify.go +++ b/cmd/helm/verify.go @@ -16,6 +16,7 @@ limitations under the License. package main import ( + "fmt" "io" "github.com/spf13/cobra" @@ -44,7 +45,14 @@ func newVerifyCmd(out io.Writer) *cobra.Command { Long: verifyDesc, Args: require.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - return client.Run(args[0]) + err := client.Run(args[0]) + if err != nil { + return err + } + + fmt.Fprint(out, client.Out) + + return nil }, } diff --git a/cmd/helm/verify_test.go b/cmd/helm/verify_test.go index a70051ff6..ccbcb3cf2 100644 --- a/cmd/helm/verify_test.go +++ b/cmd/helm/verify_test.go @@ -65,7 +65,7 @@ func TestVerifyCmd(t *testing.T) { { name: "verify validates a properly signed chart", cmd: "verify testdata/testcharts/signtest-0.1.0.tgz --keyring testdata/helm-test-key.pub", - expect: "", + expect: "Signed by: Helm Testing (This key should only be used for testing. DO NOT TRUST.) \nUsing Key With Fingerprint: 5E615389B53CA37F0EE60BD3843BBF981FC18762\nChart Hash Verified: sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55\n", wantError: false, }, } diff --git a/pkg/action/verify.go b/pkg/action/verify.go index c66b14b47..f36239496 100644 --- a/pkg/action/verify.go +++ b/pkg/action/verify.go @@ -17,6 +17,9 @@ limitations under the License. package action import ( + "fmt" + "strings" + "helm.sh/helm/v3/pkg/downloader" ) @@ -25,6 +28,7 @@ import ( // It provides the implementation of 'helm verify'. type Verify struct { Keyring string + Out string } // NewVerify creates a new Verify object with the given configuration. @@ -34,6 +38,22 @@ func NewVerify() *Verify { // Run executes 'helm verify'. func (v *Verify) Run(chartfile string) error { - _, err := downloader.VerifyChart(chartfile, v.Keyring) - return err + var out strings.Builder + p, err := downloader.VerifyChart(chartfile, v.Keyring) + if err != nil { + return err + } + + for name := range p.SignedBy.Identities { + fmt.Fprintf(&out, "Signed by: %v\n", name) + } + fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint) + fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash) + + // TODO(mattfarina): The output is set as a property rather than returned + // to maintain the Go API. In Helm v4 this function should return the out + // and the property on the struct can be removed. + v.Out = out.String() + + return nil } From 8edf86a7181c16fe4089c52f7b7fe58df5b08ce7 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 28 Feb 2020 12:35:01 -0800 Subject: [PATCH 269/279] fix(ADOPTERS): alphabetize org list (#7645) Signed-off-by: Matthew Fisher --- ADOPTERS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOPTERS.md b/ADOPTERS.md index a72f51e09..46b42b8a0 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -6,8 +6,8 @@ # Organizations Using Helm - [Blood Orange](https://bloodorange.io) -- [Microsoft](https://microsoft.com) - [IBM](https://www.ibm.com) +- [Microsoft](https://microsoft.com) - [Qovery](https://www.qovery.com/) - [Samsung SDS](https://www.samsungsds.com/) - [Ville de Montreal](https://montreal.ca) From 95d7f36d41d41f6e0efe1ec9839a7a3b85e76bc0 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 2 Mar 2020 13:39:58 +0800 Subject: [PATCH 270/279] add unit test for SecretDelete Signed-off-by: Zhou Hao --- pkg/storage/driver/secrets_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/storage/driver/secrets_test.go b/pkg/storage/driver/secrets_test.go index 892482e5b..e4420704d 100644 --- a/pkg/storage/driver/secrets_test.go +++ b/pkg/storage/driver/secrets_test.go @@ -184,3 +184,28 @@ func TestSecretUpdate(t *testing.T) { t.Errorf("Expected status %s, got status %s", rel.Info.Status.String(), got.Info.Status.String()) } } + +func TestSecretDelete(t *testing.T) { + vers := 1 + name := "smug-pigeon" + namespace := "default" + key := testKey(name, vers) + rel := releaseStub(name, vers, namespace, rspb.StatusDeployed) + + secrets := newTestFixtureSecrets(t, []*rspb.Release{rel}...) + + // perform the delete + rls, err := secrets.Delete(key) + if err != nil { + t.Fatalf("Failed to delete release with key %q: %s", key, err) + } + if !reflect.DeepEqual(rel, rls) { + t.Errorf("Expected {%v}, got {%v}", rel, rls) + } + + // fetch the deleted release + _, err = secrets.Get(key) + if !reflect.DeepEqual(ErrReleaseNotFound, err) { + t.Errorf("Expected {%v}, got {%v}", ErrReleaseNotFound, err) + } +} From ae508ebd1ca81a5d5ccba4f0729897872cb10409 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 2 Mar 2020 14:14:04 +0800 Subject: [PATCH 271/279] add unit test for ConfigMapDelete Signed-off-by: Zhou Hao --- pkg/storage/driver/cfgmaps_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/storage/driver/cfgmaps_test.go b/pkg/storage/driver/cfgmaps_test.go index 2aa38f284..a36cee1be 100644 --- a/pkg/storage/driver/cfgmaps_test.go +++ b/pkg/storage/driver/cfgmaps_test.go @@ -184,3 +184,28 @@ func TestConfigMapUpdate(t *testing.T) { t.Errorf("Expected status %s, got status %s", rel.Info.Status.String(), got.Info.Status.String()) } } + +func TestConfigMapDelete(t *testing.T) { + vers := 1 + name := "smug-pigeon" + namespace := "default" + key := testKey(name, vers) + rel := releaseStub(name, vers, namespace, rspb.StatusDeployed) + + cfgmaps := newTestFixtureCfgMaps(t, []*rspb.Release{rel}...) + + // perform the delete + rls, err := cfgmaps.Delete(key) + if err != nil { + t.Fatalf("Failed to delete release with key %q: %s", key, err) + } + if !reflect.DeepEqual(rel, rls) { + t.Errorf("Expected {%v}, got {%v}", rel, rls) + } + + // fetch the deleted release + _, err = cfgmaps.Get(key) + if !reflect.DeepEqual(ErrReleaseNotFound, err) { + t.Errorf("Expected {%v}, got {%v}", ErrReleaseNotFound, err) + } +} From 9744e9f619d3c1d8ddbe3af59e7d70d81c05dc5a Mon Sep 17 00:00:00 2001 From: Dong Gang Date: Mon, 2 Mar 2020 14:23:35 +0800 Subject: [PATCH 272/279] fix(helm): respect resource policy on ungrade Don't delete a resource on upgrade if it is annotated with helm.io/resource-policy=keep. This can cause data loss for users if the annotation is ignored(e.g. for a PVC) Close #7677 Signed-off-by: Dong Gang --- pkg/kube/client.go | 16 ++++++++++++++++ pkg/kube/resource_policy.go | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 pkg/kube/resource_policy.go diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 31dabcc5d..04f247c93 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -21,6 +21,7 @@ import ( "encoding/json" "fmt" "io" + "k8s.io/apimachinery/pkg/api/meta" "strings" "sync" "time" @@ -50,6 +51,8 @@ import ( // ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found. var ErrNoObjectsVisited = errors.New("no objects visited") +var metadataAccessor = meta.NewAccessor() + // Client represents a client capable of communicating with the Kubernetes API. type Client struct { Factory Factory @@ -210,6 +213,19 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err for _, info := range original.Difference(target) { c.Log("Deleting %q in %s...", info.Name, info.Namespace) + + if err := info.Get(); err != nil { + c.Log("Unable to get obj %q, err: %s", info.Name, err) + } + annotations, err := metadataAccessor.Annotations(info.Object) + if err != nil { + c.Log("Unable to get annotations on %q, err: %s", info.Name, err) + } + if annotations != nil && annotations[ResourcePolicyAnno] == KeepPolicy { + c.Log("Skipping delete of %q due to annotation [%s=%s]", info.Name, ResourcePolicyAnno, KeepPolicy) + continue + } + res.Deleted = append(res.Deleted, info) if err := deleteResource(info); err != nil { if apierrors.IsNotFound(err) { diff --git a/pkg/kube/resource_policy.go b/pkg/kube/resource_policy.go new file mode 100644 index 000000000..5f391eb50 --- /dev/null +++ b/pkg/kube/resource_policy.go @@ -0,0 +1,26 @@ +/* +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kube // import "helm.sh/helm/v3/pkg/kube" + +// ResourcePolicyAnno is the annotation name for a resource policy +const ResourcePolicyAnno = "helm.sh/resource-policy" + +// KeepPolicy is the resource policy type for keep +// +// This resource policy type allows resources to skip being deleted +// during an uninstallRelease action. +const KeepPolicy = "keep" From f5da6bd3d679e8da62cdf50c45503714d1510a73 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Mon, 2 Mar 2020 14:32:57 +0800 Subject: [PATCH 273/279] add unit test for RecordsReplace Signed-off-by: Zhou Hao --- pkg/storage/driver/records_test.go | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pkg/storage/driver/records_test.go b/pkg/storage/driver/records_test.go index 3ede92bcd..0a27839cc 100644 --- a/pkg/storage/driver/records_test.go +++ b/pkg/storage/driver/records_test.go @@ -204,3 +204,37 @@ func TestRecordsExists(t *testing.T) { } } } + +func TestRecordsReplace(t *testing.T) { + rs := records([]*record{ + newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)), + newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)), + }) + + var tests = []struct { + desc string + key string + rec *record + expected *record + }{ + { + "replace with existing key", + "rls-a.v2", + newRecord("rls-a.v3", releaseStub("rls-a", 3, "default", rspb.StatusSuperseded)), + newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)), + }, + { + "replace with non existing key", + "rls-a.v4", + newRecord("rls-a.v4", releaseStub("rls-a", 4, "default", rspb.StatusDeployed)), + nil, + }, + } + + for _, tt := range tests { + got := rs.Replace(tt.key, tt.rec) + if !reflect.DeepEqual(tt.expected, got) { + t.Fatalf("Expected %v, got %v", tt.expected, got) + } + } +} From c45869c4ad8f46140f6aea0d673aa7892f3eefad Mon Sep 17 00:00:00 2001 From: Dong Gang Date: Mon, 2 Mar 2020 14:47:54 +0800 Subject: [PATCH 274/279] fix(helm): polish goimport Signed-off-by: Dong Gang --- pkg/kube/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 04f247c93..b761c6d12 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "io" - "k8s.io/apimachinery/pkg/api/meta" "strings" "sync" "time" @@ -34,6 +33,7 @@ import ( apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" From 69d9722edaea6f54194d6ab508142d3f4eb2be14 Mon Sep 17 00:00:00 2001 From: Dong Gang Date: Mon, 2 Mar 2020 14:55:53 +0800 Subject: [PATCH 275/279] test(helm): fix client update error Signed-off-by: Dong Gang --- pkg/kube/client_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index 9e7581d00..aa081423c 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -147,6 +147,8 @@ func TestUpdate(t *testing.T) { return newResponse(200, &listB.Items[1]) case p == "/namespaces/default/pods/squid" && m == "DELETE": return newResponse(200, &listB.Items[1]) + case p == "/namespaces/default/pods/squid" && m == "GET": + return newResponse(200, &listB.Items[2]) default: t.Fatalf("unexpected request: %s %s", req.Method, req.URL.Path) return nil, nil @@ -184,6 +186,7 @@ func TestUpdate(t *testing.T) { "/namespaces/default/pods/otter:GET", "/namespaces/default/pods/dolphin:GET", "/namespaces/default/pods:POST", + "/namespaces/default/pods/squid:GET", "/namespaces/default/pods/squid:DELETE", } if len(expectedActions) != len(actions) { From a992464fa298e957ffd014496aca5fb97252cbdb Mon Sep 17 00:00:00 2001 From: Song Shukun Date: Tue, 25 Feb 2020 18:26:00 +0900 Subject: [PATCH 276/279] Save Chart.lock to helm package tar Signed-off-by: Song Shukun --- pkg/chartutil/save.go | 14 ++++++++++++++ pkg/chartutil/save_test.go | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index be0dfdc24..a2c6a9225 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -161,6 +161,20 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { return err } + // Save Chart.lock + // TODO: remove the APIVersion check when APIVersionV1 is not used anymore + if c.Metadata.APIVersion == chart.APIVersionV2 { + if c.Lock != nil { + ldata, err := yaml.Marshal(c.Lock) + if err != nil { + return err + } + if err := writeToTar(out, filepath.Join(base, "Chart.lock"), ldata); err != nil { + return err + } + } + } + // Save values.yaml for _, f := range c.Raw { if f.Name == ValuesfileName { diff --git a/pkg/chartutil/save_test.go b/pkg/chartutil/save_test.go index f367d42eb..306c13cee 100644 --- a/pkg/chartutil/save_test.go +++ b/pkg/chartutil/save_test.go @@ -49,6 +49,9 @@ func TestSave(t *testing.T) { Name: "ahab", Version: "1.2.3", }, + Lock: &chart.Lock{ + Digest: "testdigest", + }, Files: []*chart.File{ {Name: "scheherazade/shahryar.txt", Data: []byte("1,001 Nights")}, }, @@ -77,6 +80,9 @@ func TestSave(t *testing.T) { if len(c2.Files) != 1 || c2.Files[0].Name != "scheherazade/shahryar.txt" { t.Fatal("Files data did not match") } + if c2.Lock != nil { + t.Fatal("Expected v1 chart archive not to contain Chart.lock file") + } if !bytes.Equal(c.Schema, c2.Schema) { indentation := 4 @@ -87,6 +93,22 @@ func TestSave(t *testing.T) { if _, err := Save(&chartWithInvalidJSON, dest); err == nil { t.Fatalf("Invalid JSON was not caught while saving chart") } + + c.Metadata.APIVersion = chart.APIVersionV2 + where, err = Save(c, dest) + if err != nil { + t.Fatalf("Failed to save: %s", err) + } + c2, err = loader.LoadFile(where) + if err != nil { + t.Fatal(err) + } + if c2.Lock == nil { + t.Fatal("Expected v2 chart archive to containe a Chart.lock file") + } + if c2.Lock.Digest != c.Lock.Digest { + t.Fatal("Chart.lock data did not match") + } }) } } From 14f6d1ea97eeef158adf7db0e9b42206905930bf Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 2 Mar 2020 12:09:41 -0800 Subject: [PATCH 277/279] ref(environment): use string checking instead It is more idiomatic to compare the string against the empty string than to check the string's length. Signed-off-by: Matthew Fisher --- pkg/cli/environment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 1e3b23617..e279331b0 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -135,10 +135,10 @@ func (s *EnvSettings) Namespace() string { func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { s.configOnce.Do(func() { clientConfig := kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace) - if len(s.KubeToken) > 0 { + if s.KubeToken != "" { clientConfig.BearerToken = &s.KubeToken } - if len(s.KubeAPIServer) > 0 { + if s.KubeAPIServer != "" { clientConfig.APIServer = &s.KubeAPIServer } From dc26128fb4d55ecd1c0b600195b639e93aec02e2 Mon Sep 17 00:00:00 2001 From: Matthias Riegler Date: Wed, 4 Mar 2020 00:52:33 +0100 Subject: [PATCH 278/279] Add --insecure-skip-tls-verify for repositories (#7254) * added --insecure-skip-tls-verify for chart repos Signed-off-by: Matthias Riegler * fixed not passing the insecureSkipTLSverify option Signed-off-by: Matthias Riegler * fixed testcase Signed-off-by: Matthias Riegler * pass proxy when using insecureSkipVerify Signed-off-by: Matthias Riegler * Add testcases for insecureSkipVerifyTLS Signed-off-by: Matthias Riegler * added missing err check Signed-off-by: Matthias Riegler * panic after json marshal fails Signed-off-by: Matthias Riegler --- cmd/helm/repo_add.go | 23 ++++++++------ pkg/getter/getter.go | 22 +++++++++----- pkg/getter/httpgetter.go | 15 +++++++++ pkg/getter/httpgetter_test.go | 57 +++++++++++++++++++++++++++++++++++ pkg/repo/chartrepo.go | 26 +++++++++++----- 5 files changed, 119 insertions(+), 24 deletions(-) diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index e6afce3d5..3d36fd0ed 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -43,9 +43,10 @@ type repoAddOptions struct { password string noUpdate bool - certFile string - keyFile string - caFile string + certFile string + keyFile string + caFile string + insecureSkipTLSverify bool repoFile string repoCache string @@ -75,6 +76,7 @@ func newRepoAddCmd(out io.Writer) *cobra.Command { f.StringVar(&o.certFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") f.StringVar(&o.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") + f.BoolVar(&o.insecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the repository") return cmd } @@ -113,13 +115,14 @@ func (o *repoAddOptions) run(out io.Writer) error { } c := repo.Entry{ - Name: o.name, - URL: o.url, - Username: o.username, - Password: o.password, - CertFile: o.certFile, - KeyFile: o.keyFile, - CAFile: o.caFile, + Name: o.name, + URL: o.url, + Username: o.username, + Password: o.password, + CertFile: o.certFile, + KeyFile: o.keyFile, + CAFile: o.caFile, + InsecureSkipTLSverify: o.insecureSkipTLSverify, } r, err := repo.NewChartRepository(&c, getter.All(settings)) diff --git a/pkg/getter/getter.go b/pkg/getter/getter.go index 68638c2ca..4ccc74834 100644 --- a/pkg/getter/getter.go +++ b/pkg/getter/getter.go @@ -28,13 +28,14 @@ import ( // // Getters may or may not ignore these parameters as they are passed in. type options struct { - url string - certFile string - keyFile string - caFile string - username string - password string - userAgent string + url string + certFile string + keyFile string + caFile string + insecureSkipVerifyTLS bool + username string + password string + userAgent string } // Option allows specifying various settings configurable by the user for overriding the defaults @@ -64,6 +65,13 @@ func WithUserAgent(userAgent string) Option { } } +// WithInsecureSkipVerifyTLS determines if a TLS Certificate will be checked +func WithInsecureSkipVerifyTLS(insecureSkipVerifyTLS bool) Option { + return func(opts *options) { + opts.insecureSkipVerifyTLS = insecureSkipVerifyTLS + } +} + // WithTLSClientConfig sets the client auth with the provided credentials. func WithTLSClientConfig(certFile, keyFile, caFile string) Option { return func(opts *options) { diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index 5b476ff2d..695a87743 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -17,6 +17,7 @@ package getter import ( "bytes" + "crypto/tls" "io" "net/http" @@ -111,5 +112,19 @@ func (g *HTTPGetter) httpClient() (*http.Client, error) { return client, nil } + + if g.opts.insecureSkipVerifyTLS { + client := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, + }, + Proxy: http.ProxyFromEnvironment, + }, + } + + return client, nil + } + return http.DefaultClient, nil } diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index b20085574..a1288bf47 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -44,12 +44,14 @@ func TestHTTPGetter(t *testing.T) { cd := "../../testdata" join := filepath.Join ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem") + insecure := false // Test with options g, err = NewHTTPGetter( WithBasicAuth("I", "Am"), WithUserAgent("Groot"), WithTLSClientConfig(pub, priv, ca), + WithInsecureSkipVerifyTLS(insecure), ) if err != nil { t.Fatal(err) @@ -83,6 +85,29 @@ func TestHTTPGetter(t *testing.T) { if hg.opts.caFile != ca { t.Errorf("Expected NewHTTPGetter to contain %q as the CA file, got %q", ca, hg.opts.caFile) } + + if hg.opts.insecureSkipVerifyTLS != insecure { + t.Errorf("Expected NewHTTPGetter to contain %t as InsecureSkipVerifyTLs flag, got %t", false, hg.opts.insecureSkipVerifyTLS) + } + + // Test if setting insecureSkipVerifyTLS is being passed to the ops + insecure = true + + g, err = NewHTTPGetter( + WithInsecureSkipVerifyTLS(insecure), + ) + if err != nil { + t.Fatal(err) + } + + hg, ok = g.(*HTTPGetter) + if !ok { + t.Fatal("expected NewHTTPGetter to produce an *HTTPGetter") + } + + if hg.opts.insecureSkipVerifyTLS != insecure { + t.Errorf("Expected NewHTTPGetter to contain %t as InsecureSkipVerifyTLs flag, got %t", insecure, hg.opts.insecureSkipVerifyTLS) + } } func TestDownload(t *testing.T) { @@ -191,3 +216,35 @@ func TestDownloadTLS(t *testing.T) { t.Error(err) } } + +func TestDownloadInsecureSkipTLSVerify(t *testing.T) { + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) + defer ts.Close() + + u, _ := url.ParseRequestURI(ts.URL) + + // Ensure the default behaviour did not change + g, err := NewHTTPGetter( + WithURL(u.String()), + ) + if err != nil { + t.Error(err) + } + + if _, err := g.Get(u.String()); err == nil { + t.Errorf("Expected Getter to throw an error, got %s", err) + } + + // Test certificate check skip + g, err = NewHTTPGetter( + WithURL(u.String()), + WithInsecureSkipVerifyTLS(true), + ) + if err != nil { + t.Error(err) + } + if _, err = g.Get(u.String()); err != nil { + t.Error(err) + } + +} diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 38b6b8fb0..c2c366a1e 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -19,8 +19,10 @@ package repo // import "helm.sh/helm/v3/pkg/repo" import ( "crypto/rand" "encoding/base64" + "encoding/json" "fmt" "io/ioutil" + "log" "net/url" "os" "path" @@ -38,13 +40,14 @@ import ( // Entry represents a collection of parameters for chart repository type Entry struct { - Name string `json:"name"` - URL string `json:"url"` - Username string `json:"username"` - Password string `json:"password"` - CertFile string `json:"certFile"` - KeyFile string `json:"keyFile"` - CAFile string `json:"caFile"` + Name string `json:"name"` + URL string `json:"url"` + Username string `json:"username"` + Password string `json:"password"` + CertFile string `json:"certFile"` + KeyFile string `json:"keyFile"` + CAFile string `json:"caFile"` + InsecureSkipTLSverify bool `json:"insecure_skip_tls_verify"` } // ChartRepository represents a chart repository @@ -121,6 +124,7 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) { // TODO add user-agent resp, err := r.Client.Get(indexURL, getter.WithURL(r.Config.URL), + getter.WithInsecureSkipVerifyTLS(r.Config.InsecureSkipTLSverify), getter.WithTLSClientConfig(r.Config.CertFile, r.Config.KeyFile, r.Config.CAFile), getter.WithBasicAuth(r.Config.Username, r.Config.Password), ) @@ -271,3 +275,11 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { parsedBaseURL.Path = strings.TrimSuffix(parsedBaseURL.Path, "/") + "/" return parsedBaseURL.ResolveReference(parsedRefURL).String(), nil } + +func (e *Entry) String() string { + buf, err := json.Marshal(e) + if err != nil { + log.Panic(err) + } + return string(buf) +} From 16024dc19a23e83f00a19742033031717a56be0e Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 3 Mar 2020 17:28:57 -0700 Subject: [PATCH 279/279] fix: add new static linter and fix issues it found (#7655) * fix: add new static linter and fix issues it found Signed-off-by: Matt Butcher * fixed two additional linter errors. Signed-off-by: Matt Butcher --- .golangci.yml | 1 + cmd/helm/lint.go | 2 +- go.mod | 1 + internal/completion/complete.go | 4 ++-- internal/experimental/registry/client_test.go | 4 ++-- pkg/lint/rules/template.go | 8 +++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2c3b6234d..491e648a1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,6 +17,7 @@ linters: - structcheck - unused - varcheck + - staticcheck linters-settings: gofmt: diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index bc0d1852b..fe39a5741 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -106,7 +106,7 @@ func newLintCmd(out io.Writer) *cobra.Command { fmt.Fprint(&message, "\n") } - fmt.Fprintf(out, message.String()) + fmt.Fprint(out, message.String()) summary := fmt.Sprintf("%d chart(s) linted, %d chart(s) failed", len(paths), failed) if failed > 0 { diff --git a/go.mod b/go.mod index 7ba7a5542..4e3bcf9a1 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/stretchr/testify v1.4.0 github.com/xeipuuv/gojsonschema v1.1.0 golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d + honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect k8s.io/api v0.17.3 k8s.io/apiextensions-apiserver v0.17.3 k8s.io/apimachinery v0.17.3 diff --git a/internal/completion/complete.go b/internal/completion/complete.go index eaea4e914..545f5b0dd 100644 --- a/internal/completion/complete.go +++ b/internal/completion/complete.go @@ -368,7 +368,7 @@ func CompDebug(msg string) { if debug { // Must print to stderr for this not to be read by the completion script. - fmt.Fprintf(os.Stderr, msg) + fmt.Fprintln(os.Stderr, msg) } } @@ -389,7 +389,7 @@ func CompError(msg string) { // If not already printed by the call to CompDebug(). if !debug { // Must print to stderr for this not to be read by the completion script. - fmt.Fprintf(os.Stderr, msg) + fmt.Fprintln(os.Stderr, msg) } } diff --git a/internal/experimental/registry/client_test.go b/internal/experimental/registry/client_test.go index 33799f5fa..6e9d5db36 100644 --- a/internal/experimental/registry/client_test.go +++ b/internal/experimental/registry/client_test.go @@ -162,13 +162,13 @@ func (suite *RegistryClientTestSuite) Test_2_LoadChart() { // non-existent ref ref, err := ParseReference(fmt.Sprintf("%s/testrepo/whodis:9.9.9", suite.DockerRegistryHost)) suite.Nil(err) - ch, err := suite.RegistryClient.LoadChart(ref) + _, err = suite.RegistryClient.LoadChart(ref) suite.NotNil(err) // existing ref ref, err = ParseReference(fmt.Sprintf("%s/testrepo/testchart:1.2.3", suite.DockerRegistryHost)) suite.Nil(err) - ch, err = suite.RegistryClient.LoadChart(ref) + ch, err := suite.RegistryClient.LoadChart(ref) suite.Nil(err) suite.Equal("testchart", ch.Metadata.Name) suite.Equal("1.2.3", ch.Metadata.Version) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 5c6cd7336..3d388f81b 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -116,11 +116,9 @@ func Templates(linter *support.Linter, values map[string]interface{}, namespace // key will be raised as well err := yaml.Unmarshal([]byte(renderedContent), &yamlStruct) - validYaml := linter.RunLinterRule(support.ErrorSev, path, validateYamlContent(err)) - - if !validYaml { - continue - } + // If YAML linting fails, we sill progress. So we don't capture the returned state + // on this linter run. + linter.RunLinterRule(support.ErrorSev, path, validateYamlContent(err)) } }