Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controllers/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ var (
CollectContent = collectContent
CollectReferencedObjects = collectReferencedObjects
PrepareBundleSettersWithResourceInfo = prepareBundleSettersWithResourceInfo
PrepareBundleSettersWithHelmInfo = prepareBundleSettersWithHelmInfo
UndeployStaleResources = undeployStaleResources
GetDeployedGroupVersionKinds = getDeployedGroupVersionKinds
GetSecret = getSecret
Expand Down
4 changes: 3 additions & 1 deletion controllers/handlers_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5794,10 +5794,12 @@ func prepareBundleSettersWithHelmInfo(currentChart *configv1beta1.HelmChart, isU
setters := make([]pullmode.BundleOption, 0)

timeout := getTimeoutValue(currentChart.Options)
skipNamespaceCreation := !getCreateNamespaceHelmValue(currentChart.Options)
setters = append(setters,
pullmode.WithTimeout(&timeout),
pullmode.WithReleaseInfo(currentChart.ReleaseNamespace, currentChart.ReleaseName,
currentChart.RepositoryURL, rInfo.ChartVersion, rInfo.Icon, isUninstall, isLast))
currentChart.RepositoryURL, rInfo.ChartVersion, rInfo.Icon, isUninstall, isLast),
pullmode.WithResourceInfo("", "", "", 0, skipNamespaceCreation, false))

return setters
}
Expand Down
52 changes: 52 additions & 0 deletions controllers/handlers_helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2/textlogger"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
Expand All @@ -54,6 +55,7 @@ import (
"github.com/projectsveltos/addon-controller/pkg/scope"
libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1"
"github.com/projectsveltos/libsveltos/lib/clusterproxy"
"github.com/projectsveltos/libsveltos/lib/pullmode"
)

var _ = Describe("HandlersHelm", func() {
Expand Down Expand Up @@ -3095,6 +3097,56 @@ var _ = Describe("getHelmUpgradeClient Force", func() {
})
})

var _ = Describe("prepareBundleSettersWithHelmInfo", func() {
It("sets SkipNamespaceCreation when createNamespace is false", func() {
currentChart := &configv1beta1.HelmChart{
ReleaseName: randomString(),
ReleaseNamespace: randomString(),
RepositoryURL: randomString(),
Options: &configv1beta1.HelmOptions{
InstallOptions: configv1beta1.HelmInstallOptions{
CreateNamespace: ptr.To(false),
},
},
}
rInfo := &controllers.ReleaseInfo{
ChartVersion: randomString(),
}

setters := controllers.PrepareBundleSettersWithHelmInfo(currentChart, false, true, rInfo)

bundleOptions := &pullmode.BundleOptions{}
for _, setter := range setters {
setter(bundleOptions)
}

Expect(bundleOptions.ReleaseNamespace).To(Equal(currentChart.ReleaseNamespace))
Expect(bundleOptions.ReleaseName).To(Equal(currentChart.ReleaseName))
Expect(bundleOptions.SkipNamespaceCreation).To(BeTrue())
})

It("leaves SkipNamespaceCreation false when createNamespace is not set (default)", func() {
currentChart := &configv1beta1.HelmChart{
ReleaseName: randomString(),
ReleaseNamespace: randomString(),
RepositoryURL: randomString(),
Options: &configv1beta1.HelmOptions{},
}
rInfo := &controllers.ReleaseInfo{
ChartVersion: randomString(),
}

setters := controllers.PrepareBundleSettersWithHelmInfo(currentChart, false, true, rInfo)

bundleOptions := &pullmode.BundleOptions{}
for _, setter := range setters {
setter(bundleOptions)
}

Expect(bundleOptions.SkipNamespaceCreation).To(BeFalse())
})
})

var _ = Describe("locateChartWithTimeout", func() {
It("returns the result once locateFn returns", func() {
expectedPath := randomString()
Expand Down
Loading