github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/modules/helm/repo.go (about)

     1  package helm
     2  
     3  import (
     4  	"github.com/stretchr/testify/require"
     5  
     6  	"github.com/gruntwork-io/terratest/modules/testing"
     7  )
     8  
     9  // AddRepo will setup the provided helm repository to the local helm client configuration. This will fail the test if
    10  // there is an error.
    11  func AddRepo(t testing.TestingT, options *Options, repoName string, repoURL string) {
    12  	require.NoError(t, AddRepoE(t, options, repoName, repoURL))
    13  }
    14  
    15  // AddRepoE will setup the provided helm repository to the local helm client configuration.
    16  func AddRepoE(t testing.TestingT, options *Options, repoName string, repoURL string) error {
    17  	// Set required args
    18  	args := []string{"add", repoName, repoURL}
    19  
    20  	// Append helm repo add ExtraArgs if available
    21  	if options.ExtraArgs != nil {
    22  		if repoAddArgs, ok := options.ExtraArgs["repoAdd"]; ok {
    23  			args = append(args, repoAddArgs...)
    24  		}
    25  	}
    26  	_, err := RunHelmCommandAndGetOutputE(t, options, "repo", args...)
    27  	return err
    28  }
    29  
    30  // RemoveRepo will remove the provided helm repository from the local helm client configuration. This will fail the test
    31  // if there is an error.
    32  func RemoveRepo(t testing.TestingT, options *Options, repoName string) {
    33  	require.NoError(t, RemoveRepoE(t, options, repoName))
    34  }
    35  
    36  // RemoveRepoE will remove the provided helm repository from the local helm client configuration.
    37  func RemoveRepoE(t testing.TestingT, options *Options, repoName string) error {
    38  	_, err := RunHelmCommandAndGetOutputE(t, options, "repo", "remove", repoName)
    39  	return err
    40  }