Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): Provide base domain as Plugin value #574

Merged
merged 3 commits into from
Sep 18, 2024
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
5 changes: 4 additions & 1 deletion pkg/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

greenhousesapv1alpha1 "github.com/cloudoperators/greenhouse/pkg/apis/greenhouse/v1alpha1"
"github.com/cloudoperators/greenhouse/pkg/common"
"github.com/cloudoperators/greenhouse/pkg/helm"
"github.com/cloudoperators/greenhouse/pkg/test"
)
Expand Down Expand Up @@ -70,7 +71,9 @@ var _ = Describe("helm package test", func() {
Expect(pluginOptionValues).To(
ContainElement(greenhousesapv1alpha1.PluginOptionValue{Name: "global.greenhouse.clusterName", Value: test.MustReturnJSONFor(plugin.Spec.ClusterName), ValueFrom: nil}), "the pluginDefinition option values should contain the clusterName from the plugin")
Expect(pluginOptionValues).To(
ContainElement(greenhousesapv1alpha1.PluginOptionValue{Name: "global.greenhouse.organizationName", Value: test.MustReturnJSONFor(plugin.GetNamespace()), ValueFrom: nil}), "the pluginDefinition option values should contain the orgName from the plugin namspace")
ContainElement(greenhousesapv1alpha1.PluginOptionValue{Name: "global.greenhouse.organizationName", Value: test.MustReturnJSONFor(plugin.GetNamespace()), ValueFrom: nil}), "the pluginDefinition option values should contain the orgName from the plugin namespace")
Expect(pluginOptionValues).To(
ContainElement(greenhousesapv1alpha1.PluginOptionValue{Name: "global.greenhouse.baseDomain", Value: test.MustReturnJSONFor(common.DNSDomain), ValueFrom: nil}), "the pluginDefinition option values should contain the baseDomain")
})
})

Expand Down
12 changes: 12 additions & 0 deletions pkg/helm/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

greenhousev1alpha1 "github.com/cloudoperators/greenhouse/pkg/apis/greenhouse/v1alpha1"
"github.com/cloudoperators/greenhouse/pkg/common"
)

func GetPluginOptionValuesForPlugin(ctx context.Context, c client.Client, plugin *greenhousev1alpha1.Plugin) ([]greenhousev1alpha1.PluginOptionValue, error) {
Expand Down Expand Up @@ -139,6 +140,17 @@ func getGreenhouseValues(ctx context.Context, c client.Client, p greenhousev1alp
Value: &apiextensionsv1.JSON{Raw: clusterNameVal},
ValueFrom: nil,
})

// append DNSDomain
baseDomainVal, err := json.Marshal(common.DNSDomain)
if err != nil {
return nil, err
}
greenhouseValues = append(greenhouseValues, greenhousev1alpha1.PluginOptionValue{
Name: "global.greenhouse.baseDomain",
Value: &apiextensionsv1.JSON{Raw: baseDomainVal},
ValueFrom: nil,
})
}
return greenhouseValues, nil
}
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/plugin_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ var _ = Describe("PluginLifecycle", Ordered, func() {
err = test.K8sClient.Get(ctx, namespacedName, testPlugin)
Expect(err).NotTo(HaveOccurred())
testPlugin = &pluginList.Items[0]
testPlugin.Spec.OptionValues[9].Value.Raw = []byte("2")
// TODO: This test must not rely on index value, but on OptionValue.Name
// A helper method to get and set an OptionValue by name should be introduced.
testPlugin.Spec.OptionValues[10].Value.Raw = []byte("2")
err = test.K8sClient.Update(ctx, testPlugin)
Expect(err).NotTo(HaveOccurred())
Eventually(func(g Gomega) bool {
Expand Down
Loading