From 11ee2c2625a6ed5dea0e5a71dba97c11d9c87893 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Watenberg Date: Wed, 24 Jun 2026 17:31:03 +0200 Subject: [PATCH 1/2] feat(scalityui): expose Guardian shell-ui config (canUseGuardian, guardianOrigin) shell-ui's ShellJSONFileConfig recently gained two Guardian fields that the ScalityUI CR did not expose, so they could never be set in the generated config.json: - canUseGuardian: feature flag for the embedded Guardian AI assistant - guardianOrigin: origin URL used as the assistant iframe src and postMessage target Add both to the existing UIConfig block and emit them in createConfigJSON. guardianOrigin is only emitted when set so shell-ui keeps its own default-origin fallback; canUseGuardian defaults to false. Co-Authored-By: Claude Opus 4.8 (1M context) --- api/v1alpha1/scalityui_types.go | 10 ++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/ui.scality.com_scalityuis.yaml | 12 ++++++++++++ internal/controller/scalityui/controller.go | 7 +++++++ internal/controller/scalityui/controller_test.go | 6 ++++++ 5 files changed, 40 insertions(+) diff --git a/api/v1alpha1/scalityui_types.go b/api/v1alpha1/scalityui_types.go index cc6508d..00e47dd 100644 --- a/api/v1alpha1/scalityui_types.go +++ b/api/v1alpha1/scalityui_types.go @@ -197,6 +197,16 @@ type UIConfig struct { // +kubebuilder:default=false CanChangeTheme *bool `json:"canChangeTheme,omitempty"` + // CanUseGuardian controls whether the embedded Guardian AI assistant is + // available in the UI. It only takes effect when GuardianOrigin is also set. + // +kubebuilder:default=false + CanUseGuardian *bool `json:"canUseGuardian,omitempty"` + + // GuardianOrigin is the origin (scheme + host + port, no path or query) of + // the embedded Guardian AI assistant. It is used as the iframe src and as + // the postMessage target origin. + GuardianOrigin string `json:"guardianOrigin,omitempty"` + // Favicon specifies the favicon for the UI // +kubebuilder:default="/favicon.ico" Favicon string `json:"favicon,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 6b21f15..3ebea3a 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -626,6 +626,11 @@ func (in *UIConfig) DeepCopyInto(out *UIConfig) { *out = new(bool) **out = **in } + if in.CanUseGuardian != nil { + in, out := &in.CanUseGuardian, &out.CanUseGuardian + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UIConfig. diff --git a/config/crd/bases/ui.scality.com_scalityuis.yaml b/config/crd/bases/ui.scality.com_scalityuis.yaml index 09711ac..5f13398 100644 --- a/config/crd/bases/ui.scality.com_scalityuis.yaml +++ b/config/crd/bases/ui.scality.com_scalityuis.yaml @@ -1396,10 +1396,22 @@ spec: description: CanChangeTheme controls whether users can change the UI theme type: boolean + canUseGuardian: + default: false + description: |- + CanUseGuardian controls whether the embedded Guardian AI assistant is + available in the UI. It only takes effect when GuardianOrigin is also set. + type: boolean favicon: default: /favicon.ico description: Favicon specifies the favicon for the UI type: string + guardianOrigin: + description: |- + GuardianOrigin is the origin (scheme + host + port, no path or query) of + the embedded Guardian AI assistant. It is used as the iframe src and as + the postMessage target origin. + type: string type: object required: - image diff --git a/internal/controller/scalityui/controller.go b/internal/controller/scalityui/controller.go index 82cf6d7..5f9d6b7 100644 --- a/internal/controller/scalityui/controller.go +++ b/internal/controller/scalityui/controller.go @@ -51,11 +51,18 @@ func createConfigJSON(scalityui *uiscalitycomv1alpha1.ScalityUI) ([]byte, error) configOutput["canChangeInstanceName"] = scalityui.Spec.UIConfig.CanChangeInstanceName configOutput["canChangeLanguage"] = scalityui.Spec.UIConfig.CanChangeLanguage configOutput["canChangeTheme"] = scalityui.Spec.UIConfig.CanChangeTheme + configOutput["canUseGuardian"] = scalityui.Spec.UIConfig.CanUseGuardian configOutput["favicon"] = scalityui.Spec.UIConfig.Favicon + // Only emit guardianOrigin when set; shell-ui falls back to its own + // default origin otherwise. + if scalityui.Spec.UIConfig.GuardianOrigin != "" { + configOutput["guardianOrigin"] = scalityui.Spec.UIConfig.GuardianOrigin + } } else { configOutput["canChangeInstanceName"] = false configOutput["canChangeLanguage"] = false configOutput["canChangeTheme"] = false + configOutput["canUseGuardian"] = false configOutput["favicon"] = "/favicon.ico" } diff --git a/internal/controller/scalityui/controller_test.go b/internal/controller/scalityui/controller_test.go index a713fa2..e38116e 100644 --- a/internal/controller/scalityui/controller_test.go +++ b/internal/controller/scalityui/controller_test.go @@ -961,6 +961,8 @@ var _ = Describe("ScalityUI Shell Features", func() { Expect(config["canChangeTheme"]).To(Equal(false)) Expect(config["canChangeInstanceName"]).To(Equal(false)) Expect(config["canChangeLanguage"]).To(Equal(false)) + Expect(config["canUseGuardian"]).To(Equal(false)) + Expect(config).NotTo(HaveKey("guardianOrigin")) Expect(config["favicon"]).To(Equal("/favicon.ico")) Expect(lightTheme["type"]).To(Equal("core-ui")) @@ -1008,6 +1010,8 @@ var _ = Describe("ScalityUI Shell Features", func() { CanChangeTheme: &[]bool{true}[0], CanChangeInstanceName: &[]bool{true}[0], CanChangeLanguage: &[]bool{true}[0], + CanUseGuardian: &[]bool{true}[0], + GuardianOrigin: "https://guardian.example.com", Favicon: "/custom/favicon.ico", } @@ -1033,6 +1037,8 @@ var _ = Describe("ScalityUI Shell Features", func() { Expect(config["canChangeTheme"]).To(Equal(true)) Expect(config["canChangeInstanceName"]).To(Equal(true)) Expect(config["canChangeLanguage"]).To(Equal(true)) + Expect(config["canUseGuardian"]).To(Equal(true)) + Expect(config["guardianOrigin"]).To(Equal("https://guardian.example.com")) Expect(config["favicon"]).To(Equal("/custom/favicon.ico")) By("Verifying custom navigation structure") From 685bec1871d1b64e339b68728fac72ac6baa230f Mon Sep 17 00:00:00 2001 From: JBWatenbergScality <75977494+JBWatenbergScality@users.noreply.github.com> Date: Wed, 24 Jun 2026 17:46:38 +0200 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- internal/controller/scalityui/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/controller/scalityui/controller.go b/internal/controller/scalityui/controller.go index 5f9d6b7..742f45d 100644 --- a/internal/controller/scalityui/controller.go +++ b/internal/controller/scalityui/controller.go @@ -51,7 +51,7 @@ func createConfigJSON(scalityui *uiscalitycomv1alpha1.ScalityUI) ([]byte, error) configOutput["canChangeInstanceName"] = scalityui.Spec.UIConfig.CanChangeInstanceName configOutput["canChangeLanguage"] = scalityui.Spec.UIConfig.CanChangeLanguage configOutput["canChangeTheme"] = scalityui.Spec.UIConfig.CanChangeTheme - configOutput["canUseGuardian"] = scalityui.Spec.UIConfig.CanUseGuardian + configOutput["canUseGuardian"] = scalityui.Spec.UIConfig.CanUseGuardian != nil && *scalityui.Spec.UIConfig.CanUseGuardian configOutput["favicon"] = scalityui.Spec.UIConfig.Favicon // Only emit guardianOrigin when set; shell-ui falls back to its own // default origin otherwise.