gitlab.azmi.pl/azmi-open-source/helm@v3.0.0-beta.3+incompatible/cmd/helm/release_testing_run.go (about)

     1  /*
     2  Copyright The Helm Authors.
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6  
     7  http://www.apache.org/licenses/LICENSE-2.0
     8  
     9  Unless required by applicable law or agreed to in writing, software
    10  distributed under the License is distributed on an "AS IS" BASIS,
    11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  See the License for the specific language governing permissions and
    13  limitations under the License.
    14  */
    15  
    16  package main
    17  
    18  import (
    19  	"io"
    20  	"time"
    21  
    22  	"github.com/spf13/cobra"
    23  
    24  	"helm.sh/helm/cmd/helm/require"
    25  	"helm.sh/helm/pkg/action"
    26  )
    27  
    28  const releaseTestRunHelp = `
    29  The test command runs the tests for a release.
    30  
    31  The argument this command takes is the name of a deployed release.
    32  The tests to be run are defined in the chart that was installed.
    33  `
    34  
    35  func newReleaseTestRunCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
    36  	client := action.NewReleaseTesting(cfg)
    37  
    38  	cmd := &cobra.Command{
    39  		Use:   "run [RELEASE]",
    40  		Short: "run tests for a release",
    41  		Long:  releaseTestRunHelp,
    42  		Args:  require.ExactArgs(1),
    43  		RunE: func(cmd *cobra.Command, args []string) error {
    44  			return client.Run(args[0])
    45  		},
    46  	}
    47  
    48  	f := cmd.Flags()
    49  	f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
    50  	f.BoolVar(&client.Cleanup, "cleanup", false, "delete test pods upon completion")
    51  
    52  	return cmd
    53  }