Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Implement packages installation APIs for cluster essential
Browse files Browse the repository at this point in the history
Signed-off-by: Vandana Pathak <[email protected]>
  • Loading branch information
Vandana Pathak committed May 4, 2023
1 parent 3342f79 commit 5c29595
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cluster-essentials/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/cppforlife/go-cli-ui v0.0.0-20200716203538-1e47f820817f
github.com/k14s/kbld v0.32.0
github.com/otiai10/copy v1.0.2
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.0
github.com/vmware-tanzu/carvel-imgpkg v0.23.1
github.com/vmware-tanzu/carvel-ytt v0.40.0
Expand Down Expand Up @@ -69,6 +68,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2-0.20210730191737-8e42a01fb1b7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
Expand Down
10 changes: 5 additions & 5 deletions cluster-essentials/pkg/client/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

var downloadBundles = downloadBundle
var applyResourcesFromManifests = applyResourcesFromManifest
var createClientSet = createClientset
var createClientConfig = createClientconfig

const defaultBundleDir = "/tmp"
const defaultTimeout = 15 * time.Minute
Expand All @@ -30,12 +30,12 @@ const versionAnnotation = "runtime.tanzu.vmware.com/cluster-essential-vesion"

var clusterEssentialPackages = []string{"kapp-controller", "secretgen-controller"}

func createClientset(restConfig *rest.Config) (c client.Client, err error) {
clientSet, err := client.New(restConfig, client.Options{})
func createClientconfig(restConfig *rest.Config) (c client.Client, err error) {
clientConfig, err := client.New(restConfig, client.Options{})
if err != nil {
return nil, err
}
return clientSet, nil
return clientConfig, nil
}

func validatePreInstall(ctx context.Context, clientset client.Client, upgradeVersion string) error {
Expand Down Expand Up @@ -127,7 +127,7 @@ func Install(ctx context.Context, config *rest.Config, clusterEssentialRepo, clu
return fmt.Errorf("unable to download cluster essential manifest: %w", err)
}

clientSet, err := createClientSet(config)
clientSet, err := createClientConfig(config)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cluster-essentials/pkg/client/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ func Test_Install(t *testing.T) {
})
t.Run("fails when unable to process downloaded cluster essential bundle ", func(t *testing.T) {
downloadBundles = downloadCorruptedBundleSuccess
createClientSet = createMockClientSet
createClientConfig = createMockClientSet
err := Install(ctx, config, clusterEssentialRepo, clusterEssentialVersion, 0)
require.Error(t, err)
require.ErrorContains(t, err, "unable to process carvel package")
})
t.Run("fails when unable to load kubeconfig ", func(t *testing.T) {
downloadBundles = downloadBundleSuccess
createClientSet = createMockClientSet
createClientConfig = createMockClientSet
err := Install(ctx, config, clusterEssentialRepo, clusterEssentialVersion, 0)
require.Error(t, err)
require.ErrorContains(t, err, "failed to load kubeconfig")
})
t.Run("succeeds when API successfully able to install cluster essential packages", func(t *testing.T) {
downloadBundles = downloadBundleSuccess
applyResourcesFromManifests = applyResourcesFromManifestSuccess
createClientSet = createMockClientSet
createClientConfig = createMockClientSet
err := Install(ctx, config, clusterEssentialRepo, clusterEssentialVersion, 0)
require.NoError(t, err)
})
Expand Down

0 comments on commit 5c29595

Please sign in to comment.