mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 03:56:36 +00:00
Feat: support delete the readonly application (#3492)
Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
+44
-46
@@ -284,6 +284,12 @@
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "force disable an addon",
|
||||
"name": "force",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -6211,8 +6217,8 @@
|
||||
},
|
||||
"v1.AddonStatusResponse": {
|
||||
"required": [
|
||||
"name",
|
||||
"phase",
|
||||
"name",
|
||||
"args"
|
||||
],
|
||||
"properties": {
|
||||
@@ -6359,12 +6365,12 @@
|
||||
},
|
||||
"v1.ApplicationDeployResponse": {
|
||||
"required": [
|
||||
"status",
|
||||
"createTime",
|
||||
"version",
|
||||
"status",
|
||||
"envName",
|
||||
"triggerType",
|
||||
"note"
|
||||
"note",
|
||||
"triggerType"
|
||||
],
|
||||
"properties": {
|
||||
"codeInfo": {
|
||||
@@ -6806,7 +6812,6 @@
|
||||
"componentType",
|
||||
"main",
|
||||
"dependsOn",
|
||||
"deployVersion",
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"traits"
|
||||
@@ -6831,9 +6836,6 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"deployVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -7421,9 +7423,9 @@
|
||||
"v1.DetailAddonResponse": {
|
||||
"required": [
|
||||
"name",
|
||||
"description",
|
||||
"invisible",
|
||||
"version",
|
||||
"description",
|
||||
"icon",
|
||||
"schema",
|
||||
"uiSchema",
|
||||
@@ -7497,16 +7499,15 @@
|
||||
},
|
||||
"v1.DetailApplicationResponse": {
|
||||
"required": [
|
||||
"alias",
|
||||
"project",
|
||||
"name",
|
||||
"description",
|
||||
"icon",
|
||||
"name",
|
||||
"alias",
|
||||
"project",
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"policies",
|
||||
"envBindings",
|
||||
"status",
|
||||
"applicationType",
|
||||
"resourceInfo"
|
||||
],
|
||||
@@ -7557,9 +7558,6 @@
|
||||
"resourceInfo": {
|
||||
"$ref": "#/definitions/v1.ApplicationResourceInfo"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"updateTime": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
@@ -7568,20 +7566,20 @@
|
||||
},
|
||||
"v1.DetailClusterResponse": {
|
||||
"required": [
|
||||
"createTime",
|
||||
"description",
|
||||
"status",
|
||||
"apiServerURL",
|
||||
"updateTime",
|
||||
"alias",
|
||||
"reason",
|
||||
"name",
|
||||
"icon",
|
||||
"labels",
|
||||
"provider",
|
||||
"dashboardURL",
|
||||
"kubeConfig",
|
||||
"name",
|
||||
"status",
|
||||
"description",
|
||||
"icon",
|
||||
"createTime",
|
||||
"alias",
|
||||
"provider",
|
||||
"apiServerURL",
|
||||
"kubeConfigSecret",
|
||||
"updateTime",
|
||||
"labels",
|
||||
"resourceInfo"
|
||||
],
|
||||
"properties": {
|
||||
@@ -7639,14 +7637,14 @@
|
||||
},
|
||||
"v1.DetailComponentResponse": {
|
||||
"required": [
|
||||
"type",
|
||||
"creator",
|
||||
"name",
|
||||
"alias",
|
||||
"type",
|
||||
"createTime",
|
||||
"alias",
|
||||
"updateTime",
|
||||
"appPrimaryKey",
|
||||
"main",
|
||||
"updateTime",
|
||||
"definition"
|
||||
],
|
||||
"properties": {
|
||||
@@ -7748,13 +7746,13 @@
|
||||
},
|
||||
"v1.DetailPolicyResponse": {
|
||||
"required": [
|
||||
"name",
|
||||
"type",
|
||||
"description",
|
||||
"creator",
|
||||
"properties",
|
||||
"createTime",
|
||||
"updateTime"
|
||||
"updateTime",
|
||||
"name",
|
||||
"type",
|
||||
"description"
|
||||
],
|
||||
"properties": {
|
||||
"createTime": {
|
||||
@@ -7784,17 +7782,17 @@
|
||||
},
|
||||
"v1.DetailRevisionResponse": {
|
||||
"required": [
|
||||
"appPrimaryKey",
|
||||
"version",
|
||||
"createTime",
|
||||
"status",
|
||||
"workflowName",
|
||||
"updateTime",
|
||||
"reason",
|
||||
"deployUser",
|
||||
"envName",
|
||||
"appPrimaryKey",
|
||||
"updateTime",
|
||||
"version",
|
||||
"note",
|
||||
"triggerType",
|
||||
"createTime",
|
||||
"envName",
|
||||
"reason"
|
||||
"workflowName"
|
||||
],
|
||||
"properties": {
|
||||
"appPrimaryKey": {
|
||||
@@ -7848,8 +7846,8 @@
|
||||
},
|
||||
"v1.DetailTargetResponse": {
|
||||
"required": [
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"createTime",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
@@ -7887,11 +7885,11 @@
|
||||
},
|
||||
"v1.DetailUserResponse": {
|
||||
"required": [
|
||||
"name",
|
||||
"email",
|
||||
"disabled",
|
||||
"createTime",
|
||||
"lastLoginTime",
|
||||
"name",
|
||||
"projects"
|
||||
],
|
||||
"properties": {
|
||||
@@ -7984,12 +7982,12 @@
|
||||
"required": [
|
||||
"default",
|
||||
"envName",
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"name",
|
||||
"alias",
|
||||
"description",
|
||||
"enable",
|
||||
"createTime"
|
||||
"enable"
|
||||
],
|
||||
"properties": {
|
||||
"alias": {
|
||||
@@ -8672,11 +8670,11 @@
|
||||
},
|
||||
"v1.SystemInfoResponse": {
|
||||
"required": [
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"installID",
|
||||
"enableCollection",
|
||||
"loginType",
|
||||
"createTime",
|
||||
"updateTime",
|
||||
"systemVersion"
|
||||
],
|
||||
"properties": {
|
||||
|
||||
@@ -81,6 +81,14 @@ func (a *Application) GetAppNameForSynced() string {
|
||||
return strings.TrimSuffix(a.Name, "-"+namespace)
|
||||
}
|
||||
|
||||
// GetAppNamespaceForSynced will return the namespace of synced CR
|
||||
func (a *Application) GetAppNamespaceForSynced() string {
|
||||
if a.Labels == nil {
|
||||
return ""
|
||||
}
|
||||
return a.Labels[LabelSyncNamespace]
|
||||
}
|
||||
|
||||
// IsSynced answer if the app is synced one
|
||||
func (a *Application) IsSynced() bool {
|
||||
if a.Labels == nil {
|
||||
|
||||
@@ -570,7 +570,6 @@ type DetailApplicationResponse struct {
|
||||
ApplicationBase
|
||||
Policies []string `json:"policies"`
|
||||
EnvBindings []string `json:"envBindings"`
|
||||
Status string `json:"status"`
|
||||
ApplicationType string `json:"applicationType"`
|
||||
ResourceInfo ApplicationResourceInfo `json:"resourceInfo"`
|
||||
}
|
||||
@@ -592,7 +591,6 @@ type ComponentBase struct {
|
||||
Icon string `json:"icon,omitempty"`
|
||||
DependsOn []string `json:"dependsOn"`
|
||||
Creator string `json:"creator,omitempty"`
|
||||
DeployVersion string `json:"deployVersion"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
Inputs common.StepInputs `json:"inputs,omitempty"`
|
||||
|
||||
@@ -294,8 +294,18 @@ func (c *applicationUsecaseImpl) GetApplicationStatus(ctx context.Context, appmo
|
||||
|
||||
// GetApplicationCR get application CR in cluster
|
||||
func (c *applicationUsecaseImpl) GetApplicationCR(ctx context.Context, appModel *model.Application) (*v1beta1.ApplicationList, error) {
|
||||
|
||||
var apps v1beta1.ApplicationList
|
||||
if appModel.IsSynced() {
|
||||
var app v1beta1.Application
|
||||
err := c.kubeClient.Get(ctx, types.NamespacedName{Namespace: appModel.GetAppNamespaceForSynced(), Name: appModel.GetAppNameForSynced()}, &app)
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
if err == nil {
|
||||
apps.Items = append(apps.Items, app)
|
||||
return &apps, nil
|
||||
}
|
||||
}
|
||||
selector := labels.NewSelector()
|
||||
re, err := labels.NewRequirement(oam.AnnotationAppName, selection.Equals, []string{appModel.GetAppNameForSynced()})
|
||||
if err != nil {
|
||||
@@ -924,12 +934,11 @@ func (c *applicationUsecaseImpl) convertRevisionModelToBase(revision *model.Appl
|
||||
|
||||
// DeleteApplication delete application
|
||||
func (c *applicationUsecaseImpl) DeleteApplication(ctx context.Context, app *model.Application) error {
|
||||
// TODO: check app can be deleted
|
||||
crs, err := c.GetApplicationCR(ctx, app)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(crs.Items) > 0 || app.IsSynced() {
|
||||
if len(crs.Items) > 0 {
|
||||
return bcode.ErrApplicationRefusedDelete
|
||||
}
|
||||
// query all components to deleted
|
||||
|
||||
@@ -101,7 +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)).
|
||||
Param(ws.QueryParameter("force", "force disable an addon").DataType("boolean").Required(false)).
|
||||
Writes(apis.AddonStatusResponse{}))
|
||||
|
||||
// update addon
|
||||
|
||||
Reference in New Issue
Block a user