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