Repository: helm/chart-testing
Pull request #456 (2022-07-25 23:25:13)

Bump sigstore/cosign-installer from 2.4.1 to 2.5.0
Bumps [sigstore/cosign-installer](https://github.com/sigstore/cosign-installer) from 2.4.1 to 2.5.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/sigstore/cosign-installer/releases">sigstore/cosign-installer's releases</a>.</em></p>
<blockquote>
<h2>v2.5.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update action to install cosign 1.10.0 by default by <a href="https://github.com/cpanato"><code>@​cpanato</code></a> in <a href="https://github-redirect.dependabot.com/sigstore/cosign-installer/pull/86">sigstore/cosign-installer#86</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/sigstore/cosign-installer/compare/v2.4.1...v2.5.0">https://github.com/sigstore/cosign-installer/compare/v2.4.1...v2.5.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/sigstore/cosign-installer/commit/09a077b27eb1310dcfb21981bee195b30ce09de0"><code>09a077b</code></a> Update action to install cosign 1.10.0 by default (<a href="https://github-redirect.dependabot.com/sigstore/cosign-installer/issues/86">#86</a>)</li>
<li>See full diff in <a href="https://github.com/sigstore/cosign-installer/compare/48866aa521d8bf870604709cd43ec2f602d03ff2...09a077b27eb1310dcfb21981bee195b30ce09de0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sigstore/cosign-installer&package-manager=github_actions&previous-version=2.4.1&new-version=2.5.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 67dbbb3..8e5183a 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -35,7 +35,7 @@ jobs:
           install-only: true
 
       - name: Install cosign
-        uses: sigstore/cosign-installer@48866aa521d8bf870604709cd43ec2f602d03ff2 # v2.4.0
+        uses: sigstore/cosign-installer@09a077b27eb1310dcfb21981bee195b30ce09de0 # v2.4.0
 
       - name: Install syft
         uses: anchore/sbom-action/download-syft@bb716408e75840bbb01e839347cd213767269d4a # v0.11.0
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 907f8e2..bb1712b 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -36,7 +36,7 @@ jobs:
           install-only: true
 
       - name: Install cosign
-        uses: sigstore/cosign-installer@48866aa521d8bf870604709cd43ec2f602d03ff2 # v2.4.0
+        uses: sigstore/cosign-installer@09a077b27eb1310dcfb21981bee195b30ce09de0 # v2.4.0
 
       - name: Install syft
         uses: anchore/sbom-action/download-syft@bb716408e75840bbb01e839347cd213767269d4a # v0.11.0
diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go
index b222f39..c66c8e0 100644
--- a/pkg/chart/chart.go
+++ b/pkg/chart/chart.go
@@ -263,7 +263,7 @@ func NewTesting(config config.Configuration, extraSetArgs string) (Testing, erro
 		config:           config,
 		helm:             tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
 		git:              tool.NewGit(procExec),
-		kubectl:          tool.NewKubectl(procExec),
+		kubectl:          tool.NewKubectl(procExec, config.KubectlTimeout),
 		linter:           tool.NewLinter(procExec),
 		cmdExecutor:      tool.NewCmdTemplateExecutor(procExec),
 		accountValidator: tool.AccountValidator{},
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 33f2ace..7113761 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -20,6 +20,7 @@ import (
 	"path/filepath"
 	"reflect"
 	"strings"
+	"time"
 
 	"github.com/mitchellh/go-homedir"
 
@@ -41,36 +42,39 @@ var (
 )
 
 type Configuration struct {
-	Remote                  string   `mapstructure:"remote"`
-	TargetBranch            string   `mapstructure:"target-branch"`
-	Since                   string   `mapstructure:"since"`
-	BuildId                 string   `mapstructure:"build-id"`
-	LintConf                string   `mapstructure:"lint-conf"`
-	ChartYamlSchema         string   `mapstructure:"chart-yaml-schema"`
-	ValidateMaintainers     bool     `mapstructure:"validate-maintainers"`
-	ValidateChartSchema     bool     `mapstructure:"validate-chart-schema"`
-	ValidateYaml            bool     `mapstructure:"validate-yaml"`
-	AdditionalCommands      []string `mapstructure:"additional-commands"`
-	CheckVersionIncrement   bool     `mapstructure:"check-version-increment"`
-	ProcessAllCharts        bool     `mapstructure:"all"`
-	Charts                  []string `mapstructure:"charts"`
-	ChartRepos              []string `mapstructure:"chart-repos"`
-	ChartDirs               []string `mapstructure:"chart-dirs"`
-	ExcludedCharts          []string `mapstructure:"excluded-charts"`
-	HelmExtraArgs           string   `mapstructure:"helm-extra-args"`
-	HelmRepoExtraArgs       []string `mapstructure:"helm-repo-extra-args"`
-	HelmDependencyExtraArgs []string `mapstructure:"helm-dependency-extra-args"`
-	Debug                   bool     `mapstructure:"debug"`
-	Upgrade                 bool     `mapstructure:"upgrade"`
-	SkipMissingValues       bool     `mapstructure:"skip-missing-values"`
-	Namespace               string   `mapstructure:"namespace"`
-	ReleaseLabel            string   `mapstructure:"release-label"`
-	ExcludeDeprecated       bool     `mapstructure:"exclude-deprecated"`
+	Remote                  string        `mapstructure:"remote"`
+	TargetBranch            string        `mapstructure:"target-branch"`
+	Since                   string        `mapstructure:"since"`
+	BuildId                 string        `mapstructure:"build-id"`
+	LintConf                string        `mapstructure:"lint-conf"`
+	ChartYamlSchema         string        `mapstructure:"chart-yaml-schema"`
+	ValidateMaintainers     bool          `mapstructure:"validate-maintainers"`
+	ValidateChartSchema     bool          `mapstructure:"validate-chart-schema"`
+	ValidateYaml            bool          `mapstructure:"validate-yaml"`
+	AdditionalCommands      []string      `mapstructure:"additional-commands"`
+	CheckVersionIncrement   bool          `mapstructure:"check-version-increment"`
+	ProcessAllCharts        bool          `mapstructure:"all"`
+	Charts                  []string      `mapstructure:"charts"`
+	ChartRepos              []string      `mapstructure:"chart-repos"`
+	ChartDirs               []string      `mapstructure:"chart-dirs"`
+	ExcludedCharts          []string      `mapstructure:"excluded-charts"`
+	HelmExtraArgs           string        `mapstructure:"helm-extra-args"`
+	HelmRepoExtraArgs       []string      `mapstructure:"helm-repo-extra-args"`
+	HelmDependencyExtraArgs []string      `mapstructure:"helm-dependency-extra-args"`
+	Debug                   bool          `mapstructure:"debug"`
+	Upgrade                 bool          `mapstructure:"upgrade"`
+	SkipMissingValues       bool          `mapstructure:"skip-missing-values"`
+	Namespace               string        `mapstructure:"namespace"`
+	ReleaseLabel            string        `mapstructure:"release-label"`
+	ExcludeDeprecated       bool          `mapstructure:"exclude-deprecated"`
+	KubectlTimeout          time.Duration `mapstructure:"kubectl-timeout"`
 }
 
 func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*Configuration, error) {
 	v := viper.New()
 
+	v.SetDefault("kubectl-timeout", time.Duration(30*time.Second))
+
 	cmd.Flags().VisitAll(func(flag *flag.Flag) {
 		flagName := flag.Name
 		if flagName != "config" && flagName != "help" {
diff --git a/pkg/tool/kubectl.go b/pkg/tool/kubectl.go
index 13fa70d..d2021e5 100644
--- a/pkg/tool/kubectl.go
+++ b/pkg/tool/kubectl.go
@@ -14,19 +14,23 @@ import (
 )
 
 type Kubectl struct {
-	exec exec.ProcessExecutor
+	exec    exec.ProcessExecutor
+	timeout time.Duration
 }
 
-func NewKubectl(exec exec.ProcessExecutor) Kubectl {
+func NewKubectl(exec exec.ProcessExecutor, timeout time.Duration) Kubectl {
 	return Kubectl{
-		exec: exec,
+		exec:    exec,
+		timeout: timeout,
 	}
 }
 
 // CreateNamespace creates a new namespace with the given name.
 func (k Kubectl) CreateNamespace(namespace string) error {
 	fmt.Printf("Creating namespace '%s'...\n", namespace)
-	return k.exec.RunProcess("kubectl", "create", "namespace", namespace)
+	return k.exec.RunProcess("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"create", "namespace", namespace)
 }
 
 // DeleteNamespace deletes the specified namespace. If the namespace does not terminate within 120s, pods running in the
@@ -34,7 +38,10 @@ func (k Kubectl) CreateNamespace(namespace string) error {
 func (k Kubectl) DeleteNamespace(namespace string) {
 	fmt.Printf("Deleting namespace '%s'...\n", namespace)
 	timeoutSec := "180s"
-	if err := k.exec.RunProcess("kubectl", "delete", "namespace", namespace, "--timeout", timeoutSec); err != nil {
+	err := k.exec.RunProcess("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"delete", "namespace", namespace, "--timeout", timeoutSec)
+	if err != nil {
 		fmt.Printf("Namespace '%s' did not terminate after %s.\n", namespace, timeoutSec)
 	}
 
@@ -42,7 +49,11 @@ func (k Kubectl) DeleteNamespace(namespace string) {
 		fmt.Printf("Namespace '%s' did not terminate after %s.\n", namespace, timeoutSec)
 
 		fmt.Println("Force-deleting everything...")
-		if err := k.exec.RunProcess("kubectl", "delete", "all", "--namespace", namespace, "--all", "--force", "--grace-period=0"); err != nil {
+		err = k.exec.RunProcess("kubectl",
+			fmt.Sprintf("--request-timeout=%s", k.timeout),
+			"delete", "all", "--namespace", namespace, "--all", "--force",
+			"--grace-period=0")
+		if err != nil {
 			fmt.Printf("Error deleting everything in the namespace %v: %v", namespace, err)
 		}
 
@@ -59,7 +70,9 @@ func (k Kubectl) DeleteNamespace(namespace string) {
 
 func (k Kubectl) forceNamespaceDeletion(namespace string) error {
 	// Getting the namespace json to remove the finalizer
-	cmdOutput, err := k.exec.RunProcessAndCaptureOutput("kubectl", "get", "namespace", namespace, "--output=json")
+	cmdOutput, err := k.exec.RunProcessAndCaptureOutput("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"get", "namespace", namespace, "--output=json")
 	if err != nil {
 		fmt.Println("Error getting namespace json:", err)
 		return err
@@ -111,13 +124,20 @@ func (k Kubectl) forceNamespaceDeletion(namespace string) error {
 	time.Sleep(5 * time.Second)
 
 	// Check again
-	if _, err := k.exec.RunProcessAndCaptureOutput("kubectl", "get", "namespace", namespace); err != nil {
+	_, err = k.exec.RunProcessAndCaptureOutput("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"get", "namespace", namespace)
+	if err != nil {
 		fmt.Printf("Namespace '%s' terminated.\n", namespace)
 		return nil
 	}
 
 	fmt.Printf("Force-deleting namespace '%s'...\n", namespace)
-	if err := k.exec.RunProcess("kubectl", "delete", "namespace", namespace, "--force", "--grace-period=0", "--ignore-not-found=true"); err != nil {
+	err = k.exec.RunProcess("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"delete", "namespace", namespace, "--force", "--grace-period=0",
+		"--ignore-not-found=true")
+	if err != nil {
 		fmt.Println("Error deleting namespace:", err)
 		return err
 	}
@@ -126,8 +146,10 @@ func (k Kubectl) forceNamespaceDeletion(namespace string) error {
 }
 
 func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
-	output, err := k.exec.RunProcessAndCaptureOutput(
-		"kubectl", "get", "deployments", "--namespace", namespace, "--selector", selector, "--output", "jsonpath={.items[*].metadata.name}")
+	output, err := k.exec.RunProcessAndCaptureOutput("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"get", "deployments", "--namespace", namespace, "--selector", selector,
+		"--output", "jsonpath={.items[*].metadata.name}")
 	if err != nil {
 		return err
 	}
@@ -135,7 +157,9 @@ func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
 	deployments := strings.Fields(output)
 	for _, deployment := range deployments {
 		deployment = strings.Trim(deployment, "'")
-		err := k.exec.RunProcess("kubectl", "rollout", "status", "deployment", deployment, "--namespace", namespace)
+		err = k.exec.RunProcess("kubectl",
+			fmt.Sprintf("--request-timeout=%s", k.timeout),
+			"rollout", "status", "deployment", deployment, "--namespace", namespace)
 		if err != nil {
 			return err
 		}
@@ -145,7 +169,9 @@ func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
 		//
 		// Just after rollout, pods from the previous deployment revision may still be in a
 		// terminating state.
-		unavailable, err := k.exec.RunProcessAndCaptureOutput("kubectl", "get", "deployment", deployment, "--namespace", namespace, "--output",
+		unavailable, err := k.exec.RunProcessAndCaptureOutput("kubectl",
+			fmt.Sprintf("--request-timeout=%s", k.timeout),
+			"get", "deployment", deployment, "--namespace", namespace, "--output",
 			`jsonpath={.status.unavailableReplicas}`)
 		if err != nil {
 			return err
@@ -159,7 +185,9 @@ func (k Kubectl) WaitForDeployments(namespace string, selector string) error {
 }
 
 func (k Kubectl) GetPodsforDeployment(namespace string, deployment string) ([]string, error) {
-	jsonString, _ := k.exec.RunProcessAndCaptureOutput("kubectl", "get", "deployment", deployment, "--namespace", namespace, "--output=json")
+	jsonString, _ := k.exec.RunProcessAndCaptureOutput("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"get", "deployment", deployment, "--namespace", namespace, "--output=json")
 	var deploymentMap map[string]interface{}
 	err := json.Unmarshal([]byte(jsonString), &deploymentMap)
 	if err != nil {
@@ -183,7 +211,8 @@ func (k Kubectl) GetPodsforDeployment(namespace string, deployment string) ([]st
 func (k Kubectl) GetPods(args ...string) ([]string, error) {
 	kubectlArgs := []string{"get", "pods"}
 	kubectlArgs = append(kubectlArgs, args...)
-	pods, err := k.exec.RunProcessAndCaptureOutput("kubectl", kubectlArgs)
+	pods, err := k.exec.RunProcessAndCaptureOutput("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout), kubectlArgs)
 	if err != nil {
 		return nil, err
 	}
@@ -191,15 +220,21 @@ func (k Kubectl) GetPods(args ...string) ([]string, error) {
 }
 
 func (k Kubectl) GetEvents(namespace string) error {
-	return k.exec.RunProcess("kubectl", "get", "events", "--output", "wide", "--namespace", namespace)
+	return k.exec.RunProcess("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"get", "events", "--output", "wide", "--namespace", namespace)
 }
 
 func (k Kubectl) DescribePod(namespace string, pod string) error {
-	return k.exec.RunProcess("kubectl", "describe", "pod", pod, "--namespace", namespace)
+	return k.exec.RunProcess("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"describe", "pod", pod, "--namespace", namespace)
 }
 
 func (k Kubectl) Logs(namespace string, pod string, container string) error {
-	return k.exec.RunProcess("kubectl", "logs", pod, "--namespace", namespace, "--container", container)
+	return k.exec.RunProcess("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"logs", pod, "--namespace", namespace, "--container", container)
 }
 
 func (k Kubectl) GetInitContainers(namespace string, pod string) ([]string, error) {
@@ -211,7 +246,10 @@ func (k Kubectl) GetContainers(namespace string, pod string) ([]string, error) {
 }
 
 func (k Kubectl) getNamespace(namespace string) bool {
-	if _, err := k.exec.RunProcessAndCaptureOutput("kubectl", "get", "namespace", namespace); err != nil {
+	_, err := k.exec.RunProcessAndCaptureOutput("kubectl",
+		fmt.Sprintf("--request-timeout=%s", k.timeout),
+		"get", "namespace", namespace)
+	if err != nil {
 		fmt.Printf("Namespace '%s' terminated.\n", namespace)
 		return false
 	}


Test patch:
diff --git a/pkg/chart/integration_test.go b/pkg/chart/integration_test.go
index 63fa5d6..9d5f881 100644
--- a/pkg/chart/integration_test.go
+++ b/pkg/chart/integration_test.go
@@ -21,6 +21,7 @@ import (
 	"fmt"
 	"strings"
 	"testing"
+	"time"
 
 	"github.com/helm/chart-testing/v3/pkg/config"
 	"github.com/helm/chart-testing/v3/pkg/exec"
@@ -41,7 +42,7 @@ func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Te
 		accountValidator: fakeAccountValidator{},
 		linter:           fakeMockLinter,
 		helm:             tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
-		kubectl:          tool.NewKubectl(procExec),
+		kubectl:          tool.NewKubectl(procExec, 30*time.Second),
 	}
 }
 
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 66e4a28..0087192 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -18,6 +18,7 @@ import (
 	"os"
 	"path/filepath"
 	"testing"
+	"time"
 
 	"github.com/spf13/cobra"
 	"github.com/stretchr/testify/assert"
@@ -57,6 +58,7 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
 	require.Equal(t, "default", cfg.Namespace)
 	require.Equal(t, "release", cfg.ReleaseLabel)
 	require.Equal(t, true, cfg.ExcludeDeprecated)
+	require.Equal(t, 120*time.Second, cfg.KubectlTimeout)
 }
 
 func Test_findConfigFile(t *testing.T) {
diff --git a/pkg/config/test_config.json b/pkg/config/test_config.json
index ba5659c..861f8b7 100644
--- a/pkg/config/test_config.json
+++ b/pkg/config/test_config.json
@@ -29,5 +29,6 @@
     "skip-missing-values": true,
     "namespace": "default",
     "release-label": "release",
-    "exclude-deprecated": true
+    "exclude-deprecated": true,
+    "kubectl-timeout": "120s"
 }
diff --git a/pkg/config/test_config.yaml b/pkg/config/test_config.yaml
index 5af7bf9..56f4847 100644
--- a/pkg/config/test_config.yaml
+++ b/pkg/config/test_config.yaml
@@ -25,3 +25,4 @@ skip-missing-values: true
 namespace: default
 release-label: release
 exclude-deprecated: true
+kubectl-timeout: 120s