From d06070dfebe1d526afe33e676dbc104cd9ac367a Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Tue, 7 Nov 2023 14:24:59 +0100 Subject: [PATCH 1/2] Fix cozy-stack config ls-contexts When the default context has no configuration, it should still be listed with the `cozy-stack config ls-contexts` command. It has a list of registries. --- web/instances/contexts.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/instances/contexts.go b/web/instances/contexts.go index 16b21e4bde9..8a4ebf596b6 100644 --- a/web/instances/contexts.go +++ b/web/instances/contexts.go @@ -33,7 +33,6 @@ func showContext(c echo.Context) error { func lsContexts(c echo.Context) error { contexts := config.GetConfig().Contexts - result := []contextAPI{} for contextName, ctx := range contexts { cfg, ok := ctx.(map[string]interface{}) @@ -42,6 +41,11 @@ func lsContexts(c echo.Context) error { } result = append(result, getContextAPI(contextName, cfg)) } + for contextName := range config.GetConfig().Registries { + if _, ok := contexts[contextName]; !ok { + result = append(result, getContextAPI(contextName, nil)) + } + } return c.JSON(http.StatusOK, result) } From 5339a77a56422627b2d7d6d922d5f7946f72d435 Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Tue, 7 Nov 2023 14:33:23 +0100 Subject: [PATCH 2/2] Fix cozy-stack config show-context default command --- web/instances/contexts.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/instances/contexts.go b/web/instances/contexts.go index 8a4ebf596b6..fd0bf02c3a3 100644 --- a/web/instances/contexts.go +++ b/web/instances/contexts.go @@ -26,7 +26,11 @@ func showContext(c echo.Context) error { contexts := config.GetConfig().Contexts cfg, ok := contexts[contextName].(map[string]interface{}) if !ok { - return c.NoContent(http.StatusNotFound) + registries := config.GetConfig().Registries + _, ok := registries[contextName] + if !ok { + return c.NoContent(http.StatusNotFound) + } } return c.JSON(http.StatusOK, getContextAPI(contextName, cfg)) }