Documentation ¶
Overview ¶
Package test contains helper functions for tests related to helm.
Index ¶
- Constants
- Variables
- func AssertContainsExactly[T comparable](t *testing.T, prefixMsg string, actual []T, expected []T)
- func CheckConfigMap(t *testing.T, ctx context.Context, client ctrlruntimeclient.Client, ...)
- func CopyDir(source string, destination string) error
- func CreateNamespaceWithCleanup(t *testing.T, ctx context.Context, client ctrlruntimeclient.Client) *corev1.Namespace
- func PackageChart(t *testing.T, chartDir string, destDir string) (string, int64)
- func StartHttpRegistryWithAuthAndCleanup(t *testing.T, glob string) string
- func StartHttpRegistryWithCleanup(t *testing.T, glob string) string
- func StartOciRegistry(t *testing.T, glob string) string
- func StartOciRegistryWithAuth(t *testing.T, glob string) (string, string)
- func StartTestEnvWithCleanup(t *testing.T, crdPath string) (context.Context, ctrlruntimeclient.Client, string)
- type PKI
- func StartHttpsRegistryWithAuthAndCleanup(t *testing.T, glob string) (string, *PKI)
- func StartHttpsRegistryWithCleanup(t *testing.T, glob string) (string, *PKI)
- func StartSecureOciRegistry(t *testing.T, glob string) (string, *PKI)
- func StartSecureOciRegistryWithAuth(t *testing.T, glob string) (string, string, *PKI)
- type ReleaseStorageInfo
Constants ¶
const ( // ConfigmapName is the Name of the config map deployed by the examplechart and examplechart-v2. ConfigmapName = "testcm" // ConfigmapName2 is the Name of the config map deployed by the examplechart and examplechart2. ConfigmapName2 = "testcm-2" // CmDataKey is the key in the values.yaml of examplechart / examplechart-v2 that holds custom configmap data. CmDataKey = "cmData" // VersionLabelKey is the key in the values.yaml of examplechart / examplechart-v2 that holds custom version label value. it's also the name of the label in the configmap. VersionLabelKey = "versionLabel" // DefaultVersionLabel is the default value of the version label the configmap deployed by pkg/applications/helmclient/testdata/examplechart chart. DefaultVersionLabel = "1.0" // DefaultVersionLabelV2 is the default value of the version label the configmap deployed by pkg/applications/helmclient/testdata/examplechart-v2 chart. DefaultVersionLabelV2 = "2.0" // EnableDNSLabelKey is the label key on cmData examplechart that allow test the enableDns deployOption. EnableDNSLabelKey = "enableDNSLabel" // SvcName is the name of the service deployed by chart chart-with-lb. SvcName = "svc-1" // DeploySvcKey is the key values.yaml of examplechart-v2 to enable / disabled the deployment of the service. DeploySvcKey = "deployService" )
Const relative to pkg/applications/helmclient/testdata/examplechart chart.
Variables ¶
var ( // DefaultData contains the default data of the configmap deployed by pkg/applications/helmclient/testdata/examplechart chart. DefaultData = map[string]string{"foo": "bar"} // DefaultDataV2 contains the default data of the configmap deployed by pkg/applications/helmclient/testdata/examplechart-v2 chart. DefaultDataV2 = map[string]string{"foo-version-2": "bar-version-2"} )
Functions ¶
func AssertContainsExactly ¶
func AssertContainsExactly[T comparable](t *testing.T, prefixMsg string, actual []T, expected []T)
AssertContainsExactly failed the test if the actual slice does not contain exactly the element of the expected slice.
func CheckConfigMap ¶ added in v2.22.0
func CheckConfigMap(t *testing.T, ctx context.Context, client ctrlruntimeclient.Client, ns *corev1.Namespace, expectedData map[string]string, expectedVersionLabel string, enableDns bool)
CheckConfigMap asserts that configMap deployed by helm chart has been created/ updated with the desired data and labels.
func CreateNamespaceWithCleanup ¶ added in v2.22.0
func CreateNamespaceWithCleanup(t *testing.T, ctx context.Context, client ctrlruntimeclient.Client) *corev1.Namespace
CreateNamespaceWithCleanup creates a namespace with a generated name test-<something> and registers a hook on T.Cleanup that removes it at the end of the test.
func PackageChart ¶ added in v2.22.0
PackageChart packages the chart in chartDir into a chart archive file (i.e. a tgz) in destDir directory and returns the full path and the size of the archive.
func StartHttpRegistryWithAuthAndCleanup ¶ added in v2.22.0
StartHttpRegistryWithAuthAndCleanup starts a Helm http registry with basic auth enabled and uploads charts archives matching glob and returns the registry URL. the basic auth is hardcoded to Username: "username", Password: "password".
func StartHttpRegistryWithCleanup ¶ added in v2.22.0
StartHttpRegistryWithCleanup starts a Helm http registry and uploads charts archives matching glob and returns the registry URL.
func StartOciRegistry ¶ added in v2.22.0
StartOciRegistry start an oci registry and uploads charts archives matching glob and returns the registry URL.
func StartOciRegistryWithAuth ¶ added in v2.22.0
StartOciRegistryWithAuth start an oci registry with authentication, uploads charts archives matching glob, returns the registry URL and registryConfigFile. registryConfigFile contains the credentials of the registry.
func StartTestEnvWithCleanup ¶ added in v2.22.0
func StartTestEnvWithCleanup(t *testing.T, crdPath string) (context.Context, ctrlruntimeclient.Client, string)
StartTestEnvWithCleanup bootstraps the testing environment and return the to the kubeconfig. It also registers a hook on T.Cleanup to stop the env and remove the kubeconfig.
Types ¶
type PKI ¶ added in v2.26.0
func StartHttpsRegistryWithAuthAndCleanup ¶ added in v2.26.0
StartHttpsRegistryWithAuthAndCleanup is the same as StartHttpRegistryWithAuthAndCleanup, but starts a TLS server instead. Any package calling this must provide a "testdata" directory with the Helm test PKI.
func StartHttpsRegistryWithCleanup ¶ added in v2.26.0
StartHttpsRegistryWithCleanup is the same as StartHttpRegistryWithCleanup, but starts a TLS server instead. Any package calling this must provide a "testdata" directory with the Helm test PKI.
func StartSecureOciRegistry ¶ added in v2.26.0
StartSecureOciRegistry start an oci registry and uploads charts archives matching glob and returns the registry URL and the generated PKI.
func StartSecureOciRegistryWithAuth ¶ added in v2.26.0
StartOciRegistryWithAuth start an oci registry with authentication, uploads charts archives matching glob, returns the registry URL and registryConfigFile. registryConfigFile contains the credentials of the registry.
type ReleaseStorageInfo ¶
type ReleaseStorageInfo struct { // Name of the secret containing release information. Name string // Version of the release. Version string }
ReleaseStorageInfo holds information about the secret storing the Helm release information.
func MapToReleaseStorageInfo ¶
func MapToReleaseStorageInfo(secrets []corev1.Secret) []ReleaseStorageInfo
MapToReleaseStorageInfo maps the secrets containing the Helm release information to a smaller struct only containing the Name of the secret and the release version.