mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
Fix: add registryName into addon list (#2993)
* Fix: add registryName into addon list Signed-off-by: wangyike <wangyike_wyk@163.com> * fix congig map Signed-off-by: wangyike <wangyike_wyk@163.com> * fix several comments Signed-off-by: wangyike <wangyike_wyk@163.com> * small fix Signed-off-by: wangyike <wangyike_wyk@163.com>
This commit is contained in:
+2
-1
@@ -188,7 +188,7 @@ func GetPatternFromItem(it Item, r AsyncReader, rootPath string) string {
|
||||
}
|
||||
|
||||
// ListAddonUIDataFromReader list addons from AsyncReader
|
||||
func ListAddonUIDataFromReader(r AsyncReader, registryMeta map[string]SourceMeta, opt ListOptions) ([]*UIData, error) {
|
||||
func ListAddonUIDataFromReader(r AsyncReader, registryMeta map[string]SourceMeta, registryName string, opt ListOptions) ([]*UIData, error) {
|
||||
var addons []*UIData
|
||||
var err error
|
||||
var wg sync.WaitGroup
|
||||
@@ -206,6 +206,7 @@ func ListAddonUIDataFromReader(r AsyncReader, registryMeta map[string]SourceMeta
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
addonRes.RegistryName = registryName
|
||||
l.Lock()
|
||||
addons = append(addons, addonRes)
|
||||
l.Unlock()
|
||||
|
||||
@@ -123,7 +123,7 @@ func testReaderFunc(t *testing.T, reader AsyncReader) {
|
||||
assert.True(t, len(uiData.Definitions) > 0)
|
||||
|
||||
// test get ui data
|
||||
uiDataList, err := ListAddonUIDataFromReader(reader, registryMeta, UIMetaOptions)
|
||||
uiDataList, err := ListAddonUIDataFromReader(reader, registryMeta, "KubeVela", UIMetaOptions)
|
||||
assert.True(t, strings.Contains(err.Error(), "#parameter.example: preference mark not allowed at this position"))
|
||||
assert.Equal(t, len(uiDataList), 3)
|
||||
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ func (r *Registry) ListUIData(registryAddonMeta map[string]SourceMeta, opt ListO
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ListAddonUIDataFromReader(reader, registryAddonMeta, opt)
|
||||
return ListAddonUIDataFromReader(reader, registryAddonMeta, r.Name, opt)
|
||||
}
|
||||
|
||||
// GetInstallPackage get install package which is all needed to enable an addon from addon registry
|
||||
|
||||
@@ -36,6 +36,7 @@ type UIData struct {
|
||||
Definitions []ElementFile `json:"definitions"`
|
||||
CUEDefinitions []ElementFile `json:"CUEDefinitions"`
|
||||
Parameters string `json:"parameters"`
|
||||
RegistryName string `json:"registryName"`
|
||||
}
|
||||
|
||||
// InstallPackage contains all necessary files that can be installed for an addon
|
||||
|
||||
@@ -101,12 +101,18 @@ type EnableAddonRequest struct {
|
||||
|
||||
// ListAddonResponse defines the format for addon list response
|
||||
type ListAddonResponse struct {
|
||||
Addons []*addon.Meta `json:"addons"`
|
||||
Addons []*AddonInfo `json:"addons"`
|
||||
|
||||
// Message demonstrate the error info if exists
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// AddonInfo contain addon metaData and some baseInfo
|
||||
type AddonInfo struct {
|
||||
*addon.Meta
|
||||
RegistryName string `json:"registryName"`
|
||||
}
|
||||
|
||||
// ListEnabledAddonResponse defines the format for enabled addon list response
|
||||
type ListEnabledAddonResponse struct {
|
||||
EnabledAddons []*AddonBaseStatus `json:"enabledAddons"`
|
||||
@@ -126,8 +132,9 @@ type DetailAddonResponse struct {
|
||||
UISchema []*utils.UIParameter `json:"uiSchema"`
|
||||
|
||||
// More details about the addon, e.g. README
|
||||
Detail string `json:"detail,omitempty"`
|
||||
Definitions []*AddonDefinition `json:"definitions"`
|
||||
Detail string `json:"detail,omitempty"`
|
||||
Definitions []*AddonDefinition `json:"definitions"`
|
||||
RegistryName string `json:"registryName,omitempty"`
|
||||
}
|
||||
|
||||
// AddonDefinition is definition an addon can provide
|
||||
|
||||
@@ -78,11 +78,12 @@ func AddonImpl2AddonRes(impl *pkgaddon.UIData) (*apis.DetailAddonResponse, error
|
||||
})
|
||||
}
|
||||
return &apis.DetailAddonResponse{
|
||||
Meta: impl.Meta,
|
||||
APISchema: impl.APISchema,
|
||||
UISchema: impl.UISchema,
|
||||
Detail: impl.Detail,
|
||||
Definitions: defs,
|
||||
Meta: impl.Meta,
|
||||
APISchema: impl.APISchema,
|
||||
UISchema: impl.UISchema,
|
||||
Detail: impl.Detail,
|
||||
Definitions: defs,
|
||||
RegistryName: impl.RegistryName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
|
||||
pkgaddon "github.com/oam-dev/kubevela/pkg/addon"
|
||||
apis "github.com/oam-dev/kubevela/pkg/apiserver/rest/apis/v1"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/rest/usecase"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/rest/utils/bcode"
|
||||
@@ -122,10 +121,10 @@ func (s *addonWebService) listAddons(req *restful.Request, res *restful.Response
|
||||
return
|
||||
}
|
||||
|
||||
var addons []*pkgaddon.Meta
|
||||
var addons []*apis.AddonInfo
|
||||
|
||||
for _, d := range detailAddons {
|
||||
addons = append(addons, &d.Meta)
|
||||
addons = append(addons, &apis.AddonInfo{Meta: &d.Meta, RegistryName: d.RegistryName})
|
||||
}
|
||||
|
||||
var message string
|
||||
|
||||
@@ -294,7 +294,7 @@ func statusAddon(name string, ioStreams cmdutil.IOStreams, cmd *cobra.Command, c
|
||||
}
|
||||
fmt.Printf("addon %s status is %s \n", name, status.AddonPhase)
|
||||
if status.AddonPhase != statusEnabled && status.AddonPhase != statusDisabled {
|
||||
fmt.Printf("diagnose addon info from realted application %s ", pkgaddon.Convert2AppName(name))
|
||||
fmt.Printf("diagnose addon info from application %s", pkgaddon.Convert2AppName(name))
|
||||
err := printAppStatus(context.Background(), clt, ioStreams, pkgaddon.Convert2AppName(name), types.DefaultKubeVelaNS, cmd, c)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -329,14 +329,14 @@ func listAddons(ctx context.Context, registry string) error {
|
||||
}
|
||||
|
||||
table := uitable.New()
|
||||
table.AddRow("NAME", "DESCRIPTION", "STATUS")
|
||||
table.AddRow("NAME", "REGISTRY", "DESCRIPTION", "STATUS")
|
||||
|
||||
for _, addon := range addons {
|
||||
status, err := pkgaddon.GetAddonStatus(ctx, clt, addon.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
table.AddRow(addon.Name, addon.Description, status.AddonPhase)
|
||||
table.AddRow(addon.Name, addon.RegistryName, addon.Description, status.AddonPhase)
|
||||
}
|
||||
fmt.Println(table.String())
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user