From 28858f695f511886f6d4fcbcf62bbb1dcaf25251 Mon Sep 17 00:00:00 2001 From: Andrei Aaron Date: Sat, 26 Aug 2023 23:32:41 +0300 Subject: [PATCH] feat(mgmt): mgmt extention no longer depends on UI being enabled (#1728) It is now enabled based only on search configuration Signed-off-by: Andrei Aaron --- pkg/api/config/config.go | 2 +- pkg/api/controller_test.go | 4 ++-- pkg/cli/extensions_test.go | 7 ++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/api/config/config.go b/pkg/api/config/config.go index 7680877a..acf9925d 100644 --- a/pkg/api/config/config.go +++ b/pkg/api/config/config.go @@ -326,7 +326,7 @@ func (c *Config) AreUserPrefsEnabled() bool { } func (c *Config) IsMgmtEnabled() bool { - return c.IsSearchEnabled() && c.IsUIEnabled() + return c.IsSearchEnabled() } func (c *Config) IsImageTrustEnabled() bool { diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 0f5245ba..341c13e7 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -8538,17 +8538,17 @@ func TestDistSpecExtensions(t *testing.T) { So(err, ShouldBeNil) t.Log(extensionList.Extensions) So(len(extensionList.Extensions), ShouldEqual, 1) - So(len(extensionList.Extensions[0].Endpoints), ShouldEqual, 1) + So(len(extensionList.Extensions[0].Endpoints), ShouldEqual, 2) So(extensionList.Extensions[0].Name, ShouldEqual, "_zot") So(extensionList.Extensions[0].URL, ShouldContainSubstring, "_zot.md") So(extensionList.Extensions[0].Description, ShouldNotBeEmpty) // Verify the endpoints below are enabled by search So(extensionList.Extensions[0].Endpoints, ShouldContain, constants.FullSearchPrefix) + So(extensionList.Extensions[0].Endpoints, ShouldContain, constants.FullMgmt) // Verify the endpoints below are not enabled since trust is not enabled So(extensionList.Extensions[0].Endpoints, ShouldNotContain, constants.FullCosign) So(extensionList.Extensions[0].Endpoints, ShouldNotContain, constants.FullNotation) // Verify the endpoints below are not enabled since the UI is not enabled - So(extensionList.Extensions[0].Endpoints, ShouldNotContain, constants.FullMgmt) So(extensionList.Extensions[0].Endpoints, ShouldNotContain, constants.FullUserPrefs) }) diff --git a/pkg/cli/extensions_test.go b/pkg/cli/extensions_test.go index eeb7abfc..249d7c65 100644 --- a/pkg/cli/extensions_test.go +++ b/pkg/cli/extensions_test.go @@ -813,9 +813,6 @@ func TestServeMgmtExtension(t *testing.T) { "output": "%s" }, "extensions": { - "ui": { - "enable": true - }, "search": { "enable": true } @@ -837,7 +834,7 @@ func TestServeMgmtExtension(t *testing.T) { So(found, ShouldBeTrue) }) - Convey("Mgmt disabled - UI unconfigured", t, func(c C) { + Convey("Mgmt disabled - search unconfigured", t, func(c C) { content := `{ "storage": { "rootDirectory": "%s" @@ -852,7 +849,7 @@ func TestServeMgmtExtension(t *testing.T) { }, "extensions": { "search": { - "enable": true + "enable": false } } }`