mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 20:17:04 +00:00
fix disable addon check several bugs (#3488)
Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com>
This commit is contained in:
+3
-3
@@ -197,15 +197,15 @@ func findLegacyAddonDefs(ctx context.Context, k8sClient client.Client, addonName
|
||||
}
|
||||
|
||||
func usingAppsInfo(apps []v1beta1.Application) string {
|
||||
res := "application: "
|
||||
res := "addon is being used :"
|
||||
appsNamespaceNameList := map[string][]string{}
|
||||
for _, app := range apps {
|
||||
appsNamespaceNameList[app.GetNamespace()] = append(appsNamespaceNameList[app.GetNamespace()], app.GetName())
|
||||
}
|
||||
for namespace, appNames := range appsNamespaceNameList {
|
||||
nameStr := strings.Join(appNames, ",")
|
||||
res += fmt.Sprintf("(%s) in namespace:%s,", nameStr, namespace)
|
||||
res += fmt.Sprintf("{%s} in namespace:%s,", nameStr, namespace)
|
||||
}
|
||||
res = strings.TrimSuffix(res, ",") + " are still using this addon"
|
||||
res = strings.TrimSuffix(res, ",") + ".Please delete them before disabling the addon."
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ func TestUsingAddonInfo(t *testing.T) {
|
||||
v1beta1.Application{ObjectMeta: metav1.ObjectMeta{Namespace: "namespace-1", Name: "app-3"}},
|
||||
}
|
||||
res := usingAppsInfo(apps)
|
||||
assert.Equal(t, true, strings.Contains(res, "still using this addon"))
|
||||
assert.Equal(t, true, strings.Contains(res, "Please delete them before disabling the addon"))
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -101,6 +101,7 @@ func (s *addonWebService) GetWebService() *restful.WebService {
|
||||
Returns(200, "OK", apis.AddonStatusResponse{}).
|
||||
Returns(400, "Bad Request", bcode.Bcode{}).
|
||||
Param(ws.PathParameter("name", "addon name to enable").DataType("string").Required(true)).
|
||||
Param(ws.QueryParameter("force", "force disable an anddon").DataType("bool").Required(false)).
|
||||
Writes(apis.AddonStatusResponse{}))
|
||||
|
||||
// update addon
|
||||
|
||||
Reference in New Issue
Block a user