diff --git a/docs/apidoc/swagger.json b/docs/apidoc/swagger.json index 9f4aa3991..cc9f77b13 100644 --- a/docs/apidoc/swagger.json +++ b/docs/apidoc/swagger.json @@ -15,7 +15,300 @@ "version": "v1beta1" }, "paths": { - "/api/v1/applications": { + "/api/v1/addon_registries": { + "get": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon_registry" + ], + "summary": "list all addon registry", + "operationId": "listAddonRegistry", + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.ListAddonRegistryResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + }, + "post": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon_registry" + ], + "summary": "create an addon registry", + "operationId": "createAddonRegistry", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.CreateAddonRegistryRequest" + } + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.AddonRegistryMeta" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/addon_registries/{name}": { + "delete": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon_registry" + ], + "summary": "delete an addon registry", + "operationId": "deleteAddonRegistry", + "parameters": [ + { + "type": "string", + "description": "identifier of the addon registry", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.AddonRegistryMeta" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/addons": { + "get": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon" + ], + "summary": "list all addons", + "operationId": "listAddons", + "parameters": [ + { + "type": "string", + "description": "Fuzzy search based on name and description.", + "name": "query", + "in": "query" + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.ListAddonResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/addons/{name}": { + "get": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon" + ], + "summary": "show details of an addon", + "operationId": "detailAddon", + "parameters": [ + { + "type": "string", + "description": "addon name to query detail", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.DetailAddonResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/addons/{name}/disable": { + "post": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon" + ], + "summary": "disable an addon", + "operationId": "disableAddon", + "parameters": [ + { + "type": "string", + "description": "addon name to enable", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.AddonStatusResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/addons/{name}/enable": { + "post": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon" + ], + "summary": "enable an addon", + "operationId": "enableAddon", + "parameters": [ + { + "type": "string", + "description": "addon name to enable", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.AddonStatusResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/addons/{name}/status": { + "get": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "addon" + ], + "summary": "show status of an addon", + "operationId": "statusAddon", + "parameters": [ + { + "type": "string", + "description": "addon name to query status", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.AddonStatusResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/applicationplans": { "get": { "consumes": [ "application/xml", @@ -53,7 +346,7 @@ "responses": { "200": { "schema": { - "$ref": "#/definitions/v1.ListApplicationResponse" + "$ref": "#/definitions/v1.ListApplicationPlanResponse" } }, "400": { @@ -83,14 +376,14 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.CreateApplicationRequest" + "$ref": "#/definitions/v1.CreateApplicationPlanRequest" } } ], "responses": { "200": { "schema": { - "$ref": "#/definitions/v1.ApplicationBase" + "$ref": "#/definitions/v1.ApplicationPlanBase" } }, "400": { @@ -101,7 +394,7 @@ } } }, - "/api/v1/applications/{name}": { + "/api/v1/applicationplans/{name}": { "get": { "consumes": [ "application/xml", @@ -128,7 +421,7 @@ "responses": { "200": { "schema": { - "$ref": "#/definitions/v1.DetailApplicationResponse" + "$ref": "#/definitions/v1.DetailApplicationPlanResponse" } }, "400": { @@ -175,7 +468,7 @@ } } }, - "/api/v1/applications/{name}/components": { + "/api/v1/applicationplans/{name}/componentplans": { "get": { "consumes": [ "application/xml", @@ -188,7 +481,7 @@ "tags": [ "application" ], - "summary": "gets the component topology of the application", + "summary": "gets the componentplan topology of the application", "operationId": "listApplicationComponents", "parameters": [ { @@ -200,16 +493,15 @@ }, { "type": "string", - "description": "list components that deployed in define cluster", - "name": "cluster", - "in": "path", - "required": true + "description": "list components that deployed in define env", + "name": "envName", + "in": "query" } ], "responses": { "200": { "schema": { - "$ref": "#/definitions/v1.ComponentListResponse" + "$ref": "#/definitions/v1.ComponentPlanListResponse" } }, "400": { @@ -231,7 +523,7 @@ "tags": [ "application" ], - "summary": "create component for application", + "summary": "create component plan for application plan", "operationId": "createComponent", "parameters": [ { @@ -246,14 +538,14 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.CreateComponentRequest" + "$ref": "#/definitions/v1.CreateComponentPlanRequest" } } ], "responses": { "200": { "schema": { - "$ref": "#/definitions/v1.ComponentBase" + "$ref": "#/definitions/v1.ComponentPlanBase" } }, "400": { @@ -264,7 +556,7 @@ } } }, - "/api/v1/applications/{name}/components/{componentName}": { + "/api/v1/applicationplans/{name}/componentplans/{componentName}": { "get": { "consumes": [ "application/xml", @@ -277,7 +569,7 @@ "tags": [ "application" ], - "summary": "detail component for application", + "summary": "detail component plan for application plan", "operationId": "detailComponent", "parameters": [ { @@ -291,7 +583,7 @@ "responses": { "200": { "schema": { - "$ref": "#/definitions/v1.DetailComponentResponse" + "$ref": "#/definitions/v1.DetailComponentPlanResponse" } }, "400": { @@ -302,7 +594,7 @@ } } }, - "/api/v1/applications/{name}/deploy": { + "/api/v1/applicationplans/{name}/deploy": { "post": { "consumes": [ "application/xml", @@ -340,7 +632,7 @@ } } }, - "/api/v1/applications/{name}/policies": { + "/api/v1/applicationplans/{name}/policies": { "get": { "consumes": [ "application/xml", @@ -422,7 +714,7 @@ } } }, - "/api/v1/applications/{name}/policies/{policyName}": { + "/api/v1/applicationplans/{name}/policies/{policyName}": { "get": { "consumes": [ "application/xml", @@ -561,7 +853,7 @@ } } }, - "/api/v1/applications/{name}/template": { + "/api/v1/applicationplans/{name}/template": { "post": { "consumes": [ "application/xml", @@ -715,6 +1007,13 @@ "summary": "list cloud clusters", "operationId": "listCloudClusters", "parameters": [ + { + "type": "string", + "description": "identifier of the cloud provider", + "name": "provider", + "in": "path", + "required": true + }, { "type": "int", "default": 0, @@ -768,6 +1067,13 @@ "summary": "create cluster from cloud cluster", "operationId": "connectCloudCluster", "parameters": [ + { + "type": "string", + "description": "identifier of the cloud provider", + "name": "provider", + "in": "path", + "required": true + }, { "name": "body", "in": "body", @@ -828,7 +1134,7 @@ } } }, - "post": { + "put": { "consumes": [ "application/xml", "application/json" @@ -1015,7 +1321,44 @@ } } }, - "/api/v1/workflows": { + "/api/v1/query": { + "get": { + "consumes": [ + "application/xml", + "application/json" + ], + "produces": [ + "application/json", + "application/xml" + ], + "tags": [ + "velaQL" + ], + "summary": "use velaQL to query resource status", + "operationId": "queryView", + "parameters": [ + { + "type": "string", + "description": "velaql query statement", + "name": "velaql", + "in": "query" + } + ], + "responses": { + "200": { + "schema": { + "$ref": "#/definitions/v1.VelaQLViewResponse" + } + }, + "400": { + "schema": { + "$ref": "#/definitions/bcode.Bcode" + } + } + } + } + }, + "/api/v1/workflowplans": { "get": { "consumes": [ "application/xml", @@ -1076,7 +1419,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.CreateWorkflowRequest" + "$ref": "#/definitions/v1.CreateWorkflowPlanRequest" } } ], @@ -1099,7 +1442,7 @@ } } }, - "/api/v1/workflows/{name}": { + "/api/v1/workflowplans/{name}": { "get": { "consumes": [ "application/xml", @@ -1162,7 +1505,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/v1.UpdateWorkflowRequest" + "$ref": "#/definitions/v1.UpdateWorkflowPlanRequest" } } ], @@ -1214,7 +1557,7 @@ } } }, - "/api/v1/workflows/{name}/records": { + "/api/v1/workflowplans/{name}/records": { "get": { "consumes": [ "application/xml", @@ -1228,7 +1571,7 @@ "cluster" ], "summary": "query application workflow execution record", - "operationId": "noop", + "operationId": "listWorkflowRecords", "parameters": [ { "type": "string", @@ -1265,7 +1608,7 @@ } } }, - "/v1/addons": { + "/api/v1/workflowplans/{name}/records/{record}": { "get": { "consumes": [ "application/xml", @@ -1276,16 +1619,24 @@ "application/xml" ], "tags": [ - "addon" + "cluster" ], - "summary": "list all addons", - "operationId": "noop", + "summary": "query application workflow execution record detail", + "operationId": "detailWorkflowRecord", "parameters": [ { "type": "string", - "description": "Cluster-based search", - "name": "cluster", - "in": "query" + "description": "identifier of the workflow", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "identifier of the workflow record", + "name": "record", + "in": "path", + "required": true } ], "responses": { @@ -1299,187 +1650,6 @@ "description": "Bummer, something went wrong" } } - }, - "post": { - "consumes": [ - "application/xml", - "application/json" - ], - "produces": [ - "application/json", - "application/xml" - ], - "tags": [ - "addon" - ], - "summary": "create an addon", - "operationId": "noop", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1.CreateAddonRequest" - } - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/v1/addons/{name}": { - "get": { - "consumes": [ - "application/xml", - "application/json" - ], - "produces": [ - "application/json", - "application/xml" - ], - "tags": [ - "addon" - ], - "summary": "show details of an addon", - "operationId": "noop", - "parameters": [ - { - "type": "string", - "description": "identifier of the addon", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - }, - "delete": { - "consumes": [ - "application/xml", - "application/json" - ], - "produces": [ - "application/json", - "application/xml" - ], - "tags": [ - "addon" - ], - "summary": "delete an addon", - "operationId": "noop", - "parameters": [ - { - "type": "string", - "description": "identifier of the addon", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/v1/addons/{name}/disable": { - "post": { - "consumes": [ - "application/xml", - "application/json" - ], - "produces": [ - "application/json", - "application/xml" - ], - "tags": [ - "addon" - ], - "summary": "disable an addon on a cluster", - "operationId": "noop", - "parameters": [ - { - "type": "string", - "description": "cluster name", - "name": "cluster", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/v1/addons/{name}/enable": { - "post": { - "consumes": [ - "application/xml", - "application/json" - ], - "produces": [ - "application/json", - "application/xml" - ], - "tags": [ - "addon" - ], - "summary": "enable an addon on a cluster", - "operationId": "noop", - "parameters": [ - { - "type": "string", - "description": "cluster name", - "name": "cluster", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/v1/addons/{name}/status": { - "get": { - "consumes": [ - "application/xml", - "application/json" - ], - "produces": [ - "application/json", - "application/xml" - ], - "tags": [ - "addon" - ], - "summary": "show status of an addon", - "operationId": "noop", - "parameters": [ - { - "type": "string", - "description": "identifier of the addon", - "name": "name", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } } }, "/v1/namespaces/{namespace}/applications/{appname}": { @@ -1619,6 +1789,7 @@ }, "cloudprovider.CloudCluster": { "required": [ + "provider", "id", "name", "type", @@ -1647,6 +1818,9 @@ "name": { "type": "string" }, + "provider": { + "type": "string" + }, "status": { "type": "string" }, @@ -1661,10 +1835,10 @@ "common.AppRolloutStatus": { "required": [ "batchRollingState", - "currentBatch", "upgradedReplicas", - "upgradedReadyReplicas", "rollingState", + "currentBatch", + "upgradedReadyReplicas", "lastTargetAppRevision" ], "properties": { @@ -2129,16 +2303,20 @@ "type": "string" } }, - "model.ApplicationComponent": { + "model.ApplicationComponentPlan": { "required": [ "createTime", "updateTime", "appPrimaryKey", "creator", "name", + "alias", "type" ], "properties": { + "alias": { + "type": "string" + }, "appPrimaryKey": { "type": "string" }, @@ -2197,7 +2375,7 @@ "traits": { "type": "array", "items": { - "$ref": "#/definitions/model.ApplicationTrait" + "$ref": "#/definitions/model.ApplicationTraitPlan" } }, "type": { @@ -2209,7 +2387,7 @@ } } }, - "model.ApplicationTrait": { + "model.ApplicationTraitPlan": { "required": [ "type" ], @@ -2222,6 +2400,86 @@ } } }, + "model.Cluster": { + "required": [ + "createTime", + "updateTime", + "name", + "alias", + "description", + "icon", + "labels", + "status", + "reason", + "provider", + "apiServerURL", + "dashboardURL", + "kubeConfig", + "kubeConfigSecret" + ], + "properties": { + "alias": { + "type": "string" + }, + "apiServerURL": { + "type": "string" + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "dashboardURL": { + "type": "string" + }, + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "kubeConfig": { + "type": "string" + }, + "kubeConfigSecret": { + "type": "string" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "provider": { + "$ref": "#/definitions/model.ProviderInfo" + }, + "reason": { + "type": "string" + }, + "status": { + "type": "string" + }, + "updateTime": { + "type": "string", + "format": "date-time" + } + } + }, + "model.GitAddonSource": { + "properties": { + "path": { + "type": "string" + }, + "token": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "model.JSONStruct": { "type": "object" }, @@ -2243,6 +2501,7 @@ }, "model.ProviderInfo": { "required": [ + "provider", "name", "id", "zone", @@ -2261,6 +2520,9 @@ "name": { "type": "string" }, + "provider": { + "type": "string" + }, "zone": { "type": "string" } @@ -2322,8 +2584,7 @@ "version", "description", "icon", - "tags", - "phase" + "tags" ], "properties": { "description": { @@ -2335,9 +2596,6 @@ "name": { "type": "string" }, - "phase": { - "type": "string" - }, "tags": { "type": "array", "items": { @@ -2349,71 +2607,32 @@ } } }, + "v1.AddonRegistryMeta": { + "required": [ + "name" + ], + "properties": { + "git": { + "$ref": "#/definitions/model.GitAddonSource" + }, + "name": { + "type": "string" + } + } + }, "v1.AddonStatusResponse": { "required": [ "phase" ], "properties": { + "enabling_progress": { + "$ref": "#/definitions/v1.EnablingProgress" + }, "phase": { "type": "string" } } }, - "v1.ApplicationBase": { - "required": [ - "name", - "namespace", - "description", - "createTime", - "updateTime", - "icon", - "status", - "gatewayRule" - ], - "properties": { - "createTime": { - "type": "string", - "format": "date-time" - }, - "description": { - "type": "string" - }, - "envBind": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.EnvBind" - } - }, - "gatewayRule": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.GatewayRule" - } - }, - "icon": { - "type": "string" - }, - "labels": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "name": { - "type": "string" - }, - "namespace": { - "type": "string" - }, - "status": { - "type": "string" - }, - "updateTime": { - "type": "string", - "format": "date-time" - } - } - }, "v1.ApplicationDeployRequest": { "required": [ "workflowName", @@ -2466,6 +2685,65 @@ } } }, + "v1.ApplicationPlanBase": { + "required": [ + "name", + "alias", + "namespace", + "description", + "createTime", + "updateTime", + "icon", + "status", + "gatewayRule" + ], + "properties": { + "alias": { + "type": "string" + }, + "createTime": { + "type": "string", + "format": "date-time" + }, + "description": { + "type": "string" + }, + "envBind": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.EnvBind" + } + }, + "gatewayRule": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.GatewayRule" + } + }, + "icon": { + "type": "string" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "status": { + "type": "string" + }, + "updateTime": { + "type": "string", + "format": "date-time" + } + } + }, "v1.ApplicationRequest": { "required": [ "components" @@ -2578,6 +2856,7 @@ "v1.ClusterBase": { "required": [ "name", + "alias", "description", "icon", "labels", @@ -2588,6 +2867,9 @@ "reason" ], "properties": { + "alias": { + "type": "string" + }, "apiServerURL": { "type": "string" }, @@ -2693,10 +2975,29 @@ } } }, - "v1.ComponentBase": { + "v1.ComponentDefinitionBase": { "required": [ "name", "description", + "icon" + ], + "properties": { + "description": { + "type": "string" + }, + "icon": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "v1.ComponentPlanBase": { + "required": [ + "name", + "alias", + "description", "componentType", "envNames", "dependsOn", @@ -2705,6 +3006,9 @@ "updateTime" ], "properties": { + "alias": { + "type": "string" + }, "componentType": { "type": "string" }, @@ -2751,33 +3055,15 @@ } } }, - "v1.ComponentDefinitionBase": { + "v1.ComponentPlanListResponse": { "required": [ - "name", - "description", - "icon" + "componentplans" ], "properties": { - "description": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "v1.ComponentListResponse": { - "required": [ - "components" - ], - "properties": { - "components": { + "componentplans": { "type": "array", "items": { - "$ref": "#/definitions/v1.ComponentBase" + "$ref": "#/definitions/v1.ComponentPlanBase" } } } @@ -2788,6 +3074,7 @@ "accessKeySecret", "clusterID", "name", + "alias", "icon" ], "properties": { @@ -2797,6 +3084,9 @@ "accessKeySecret": { "type": "string" }, + "alias": { + "type": "string" + }, "clusterID": { "type": "string" }, @@ -2817,51 +3107,31 @@ } } }, - "v1.CreateAddonRequest": { + "v1.CreateAddonRegistryRequest": { "required": [ - "name", - "version", - "icon", - "tags" + "name" ], "properties": { - "deploy_data": { - "type": "string" - }, - "deploy_url": { - "type": "string" - }, - "description": { - "type": "string" - }, - "detail": { - "type": "string" - }, - "icon": { - "type": "string" + "git": { + "$ref": "#/definitions/model.GitAddonSource" }, "name": { "type": "string" - }, - "tags": { - "type": "array", - "items": { - "type": "string" - } - }, - "version": { - "type": "string" } } }, - "v1.CreateApplicationRequest": { + "v1.CreateApplicationPlanRequest": { "required": [ "name", + "alias", "namespace", "description", "icon" ], "properties": { + "alias": { + "type": "string" + }, "deploy": { "type": "boolean" }, @@ -2915,9 +3185,13 @@ "v1.CreateClusterRequest": { "required": [ "name", + "alias", "icon" ], "properties": { + "alias": { + "type": "string" + }, "dashboardURL": { "type": "string" }, @@ -2944,15 +3218,19 @@ } } }, - "v1.CreateComponentRequest": { + "v1.CreateComponentPlanRequest": { "required": [ "name", + "alias", "description", "icon", "componentType", "dependsOn" ], "properties": { + "alias": { + "type": "string" + }, "componentType": { "type": "string" }, @@ -3024,15 +3302,19 @@ } } }, - "v1.CreateWorkflowRequest": { + "v1.CreateWorkflowPlanRequest": { "required": [ "appName", "name", + "alias", "description", "enable", "default" ], "properties": { + "alias": { + "type": "string" + }, "appName": { "type": "string" }, @@ -3058,20 +3340,16 @@ }, "v1.DetailAddonResponse": { "required": [ + "version", "description", "icon", "tags", - "phase", - "name", - "version" + "name" ], "properties": { "deploy_data": { "type": "string" }, - "deploy_url": { - "type": "string" - }, "description": { "type": "string" }, @@ -3084,9 +3362,6 @@ "name": { "type": "string" }, - "phase": { - "type": "string" - }, "tags": { "type": "array", "items": { @@ -3098,22 +3373,26 @@ } } }, - "v1.DetailApplicationResponse": { + "v1.DetailApplicationPlanResponse": { "required": [ - "description", - "createTime", + "icon", "status", "gatewayRule", - "name", "namespace", + "description", + "createTime", "updateTime", - "icon", + "name", + "alias", "policies", "status", "resourceInfo", "workflowStatus" ], "properties": { + "alias": { + "type": "string" + }, "createTime": { "type": "string", "format": "date-time" @@ -3174,21 +3453,33 @@ }, "v1.DetailClusterResponse": { "required": [ - "status", - "icon", + "createTime", "description", - "labels", - "providerInfo", - "apiServerURL", - "dashboardURL", + "status", "reason", + "kubeConfig", + "kubeConfigSecret", "name", + "alias", + "provider", + "labels", + "dashboardURL", + "updateTime", + "icon", + "apiServerURL", "resourceInfo" ], "properties": { + "alias": { + "type": "string" + }, "apiServerURL": { "type": "string" }, + "createTime": { + "type": "string", + "format": "date-time" + }, "dashboardURL": { "type": "string" }, @@ -3198,6 +3489,12 @@ "icon": { "type": "string" }, + "kubeConfig": { + "type": "string" + }, + "kubeConfigSecret": { + "type": "string" + }, "labels": { "type": "object", "additionalProperties": { @@ -3207,26 +3504,28 @@ "name": { "type": "string" }, - "providerInfo": { + "provider": { "$ref": "#/definitions/model.ProviderInfo" }, "reason": { "type": "string" }, - "remoteManageURL": { - "type": "string" - }, "resourceInfo": { "$ref": "#/definitions/v1.ClusterResourceInfo" }, "status": { "type": "string" + }, + "updateTime": { + "type": "string", + "format": "date-time" } } }, - "v1.DetailComponentResponse": { + "v1.DetailComponentPlanResponse": { "required": [ "appPrimaryKey", + "alias", "type", "updateTime", "creator", @@ -3234,6 +3533,9 @@ "createTime" ], "properties": { + "alias": { + "type": "string" + }, "appPrimaryKey": { "type": "string" }, @@ -3292,7 +3594,7 @@ "traits": { "type": "array", "items": { - "$ref": "#/definitions/model.ApplicationTrait" + "$ref": "#/definitions/model.ApplicationTraitPlan" } }, "type": { @@ -3306,13 +3608,13 @@ }, "v1.DetailPolicyResponse": { "required": [ + "description", "creator", "properties", "createTime", "updateTime", "name", - "type", - "description" + "type" ], "properties": { "createTime": { @@ -3340,17 +3642,21 @@ } } }, - "v1.DetailWorkflowResponse": { + "v1.DetailWorkflowPlanResponse": { "required": [ + "description", + "enable", "default", "createTime", "updateTime", "name", - "description", - "enable", + "alias", "workflowRecord" ], "properties": { + "alias": { + "type": "string" + }, "createTime": { "type": "string", "format": "date-time" @@ -3382,7 +3688,72 @@ } } }, + "v1.DetailWorkflowRecordResponse": { + "required": [ + "name", + "namespace", + "suspend", + "terminated", + "deployTime", + "deployUser", + "commit", + "sourceType" + ], + "properties": { + "commit": { + "type": "string" + }, + "deployTime": { + "type": "string", + "format": "date-time" + }, + "deployUser": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "sourceType": { + "type": "string" + }, + "startTime": { + "type": "string", + "format": "date-time" + }, + "steps": { + "type": "array", + "items": { + "$ref": "#/definitions/common.WorkflowStepStatus" + } + }, + "suspend": { + "type": "boolean" + }, + "terminated": { + "type": "boolean" + } + } + }, "v1.EmptyResponse": {}, + "v1.EnablingProgress": { + "required": [ + "enabled_components", + "total_components" + ], + "properties": { + "enabled_components": { + "type": "integer", + "format": "int32" + }, + "total_components": { + "type": "integer", + "format": "int32" + } + } + }, "v1.EnvBind": { "required": [ "name", @@ -3427,6 +3798,19 @@ } } }, + "v1.ListAddonRegistryResponse": { + "required": [ + "registrys" + ], + "properties": { + "registrys": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.AddonRegistryMeta" + } + } + } + }, "v1.ListAddonResponse": { "required": [ "addons" @@ -3440,6 +3824,19 @@ } } }, + "v1.ListApplicationPlanResponse": { + "required": [ + "applicationplans" + ], + "properties": { + "applicationplans": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.ApplicationPlanBase" + } + } + } + }, "v1.ListApplicationPolicy": { "required": [ "policies" @@ -3453,19 +3850,6 @@ } } }, - "v1.ListApplicationResponse": { - "required": [ - "applications" - ], - "properties": { - "applications": { - "type": "array", - "items": { - "$ref": "#/definitions/v1.ApplicationBase" - } - } - } - }, "v1.ListCloudClusterResponse": { "required": [ "clusters", @@ -3536,6 +3920,19 @@ } } }, + "v1.ListWorkflowPlanResponse": { + "required": [ + "workflowplans" + ], + "properties": { + "workflowplans": { + "type": "array", + "items": { + "$ref": "#/definitions/v1.WorkflowPlanBase" + } + } + } + }, "v1.ListWorkflowRecordsResponse": { "required": [ "records", @@ -3710,13 +4107,17 @@ } } }, - "v1.UpdateWorkflowRequest": { + "v1.UpdateWorkflowPlanRequest": { "required": [ + "alias", "description", "enable", "default" ], "properties": { + "alias": { + "type": "string" + }, "default": { "type": "boolean" }, @@ -3734,9 +4135,13 @@ } } }, - "v1.WorkflowBase": { + "v1.VelaQLViewResponse": { + "type": "object" + }, + "v1.WorkflowPlanBase": { "required": [ "name", + "alias", "description", "enable", "default", @@ -3744,6 +4149,9 @@ "updateTime" ], "properties": { + "alias": { + "type": "string" + }, "createTime": { "type": "string", "format": "date-time" @@ -3766,7 +4174,38 @@ } } }, - "v1.WorkflowRecord": {}, + "v1.WorkflowRecord": { + "required": [ + "name", + "namespace", + "suspend", + "terminated" + ], + "properties": { + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "startTime": { + "type": "string", + "format": "date-time" + }, + "steps": { + "type": "array", + "items": { + "$ref": "#/definitions/common.WorkflowStepStatus" + } + }, + "suspend": { + "type": "boolean" + }, + "terminated": { + "type": "boolean" + } + } + }, "v1.WorkflowStep": { "required": [ "name", diff --git a/pkg/apiserver/datastore/datastore_test.go b/pkg/apiserver/datastore/datastore_test.go index 26feeff76..c6fd219c3 100644 --- a/pkg/apiserver/datastore/datastore_test.go +++ b/pkg/apiserver/datastore/datastore_test.go @@ -30,7 +30,7 @@ import ( var _ = Describe("Test new entity function", func() { It("Test new application entity", func() { - var app model.Application + var app model.ApplicationPlan new, err := NewEntity(&app) Expect(err).To(BeNil()) json.Unmarshal([]byte(`{"name":"demo"}`), new) @@ -40,7 +40,7 @@ var _ = Describe("Test new entity function", func() { }) It("Test new multiple application entity", func() { - var app model.Application + var app model.ApplicationPlan var list []Entity var n = 3 for n > 0 { diff --git a/pkg/apiserver/datastore/kubeapi/kubeapi_test.go b/pkg/apiserver/datastore/kubeapi/kubeapi_test.go index bdb52f62f..b5d8c0e63 100644 --- a/pkg/apiserver/datastore/kubeapi/kubeapi_test.go +++ b/pkg/apiserver/datastore/kubeapi/kubeapi_test.go @@ -88,22 +88,22 @@ var _ = Describe("Test kubeapi datastore driver", func() { Expect(kubeStore).ToNot(BeNil()) It("Test add funtion", func() { - err := kubeStore.Add(context.TODO(), &model.Application{Name: "kubevela-app", Description: "default"}) + err := kubeStore.Add(context.TODO(), &model.ApplicationPlan{Name: "kubevela-app", Description: "default"}) Expect(err).ToNot(HaveOccurred()) }) It("Test batch add funtion", func() { var datas = []datastore.Entity{ - &model.Application{Name: "kubevela-app-2", Description: "this is demo 2"}, - &model.Application{Namespace: "test-namespace", Name: "kubevela-app-3", Description: "this is demo 3"}, - &model.Application{Namespace: "test-namespace2", Name: "kubevela-app-4", Description: "this is demo 4"}, + &model.ApplicationPlan{Name: "kubevela-app-2", Description: "this is demo 2"}, + &model.ApplicationPlan{Namespace: "test-namespace", Name: "kubevela-app-3", Description: "this is demo 3"}, + &model.ApplicationPlan{Namespace: "test-namespace2", Name: "kubevela-app-4", Description: "this is demo 4"}, } err := kubeStore.BatchAdd(context.TODO(), datas) Expect(err).ToNot(HaveOccurred()) var datas2 = []datastore.Entity{ - &model.Application{Namespace: "test-namespace", Name: "can-delete", Description: "this is demo can-delete"}, - &model.Application{Name: "kubevela-app-2", Description: "this is demo 2"}, + &model.ApplicationPlan{Namespace: "test-namespace", Name: "can-delete", Description: "this is demo can-delete"}, + &model.ApplicationPlan{Name: "kubevela-app-2", Description: "this is demo 2"}, } err = kubeStore.BatchAdd(context.TODO(), datas2) equal := cmp.Diff(strings.Contains(err.Error(), "save components occur error"), true) @@ -111,7 +111,7 @@ var _ = Describe("Test kubeapi datastore driver", func() { }) It("Test get funtion", func() { - app := &model.Application{Name: "kubevela-app"} + app := &model.ApplicationPlan{Name: "kubevela-app"} err := kubeStore.Get(context.TODO(), app) Expect(err).Should(BeNil()) diff := cmp.Diff(app.Description, "default") @@ -119,11 +119,11 @@ var _ = Describe("Test kubeapi datastore driver", func() { }) It("Test put funtion", func() { - err := kubeStore.Put(context.TODO(), &model.Application{Name: "kubevela-app", Description: "this is demo"}) + err := kubeStore.Put(context.TODO(), &model.ApplicationPlan{Name: "kubevela-app", Description: "this is demo"}) Expect(err).ToNot(HaveOccurred()) }) It("Test index", func() { - var app = model.Application{ + var app = model.ApplicationPlan{ Namespace: "test", } selector, err := labels.Parse(fmt.Sprintf("table=%s", app.TableName())) @@ -137,7 +137,7 @@ var _ = Describe("Test kubeapi datastore driver", func() { Expect(cmp.Diff(selector.String(), "namespace=test,table=vela_application")).Should(BeEmpty()) }) It("Test list function", func() { - var app model.Application + var app model.ApplicationPlan list, err := kubeStore.List(context.TODO(), &app, &datastore.ListOptions{Page: -1}) Expect(err).ShouldNot(HaveOccurred()) diff := cmp.Diff(len(list), 4) @@ -166,7 +166,7 @@ var _ = Describe("Test kubeapi datastore driver", func() { }) It("Test count function", func() { - var app model.Application + var app model.ApplicationPlan count, err := kubeStore.Count(context.TODO(), &app) Expect(err).ShouldNot(HaveOccurred()) Expect(count).Should(Equal(int64(4))) @@ -178,7 +178,7 @@ var _ = Describe("Test kubeapi datastore driver", func() { }) It("Test isExist function", func() { - var app model.Application + var app model.ApplicationPlan app.Name = "kubevela-app-3" exist, err := kubeStore.IsExist(context.TODO(), &app) Expect(err).ShouldNot(HaveOccurred()) @@ -193,7 +193,7 @@ var _ = Describe("Test kubeapi datastore driver", func() { }) It("Test delete funtion", func() { - var app model.Application + var app model.ApplicationPlan app.Name = "kubevela-app" err := kubeStore.Delete(context.TODO(), &app) Expect(err).ShouldNot(HaveOccurred()) diff --git a/pkg/apiserver/datastore/mongodb/mongodb_test.go b/pkg/apiserver/datastore/mongodb/mongodb_test.go index 3e947d028..ac5f884f6 100644 --- a/pkg/apiserver/datastore/mongodb/mongodb_test.go +++ b/pkg/apiserver/datastore/mongodb/mongodb_test.go @@ -56,22 +56,22 @@ var _ = BeforeSuite(func(done Done) { var _ = Describe("Test mongodb datastore driver", func() { It("Test add funtion", func() { - err := mongodbDriver.Add(context.TODO(), &model.Application{Name: "kubevela-app", Description: "default"}) + err := mongodbDriver.Add(context.TODO(), &model.ApplicationPlan{Name: "kubevela-app", Description: "default"}) Expect(err).ToNot(HaveOccurred()) }) It("Test batch add funtion", func() { var datas = []datastore.Entity{ - &model.Application{Name: "kubevela-app-2", Description: "this is demo 2"}, - &model.Application{Namespace: "test-namespace", Name: "kubevela-app-3", Description: "this is demo 3"}, - &model.Application{Namespace: "test-namespace2", Name: "kubevela-app-4", Description: "this is demo 4"}, + &model.ApplicationPlan{Name: "kubevela-app-2", Description: "this is demo 2"}, + &model.ApplicationPlan{Namespace: "test-namespace", Name: "kubevela-app-3", Description: "this is demo 3"}, + &model.ApplicationPlan{Namespace: "test-namespace2", Name: "kubevela-app-4", Description: "this is demo 4"}, } err := mongodbDriver.BatchAdd(context.TODO(), datas) Expect(err).ToNot(HaveOccurred()) var datas2 = []datastore.Entity{ - &model.Application{Namespace: "test-namespace", Name: "can-delete", Description: "this is demo can-delete"}, - &model.Application{Name: "kubevela-app-2", Description: "this is demo 2"}, + &model.ApplicationPlan{Namespace: "test-namespace", Name: "can-delete", Description: "this is demo can-delete"}, + &model.ApplicationPlan{Name: "kubevela-app-2", Description: "this is demo 2"}, } err = mongodbDriver.BatchAdd(context.TODO(), datas2) equal := cmp.Diff(strings.Contains(err.Error(), "save components occur error"), true) @@ -79,7 +79,7 @@ var _ = Describe("Test mongodb datastore driver", func() { }) It("Test get funtion", func() { - app := &model.Application{Name: "kubevela-app"} + app := &model.ApplicationPlan{Name: "kubevela-app"} err := mongodbDriver.Get(context.TODO(), app) Expect(err).Should(BeNil()) diff := cmp.Diff(app.Description, "default") @@ -87,11 +87,11 @@ var _ = Describe("Test mongodb datastore driver", func() { }) It("Test put funtion", func() { - err := mongodbDriver.Put(context.TODO(), &model.Application{Name: "kubevela-app", Description: "this is demo"}) + err := mongodbDriver.Put(context.TODO(), &model.ApplicationPlan{Name: "kubevela-app", Description: "this is demo"}) Expect(err).ToNot(HaveOccurred()) }) It("Test list funtion", func() { - var app model.Application + var app model.ApplicationPlan list, err := mongodbDriver.List(context.TODO(), &app, &datastore.ListOptions{Page: -1}) Expect(err).ShouldNot(HaveOccurred()) diff := cmp.Diff(len(list), 4) @@ -120,7 +120,7 @@ var _ = Describe("Test mongodb datastore driver", func() { }) It("Test count function", func() { - var app model.Application + var app model.ApplicationPlan count, err := mongodbDriver.Count(context.TODO(), &app) Expect(err).ShouldNot(HaveOccurred()) Expect(count).Should(Equal(int64(4))) @@ -132,7 +132,7 @@ var _ = Describe("Test mongodb datastore driver", func() { }) It("Test isExist funtion", func() { - var app model.Application + var app model.ApplicationPlan app.Name = "kubevela-app-3" exist, err := mongodbDriver.IsExist(context.TODO(), &app) Expect(err).ShouldNot(HaveOccurred()) @@ -147,7 +147,7 @@ var _ = Describe("Test mongodb datastore driver", func() { }) It("Test delete funtion", func() { - var app model.Application + var app model.ApplicationPlan app.Name = "kubevela-app" err := mongodbDriver.Delete(context.TODO(), &app) Expect(err).ShouldNot(HaveOccurred()) diff --git a/pkg/apiserver/model/application.go b/pkg/apiserver/model/application.go index 9a3f1be8b..5095f1cc7 100644 --- a/pkg/apiserver/model/application.go +++ b/pkg/apiserver/model/application.go @@ -23,11 +23,11 @@ import ( ) func init() { - RegistModel(&ApplicationComponent{}, &ApplicationPolicy{}, &Application{}, &DeployEvent{}) + RegistModel(&ApplicationComponentPlan{}, &ApplicationPolicyPlan{}, &ApplicationPlan{}, &DeployEvent{}) } -// Application database model -type Application struct { +// ApplicationPlan application delivery plan model +type ApplicationPlan struct { Model Name string `json:"name"` Alias string `json:"alias"` @@ -39,17 +39,17 @@ type Application struct { } // TableName return custom table name -func (a *Application) TableName() string { +func (a *ApplicationPlan) TableName() string { return tableNamePrefix + "application" } // PrimaryKey return custom primary key -func (a *Application) PrimaryKey() string { +func (a *ApplicationPlan) PrimaryKey() string { return a.Name } // Index return custom index -func (a *Application) Index() map[string]string { +func (a *ApplicationPlan) Index() map[string]string { index := make(map[string]string) if a.Name != "" { index["name"] = a.Name @@ -74,8 +74,8 @@ type ClusterSelector struct { Namespace string `json:"namespace,omitempty"` } -// ApplicationComponent component database model -type ApplicationComponent struct { +// ApplicationComponentPlan component database model +type ApplicationComponentPlan struct { Model AppPrimaryKey string `json:"appPrimaryKey"` Description string `json:"description,omitempty"` @@ -93,24 +93,24 @@ type ApplicationComponent struct { Inputs common.StepInputs `json:"inputs,omitempty"` Outputs common.StepOutputs `json:"outputs,omitempty"` // Traits define the trait of one component, the type must be array to keep the order. - Traits []ApplicationTrait `json:"traits,omitempty"` - // scopes in ApplicationComponent defines the component-level scopes + Traits []ApplicationTraitPlan `json:"traits,omitempty"` + // scopes in ApplicationComponentPlan defines the component-level scopes // the format is pairs, the key represents type of `ScopeDefinition` while the value represent the name of scope instance. Scopes map[string]string `json:"scopes,omitempty"` } // TableName return custom table name -func (a *ApplicationComponent) TableName() string { +func (a *ApplicationComponentPlan) TableName() string { return tableNamePrefix + "application_component" } // PrimaryKey return custom primary key -func (a *ApplicationComponent) PrimaryKey() string { +func (a *ApplicationComponentPlan) PrimaryKey() string { return fmt.Sprintf("%s-%s", a.AppPrimaryKey, a.Name) } // Index return custom index -func (a *ApplicationComponent) Index() map[string]string { +func (a *ApplicationComponentPlan) Index() map[string]string { index := make(map[string]string) if a.Name != "" { index["name"] = a.Name @@ -124,8 +124,8 @@ func (a *ApplicationComponent) Index() map[string]string { return index } -// ApplicationPolicy app policy -type ApplicationPolicy struct { +// ApplicationPolicyPlan app policy +type ApplicationPolicyPlan struct { Model AppPrimaryKey string `json:"appPrimaryKey"` Name string `json:"name"` @@ -136,17 +136,17 @@ type ApplicationPolicy struct { } // TableName return custom table name -func (a *ApplicationPolicy) TableName() string { +func (a *ApplicationPolicyPlan) TableName() string { return tableNamePrefix + "application_policy" } // PrimaryKey return custom primary key -func (a *ApplicationPolicy) PrimaryKey() string { +func (a *ApplicationPolicyPlan) PrimaryKey() string { return fmt.Sprintf("%s-%s", a.AppPrimaryKey, a.Name) } // Index return custom index -func (a *ApplicationPolicy) Index() map[string]string { +func (a *ApplicationPolicyPlan) Index() map[string]string { index := make(map[string]string) if a.Name != "" { index["name"] = a.Name @@ -160,8 +160,8 @@ func (a *ApplicationPolicy) Index() map[string]string { return index } -// ApplicationTrait application trait -type ApplicationTrait struct { +// ApplicationTraitPlan application trait +type ApplicationTraitPlan struct { Type string `json:"type"` Properties *JSONStruct `json:"properties,omitempty"` } diff --git a/pkg/apiserver/model/workflow.go b/pkg/apiserver/model/workflow.go index c0395f54d..261f76070 100644 --- a/pkg/apiserver/model/workflow.go +++ b/pkg/apiserver/model/workflow.go @@ -24,12 +24,12 @@ import ( ) func init() { - RegistModel(&Workflow{}) + RegistModel(&WorkflowPlan{}) RegistModel(&WorkflowRecord{}) } -// Workflow application delivery plan database model -type Workflow struct { +// WorkflowPlan application delivery plan database model +type WorkflowPlan struct { Model Name string `json:"name"` Alias string `json:"alias"` @@ -55,17 +55,17 @@ type WorkflowStep struct { } // TableName return custom table name -func (w *Workflow) TableName() string { +func (w *WorkflowPlan) TableName() string { return tableNamePrefix + "workflow" } // PrimaryKey return custom primary key -func (w *Workflow) PrimaryKey() string { +func (w *WorkflowPlan) PrimaryKey() string { return w.Name } // Index return custom primary key -func (w *Workflow) Index() map[string]string { +func (w *WorkflowPlan) Index() map[string]string { index := make(map[string]string) if w.Name != "" { index["name"] = w.Name diff --git a/pkg/apiserver/rest/apis/v1/types.go b/pkg/apiserver/rest/apis/v1/types.go index 197e366a4..fb4c0e24c 100644 --- a/pkg/apiserver/rest/apis/v1/types.go +++ b/pkg/apiserver/rest/apis/v1/types.go @@ -187,16 +187,16 @@ type ClusterBase struct { Reason string `json:"reason"` } -// ListApplicatioOptions list application query options -type ListApplicatioOptions struct { +// ListApplicatioPlanOptions list application plan query options +type ListApplicatioPlanOptions struct { Namespace string `json:"namespace"` Cluster string `json:"cluster"` Query string `json:"query"` } -// ListApplicationResponse list applications by query params -type ListApplicationResponse struct { - Applications []*ApplicationBase `json:"applications"` +// ListApplicationPlanResponse list applications by query params +type ListApplicationPlanResponse struct { + ApplicationPlans []*ApplicationPlanBase `json:"applicationplans"` } // EnvBindList env bind list @@ -212,8 +212,8 @@ func (e EnvBindList) ContainCluster(name string) bool { return false } -// ApplicationBase application base model -type ApplicationBase struct { +// ApplicationPlanBase application base model +type ApplicationPlanBase struct { Name string `json:"name"` Alias string `json:"alias"` Namespace string `json:"namespace"` @@ -246,8 +246,8 @@ type GatewayRule struct { ComponentPort int32 `json:"componentPort"` } -// CreateApplicationRequest create application request body -type CreateApplicationRequest struct { +// CreateApplicationPlanRequest create application plan request body +type CreateApplicationPlanRequest struct { Name string `json:"name" validate:"checkname"` Alias string `json:"alias" validate:"checkalias"` Namespace string `json:"namespace" validate:"checkname"` @@ -274,9 +274,9 @@ type ClusterSelector struct { Namespace string `json:"namespace,omitempty"` } -// DetailApplicationResponse application detail -type DetailApplicationResponse struct { - ApplicationBase +// DetailApplicationPlanResponse application plan detail +type DetailApplicationPlanResponse struct { + ApplicationPlanBase Policies []string `json:"policies"` Status string `json:"status"` ResourceInfo ApplicationResourceInfo `json:"resourceInfo"` @@ -296,8 +296,8 @@ type ApplicationResourceInfo struct { // Others, such as: Memory、CPU、GPU、Storage } -// ComponentBase component base model -type ComponentBase struct { +// ComponentPlanBase component plan base model +type ComponentPlanBase struct { Name string `json:"name"` Alias string `json:"alias"` Description string `json:"description"` @@ -312,13 +312,13 @@ type ComponentBase struct { UpdateTime time.Time `json:"updateTime"` } -// ComponentListResponse list component -type ComponentListResponse struct { - Components []*ComponentBase `json:"components"` +// ComponentPlanListResponse list component plan +type ComponentPlanListResponse struct { + ComponentPlans []*ComponentPlanBase `json:"componentplans"` } -// CreateComponentRequest create component request model -type CreateComponentRequest struct { +// CreateComponentPlanRequest create component plan request model +type CreateComponentPlanRequest struct { Name string `json:"name" validate:"checkname"` Alias string `json:"alias" validate:"checkalias"` Description string `json:"description"` @@ -330,9 +330,9 @@ type CreateComponentRequest struct { DependsOn []string `json:"dependsOn"` } -// DetailComponentResponse detail component model -type DetailComponentResponse struct { - model.ApplicationComponent +// DetailComponentPlanResponse detail component plan model +type DetailComponentPlanResponse struct { + model.ApplicationComponentPlan //TODO: Status } @@ -452,8 +452,8 @@ type PolicyDefinition struct { Parameters []types.Parameter `json:"parameters"` } -// CreateWorkflowRequest create workflow request -type CreateWorkflowRequest struct { +// CreateWorkflowPlanRequest create workflow plan request +type CreateWorkflowPlanRequest struct { AppName string `json:"appName" validate:"checkname"` Name string `json:"name" validate:"checkname"` Alias string `json:"alias" validate:"checkalias"` @@ -463,8 +463,8 @@ type CreateWorkflowRequest struct { Default bool `json:"default"` } -// UpdateWorkflowRequest update or create application workflow -type UpdateWorkflowRequest struct { +// UpdateWorkflowPlanRequest update or create application workflow +type UpdateWorkflowPlanRequest struct { Alias string `json:"alias" validate:"checkalias"` Description string `json:"description"` Steps []WorkflowStep `json:"steps,omitempty"` @@ -483,20 +483,20 @@ type WorkflowStep struct { Outputs common.StepOutputs `json:"outputs,omitempty"` } -// DetailWorkflowResponse detail workflow response -type DetailWorkflowResponse struct { - WorkflowBase +// DetailWorkflowPlanResponse detail workflow response +type DetailWorkflowPlanResponse struct { + WorkflowPlanBase Steps []WorkflowStep `json:"steps,omitempty"` LastRecord *WorkflowRecord `json:"workflowRecord"` } -// ListWorkflowResponse list application workflows -type ListWorkflowResponse struct { - Workflows []*WorkflowBase `json:"workflows"` +// ListWorkflowPlanResponse list application workflows +type ListWorkflowPlanResponse struct { + WorkflowPlans []*WorkflowPlanBase `json:"workflowplans"` } -// WorkflowBase workflow base model -type WorkflowBase struct { +// WorkflowPlanBase workflow base model +type WorkflowPlanBase struct { Name string `json:"name"` Alias string `json:"alias"` Description string `json:"description"` diff --git a/pkg/apiserver/rest/usecase/application.go b/pkg/apiserver/rest/usecase/application.go index c39fbe8d7..64a6f4b33 100644 --- a/pkg/apiserver/rest/usecase/application.go +++ b/pkg/apiserver/rest/usecase/application.go @@ -53,22 +53,22 @@ const ( // ApplicationUsecase application usecase type ApplicationUsecase interface { - ListApplications(ctx context.Context, listOptions apisv1.ListApplicatioOptions) ([]*apisv1.ApplicationBase, error) - GetApplication(ctx context.Context, appName string) (*model.Application, error) - DetailApplication(ctx context.Context, app *model.Application) (*apisv1.DetailApplicationResponse, error) - PublishApplicationTemplate(ctx context.Context, app *model.Application) (*apisv1.ApplicationTemplateBase, error) - CreateApplication(context.Context, apisv1.CreateApplicationRequest) (*apisv1.ApplicationBase, error) - DeleteApplication(ctx context.Context, app *model.Application) error - Deploy(ctx context.Context, app *model.Application, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) - ListComponents(ctx context.Context, app *model.Application) ([]*apisv1.ComponentBase, error) - AddComponent(ctx context.Context, app *model.Application, com apisv1.CreateComponentRequest) (*apisv1.ComponentBase, error) - DetailComponent(ctx context.Context, app *model.Application, componentName string) (*apisv1.DetailComponentResponse, error) - DeleteComponent(ctx context.Context, app *model.Application, componentName string) error - ListPolicies(ctx context.Context, app *model.Application) ([]*apisv1.PolicyBase, error) - AddPolicy(ctx context.Context, app *model.Application, policy apisv1.CreatePolicyRequest) (*apisv1.PolicyBase, error) - DetailPolicy(ctx context.Context, app *model.Application, policyName string) (*apisv1.DetailPolicyResponse, error) - DeletePolicy(ctx context.Context, app *model.Application, policyName string) error - UpdatePolicy(ctx context.Context, app *model.Application, policyName string, policy apisv1.UpdatePolicyRequest) (*apisv1.DetailPolicyResponse, error) + ListApplications(ctx context.Context, listOptions apisv1.ListApplicatioPlanOptions) ([]*apisv1.ApplicationPlanBase, error) + GetApplication(ctx context.Context, appName string) (*model.ApplicationPlan, error) + DetailApplication(ctx context.Context, app *model.ApplicationPlan) (*apisv1.DetailApplicationPlanResponse, error) + PublishApplicationTemplate(ctx context.Context, app *model.ApplicationPlan) (*apisv1.ApplicationTemplateBase, error) + CreateApplication(context.Context, apisv1.CreateApplicationPlanRequest) (*apisv1.ApplicationPlanBase, error) + DeleteApplication(ctx context.Context, app *model.ApplicationPlan) error + Deploy(ctx context.Context, app *model.ApplicationPlan, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) + ListComponents(ctx context.Context, app *model.ApplicationPlan) ([]*apisv1.ComponentPlanBase, error) + AddComponent(ctx context.Context, app *model.ApplicationPlan, com apisv1.CreateComponentPlanRequest) (*apisv1.ComponentPlanBase, error) + DetailComponent(ctx context.Context, app *model.ApplicationPlan, componentName string) (*apisv1.DetailComponentPlanResponse, error) + DeleteComponent(ctx context.Context, app *model.ApplicationPlan, componentName string) error + ListPolicies(ctx context.Context, app *model.ApplicationPlan) ([]*apisv1.PolicyBase, error) + AddPolicy(ctx context.Context, app *model.ApplicationPlan, policy apisv1.CreatePolicyRequest) (*apisv1.PolicyBase, error) + DetailPolicy(ctx context.Context, app *model.ApplicationPlan, policyName string) (*apisv1.DetailPolicyResponse, error) + DeletePolicy(ctx context.Context, app *model.ApplicationPlan, policyName string) error + UpdatePolicy(ctx context.Context, app *model.ApplicationPlan, policyName string, policy apisv1.UpdatePolicyRequest) (*apisv1.DetailPolicyResponse, error) } type applicationUsecaseImpl struct { @@ -93,8 +93,8 @@ func NewApplicationUsecase(ds datastore.DataStore, workflowUsecase WorkflowUseca } // ListApplications list applications -func (c *applicationUsecaseImpl) ListApplications(ctx context.Context, listOptions apisv1.ListApplicatioOptions) ([]*apisv1.ApplicationBase, error) { - var app = model.Application{} +func (c *applicationUsecaseImpl) ListApplications(ctx context.Context, listOptions apisv1.ListApplicatioPlanOptions) ([]*apisv1.ApplicationPlanBase, error) { + var app = model.ApplicationPlan{} if listOptions.Namespace != "" { app.Namespace = listOptions.Namespace } @@ -102,9 +102,9 @@ func (c *applicationUsecaseImpl) ListApplications(ctx context.Context, listOptio if err != nil { return nil, err } - var list []*apisv1.ApplicationBase + var list []*apisv1.ApplicationPlanBase for _, entity := range entitys { - appBase := c.converAppModelToBase(ctx, entity.(*model.Application)) + appBase := c.converAppModelToBase(ctx, entity.(*model.ApplicationPlan)) if listOptions.Query != "" && !(strings.Contains(appBase.Alias, listOptions.Query) || strings.Contains(appBase.Name, listOptions.Query) || @@ -120,8 +120,8 @@ func (c *applicationUsecaseImpl) ListApplications(ctx context.Context, listOptio } // GetApplication get application model -func (c *applicationUsecaseImpl) GetApplication(ctx context.Context, appName string) (*model.Application, error) { - var app = model.Application{ +func (c *applicationUsecaseImpl) GetApplication(ctx context.Context, appName string) (*model.ApplicationPlan, error) { + var app = model.ApplicationPlan{ Name: appName, } if err := c.ds.Get(ctx, &app); err != nil { @@ -131,7 +131,7 @@ func (c *applicationUsecaseImpl) GetApplication(ctx context.Context, appName str } // DetailApplication detail application info -func (c *applicationUsecaseImpl) DetailApplication(ctx context.Context, app *model.Application) (*apisv1.DetailApplicationResponse, error) { +func (c *applicationUsecaseImpl) DetailApplication(ctx context.Context, app *model.ApplicationPlan) (*apisv1.DetailApplicationPlanResponse, error) { base := c.converAppModelToBase(ctx, app) policys, err := c.queryApplicationPolicys(ctx, app) if err != nil { @@ -145,9 +145,9 @@ func (c *applicationUsecaseImpl) DetailApplication(ctx context.Context, app *mod for _, p := range policys { policyNames = append(policyNames, p.Name) } - var detail = &apisv1.DetailApplicationResponse{ - ApplicationBase: *base, - Policies: policyNames, + var detail = &apisv1.DetailApplicationPlanResponse{ + ApplicationPlanBase: *base, + Policies: policyNames, ResourceInfo: apisv1.ApplicationResourceInfo{ ComponentNum: len(components), }, @@ -157,14 +157,14 @@ func (c *applicationUsecaseImpl) DetailApplication(ctx context.Context, app *mod } // PublishApplicationTemplate publish app template -func (c *applicationUsecaseImpl) PublishApplicationTemplate(ctx context.Context, app *model.Application) (*apisv1.ApplicationTemplateBase, error) { +func (c *applicationUsecaseImpl) PublishApplicationTemplate(ctx context.Context, app *model.ApplicationPlan) (*apisv1.ApplicationTemplateBase, error) { //TODO: return nil, nil } // CreateApplication create application -func (c *applicationUsecaseImpl) CreateApplication(ctx context.Context, req apisv1.CreateApplicationRequest) (*apisv1.ApplicationBase, error) { - application := model.Application{ +func (c *applicationUsecaseImpl) CreateApplication(ctx context.Context, req apisv1.CreateApplicationPlanRequest) (*apisv1.ApplicationPlanBase, error) { + application := model.ApplicationPlan{ Name: req.Name, Alias: req.Alias, Description: req.Description, @@ -222,7 +222,7 @@ func (c *applicationUsecaseImpl) CreateApplication(ctx context.Context, req apis Outputs: step.Outputs, }) } - _, err := c.workflowUsecase.CreateWorkflow(ctx, &application, apisv1.CreateWorkflowRequest{ + _, err := c.workflowUsecase.CreateWorkflow(ctx, &application, apisv1.CreateWorkflowPlanRequest{ AppName: application.PrimaryKey(), Name: application.Name, Description: "Created automatically.", @@ -240,7 +240,7 @@ func (c *applicationUsecaseImpl) CreateApplication(ctx context.Context, req apis // build-in create env binding policy if len(req.EnvBind) > 0 { - policy := model.ApplicationPolicy{ + policy := model.ApplicationPolicyPlan{ AppPrimaryKey: application.PrimaryKey(), Name: "env-binds", Description: "build-in create", @@ -297,18 +297,18 @@ func (c *applicationUsecaseImpl) CreateApplication(ctx context.Context, req apis return base, nil } -func (c *applicationUsecaseImpl) saveApplicationComponent(ctx context.Context, app *model.Application, components []common.ApplicationComponent) error { +func (c *applicationUsecaseImpl) saveApplicationComponent(ctx context.Context, app *model.ApplicationPlan, components []common.ApplicationComponent) error { var componentModels []datastore.Entity for _, component := range components { // TODO: Check whether the component type is supported. - var traits []model.ApplicationTrait + var traits []model.ApplicationTraitPlan for _, trait := range component.Traits { properties, err := model.NewJSONStruct(trait.Properties) if err != nil { log.Logger.Errorf("parse trait properties failire %w", err) return bcode.ErrInvalidProperties } - traits = append(traits, model.ApplicationTrait{ + traits = append(traits, model.ApplicationTraitPlan{ Type: trait.Type, Properties: properties, }) @@ -318,7 +318,7 @@ func (c *applicationUsecaseImpl) saveApplicationComponent(ctx context.Context, a log.Logger.Errorf("parse component properties failire %w", err) return bcode.ErrInvalidProperties } - componentModel := model.ApplicationComponent{ + componentModel := model.ApplicationComponentPlan{ AppPrimaryKey: app.PrimaryKey(), Name: component.Name, Type: component.Type, @@ -336,18 +336,18 @@ func (c *applicationUsecaseImpl) saveApplicationComponent(ctx context.Context, a return c.ds.BatchAdd(ctx, componentModels) } -func (c *applicationUsecaseImpl) ListComponents(ctx context.Context, app *model.Application) ([]*apisv1.ComponentBase, error) { - var component = model.ApplicationComponent{ +func (c *applicationUsecaseImpl) ListComponents(ctx context.Context, app *model.ApplicationPlan) ([]*apisv1.ComponentPlanBase, error) { + var component = model.ApplicationComponentPlan{ AppPrimaryKey: app.PrimaryKey(), } components, err := c.ds.List(ctx, &component, &datastore.ListOptions{}) if err != nil { return nil, err } - var list []*apisv1.ComponentBase + var list []*apisv1.ComponentPlanBase for _, component := range components { log.Logger.Infof("component name %s", component.PrimaryKey()) - pm := component.(*model.ApplicationComponent) + pm := component.(*model.ApplicationComponentPlan) list = append(list, c.converComponentModelToBase(pm)) } return list, nil @@ -355,8 +355,8 @@ func (c *applicationUsecaseImpl) ListComponents(ctx context.Context, app *model. // DetailComponent detail app component // TODO: Add status data about the component. -func (c *applicationUsecaseImpl) DetailComponent(ctx context.Context, app *model.Application, policyName string) (*apisv1.DetailComponentResponse, error) { - var component = model.ApplicationComponent{ +func (c *applicationUsecaseImpl) DetailComponent(ctx context.Context, app *model.ApplicationPlan, policyName string) (*apisv1.DetailComponentPlanResponse, error) { + var component = model.ApplicationComponentPlan{ AppPrimaryKey: app.PrimaryKey(), Name: policyName, } @@ -364,13 +364,13 @@ func (c *applicationUsecaseImpl) DetailComponent(ctx context.Context, app *model if err != nil { return nil, err } - return &apisv1.DetailComponentResponse{ - ApplicationComponent: component, + return &apisv1.DetailComponentPlanResponse{ + ApplicationComponentPlan: component, }, nil } -func (c *applicationUsecaseImpl) converComponentModelToBase(m *model.ApplicationComponent) *apisv1.ComponentBase { - return &apisv1.ComponentBase{ +func (c *applicationUsecaseImpl) converComponentModelToBase(m *model.ApplicationComponentPlan) *apisv1.ComponentPlanBase { + return &apisv1.ComponentPlanBase{ Name: m.Name, Alias: m.Alias, Description: m.Description, @@ -385,7 +385,7 @@ func (c *applicationUsecaseImpl) converComponentModelToBase(m *model.Application } // ListPolicies list application policies -func (c *applicationUsecaseImpl) ListPolicies(ctx context.Context, app *model.Application) ([]*apisv1.PolicyBase, error) { +func (c *applicationUsecaseImpl) ListPolicies(ctx context.Context, app *model.ApplicationPlan) ([]*apisv1.PolicyBase, error) { policies, err := c.queryApplicationPolicys(ctx, app) if err != nil { return nil, err @@ -397,7 +397,7 @@ func (c *applicationUsecaseImpl) ListPolicies(ctx context.Context, app *model.Ap return list, nil } -func (c *applicationUsecaseImpl) converPolicyModelToBase(policy *model.ApplicationPolicy) *apisv1.PolicyBase { +func (c *applicationUsecaseImpl) converPolicyModelToBase(policy *model.ApplicationPolicyPlan) *apisv1.PolicyBase { pb := &apisv1.PolicyBase{ Name: policy.Name, Type: policy.Type, @@ -410,7 +410,7 @@ func (c *applicationUsecaseImpl) converPolicyModelToBase(policy *model.Applicati return pb } -func (c *applicationUsecaseImpl) saveApplicationPolicy(ctx context.Context, app *model.Application, policys []v1beta1.AppPolicy) error { +func (c *applicationUsecaseImpl) saveApplicationPolicy(ctx context.Context, app *model.ApplicationPlan, policys []v1beta1.AppPolicy) error { var policyModels []datastore.Entity for _, policy := range policys { properties, err := model.NewJSONStruct(policy.Properties) @@ -418,7 +418,7 @@ func (c *applicationUsecaseImpl) saveApplicationPolicy(ctx context.Context, app log.Logger.Errorf("parse trait properties failire %w", err) return bcode.ErrInvalidProperties } - policyModels = append(policyModels, &model.ApplicationPolicy{ + policyModels = append(policyModels, &model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), Name: policy.Name, Type: policy.Type, @@ -428,8 +428,8 @@ func (c *applicationUsecaseImpl) saveApplicationPolicy(ctx context.Context, app return c.ds.BatchAdd(ctx, policyModels) } -func (c *applicationUsecaseImpl) queryApplicationPolicys(ctx context.Context, app *model.Application) (list []*model.ApplicationPolicy, err error) { - var policy = model.ApplicationPolicy{ +func (c *applicationUsecaseImpl) queryApplicationPolicys(ctx context.Context, app *model.ApplicationPlan) (list []*model.ApplicationPolicyPlan, err error) { + var policy = model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), } policys, err := c.ds.List(ctx, &policy, &datastore.ListOptions{}) @@ -437,7 +437,7 @@ func (c *applicationUsecaseImpl) queryApplicationPolicys(ctx context.Context, ap return nil, err } for _, policy := range policys { - pm := policy.(*model.ApplicationPolicy) + pm := policy.(*model.ApplicationPolicyPlan) list = append(list, pm) } return @@ -445,8 +445,8 @@ func (c *applicationUsecaseImpl) queryApplicationPolicys(ctx context.Context, ap // DetailPolicy detail app policy // TODO: Add status data about the policy. -func (c *applicationUsecaseImpl) DetailPolicy(ctx context.Context, app *model.Application, policyName string) (*apisv1.DetailPolicyResponse, error) { - var policy = model.ApplicationPolicy{ +func (c *applicationUsecaseImpl) DetailPolicy(ctx context.Context, app *model.ApplicationPlan, policyName string) (*apisv1.DetailPolicyResponse, error) { + var policy = model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), Name: policyName, } @@ -462,7 +462,7 @@ func (c *applicationUsecaseImpl) DetailPolicy(ctx context.Context, app *model.Ap // Deploy deploy app to cluster // means to render oam application config and apply to cluster. // An event record is generated for each deploy. -func (c *applicationUsecaseImpl) Deploy(ctx context.Context, app *model.Application, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) { +func (c *applicationUsecaseImpl) Deploy(ctx context.Context, app *model.ApplicationPlan, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) { // step1: Render oam application version := utils.GenerateVersion("") oamApp, err := c.renderOAMApplication(ctx, app, req.WorkflowName, version) @@ -536,7 +536,7 @@ func (c *applicationUsecaseImpl) Deploy(ctx context.Context, app *model.Applicat }, nil } -func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMoel *model.Application, reqWorkflowName, version string) (*v1beta1.Application, error) { +func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMoel *model.ApplicationPlan, reqWorkflowName, version string) (*v1beta1.Application, error) { var app = &v1beta1.Application{ TypeMeta: metav1.TypeMeta{ Kind: "Application", @@ -551,7 +551,7 @@ func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMo }, }, } - var component = model.ApplicationComponent{ + var component = model.ApplicationComponentPlan{ AppPrimaryKey: appMoel.PrimaryKey(), } components, err := c.ds.List(ctx, &component, &datastore.ListOptions{}) @@ -562,7 +562,7 @@ func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMo return nil, bcode.ErrNoComponent } - var policy = model.ApplicationPolicy{ + var policy = model.ApplicationPolicyPlan{ AppPrimaryKey: appMoel.PrimaryKey(), } policies, err := c.ds.List(ctx, &policy, &datastore.ListOptions{}) @@ -571,7 +571,7 @@ func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMo } for _, entity := range components { - component := entity.(*model.ApplicationComponent) + component := entity.(*model.ApplicationComponentPlan) var traits []common.ApplicationTrait for _, trait := range component.Traits { aTrait := common.ApplicationTrait{ @@ -595,7 +595,7 @@ func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMo } for _, entity := range policies { - policy := entity.(*model.ApplicationPolicy) + policy := entity.(*model.ApplicationPolicyPlan) apolicy := v1beta1.AppPolicy{ Name: policy.Name, Type: policy.Type, @@ -608,7 +608,7 @@ func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMo // Priority 1 uses the requested workflow as release plan. // Priority 2 uses the default workflow as release plan. - var workflow *model.Workflow + var workflow *model.WorkflowPlan if reqWorkflowName != "" { workflow, err = c.workflowUsecase.GetWorkflow(ctx, reqWorkflowName) if err != nil { @@ -642,8 +642,8 @@ func (c *applicationUsecaseImpl) renderOAMApplication(ctx context.Context, appMo return app, nil } -func (c *applicationUsecaseImpl) converAppModelToBase(ctx context.Context, app *model.Application) *apisv1.ApplicationBase { - appBeas := &apisv1.ApplicationBase{ +func (c *applicationUsecaseImpl) converAppModelToBase(ctx context.Context, app *model.ApplicationPlan) *apisv1.ApplicationPlanBase { + appBeas := &apisv1.ApplicationPlanBase{ Name: app.Name, Alias: app.Alias, Namespace: app.Namespace, @@ -653,7 +653,7 @@ func (c *applicationUsecaseImpl) converAppModelToBase(ctx context.Context, app * Icon: app.Icon, Labels: app.Labels, } - var policy = model.ApplicationPolicy{ + var policy = model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), Type: string(EnvBindPolicy), } @@ -662,7 +662,7 @@ func (c *applicationUsecaseImpl) converAppModelToBase(ctx context.Context, app * log.Logger.Errorf("query application env binding policy failure %s", err.Error()) } for _, policyEntity := range policys { - policy := policyEntity.(*model.ApplicationPolicy) + policy := policyEntity.(*model.ApplicationPolicyPlan) if policy.Properties != nil { var envBindingSpec v1alpha1.EnvBindingSpec if err := json.Unmarshal([]byte(policy.Properties.JSON()), &envBindingSpec); err != nil { @@ -691,7 +691,7 @@ func (c *applicationUsecaseImpl) converAppModelToBase(ctx context.Context, app * } // DeleteApplication delete application -func (c *applicationUsecaseImpl) DeleteApplication(ctx context.Context, app *model.Application) error { +func (c *applicationUsecaseImpl) DeleteApplication(ctx context.Context, app *model.ApplicationPlan) error { // TODO: check app can be deleted // query all components to deleted @@ -710,14 +710,14 @@ func (c *applicationUsecaseImpl) DeleteApplication(ctx context.Context, app *mod } for _, component := range components { - err := c.ds.Delete(ctx, &model.ApplicationComponent{AppPrimaryKey: app.PrimaryKey(), Name: component.Name}) + err := c.ds.Delete(ctx, &model.ApplicationComponentPlan{AppPrimaryKey: app.PrimaryKey(), Name: component.Name}) if err != nil && !errors.Is(err, datastore.ErrRecordNotExist) { log.Logger.Errorf("delete component %s in app %s failure %s", component.Name, app.Name, err.Error()) } } for _, policy := range policies { - err := c.ds.Delete(ctx, &model.ApplicationPolicy{AppPrimaryKey: app.PrimaryKey(), Name: policy.Name}) + err := c.ds.Delete(ctx, &model.ApplicationPolicyPlan{AppPrimaryKey: app.PrimaryKey(), Name: policy.Name}) if err != nil && errors.Is(err, datastore.ErrRecordNotExist) { log.Logger.Errorf("delete policy %s in app %s failure %s", policy.Name, app.Name, err.Error()) } @@ -726,8 +726,8 @@ func (c *applicationUsecaseImpl) DeleteApplication(ctx context.Context, app *mod return c.ds.Delete(ctx, app) } -func (c *applicationUsecaseImpl) AddComponent(ctx context.Context, app *model.Application, com apisv1.CreateComponentRequest) (*apisv1.ComponentBase, error) { - componentModel := model.ApplicationComponent{ +func (c *applicationUsecaseImpl) AddComponent(ctx context.Context, app *model.ApplicationPlan, com apisv1.CreateComponentPlanRequest) (*apisv1.ComponentPlanBase, error) { + componentModel := model.ApplicationComponentPlan{ AppPrimaryKey: app.PrimaryKey(), Description: com.Description, Labels: com.Labels, @@ -751,7 +751,7 @@ func (c *applicationUsecaseImpl) AddComponent(ctx context.Context, app *model.Ap log.Logger.Warnf("add component for app %s failure %s", app.PrimaryKey(), err.Error()) return nil, err } - return &apisv1.ComponentBase{ + return &apisv1.ComponentPlanBase{ Name: componentModel.Name, Description: componentModel.Description, Labels: componentModel.Labels, @@ -764,8 +764,8 @@ func (c *applicationUsecaseImpl) AddComponent(ctx context.Context, app *model.Ap }, nil } -func (c *applicationUsecaseImpl) DeleteComponent(ctx context.Context, app *model.Application, componentName string) error { - var component = model.ApplicationComponent{ +func (c *applicationUsecaseImpl) DeleteComponent(ctx context.Context, app *model.ApplicationPlan, componentName string) error { + var component = model.ApplicationComponentPlan{ AppPrimaryKey: app.PrimaryKey(), Name: componentName, } @@ -779,8 +779,8 @@ func (c *applicationUsecaseImpl) DeleteComponent(ctx context.Context, app *model return nil } -func (c *applicationUsecaseImpl) AddPolicy(ctx context.Context, app *model.Application, createpolicy apisv1.CreatePolicyRequest) (*apisv1.PolicyBase, error) { - policyModel := model.ApplicationPolicy{ +func (c *applicationUsecaseImpl) AddPolicy(ctx context.Context, app *model.ApplicationPlan, createpolicy apisv1.CreatePolicyRequest) (*apisv1.PolicyBase, error) { + policyModel := model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), Description: createpolicy.Description, // TODO: Get user information from ctx and assign a value. @@ -811,8 +811,8 @@ func (c *applicationUsecaseImpl) AddPolicy(ctx context.Context, app *model.Appli }, nil } -func (c *applicationUsecaseImpl) DeletePolicy(ctx context.Context, app *model.Application, policyName string) error { - var policy = model.ApplicationPolicy{ +func (c *applicationUsecaseImpl) DeletePolicy(ctx context.Context, app *model.ApplicationPlan, policyName string) error { + var policy = model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), Name: policyName, } @@ -826,8 +826,8 @@ func (c *applicationUsecaseImpl) DeletePolicy(ctx context.Context, app *model.Ap return nil } -func (c *applicationUsecaseImpl) UpdatePolicy(ctx context.Context, app *model.Application, policyName string, policyUpdate apisv1.UpdatePolicyRequest) (*apisv1.DetailPolicyResponse, error) { - var policy = model.ApplicationPolicy{ +func (c *applicationUsecaseImpl) UpdatePolicy(ctx context.Context, app *model.ApplicationPlan, policyName string, policyUpdate apisv1.UpdatePolicyRequest) (*apisv1.DetailPolicyResponse, error) { + var policy = model.ApplicationPolicyPlan{ AppPrimaryKey: app.PrimaryKey(), Name: policyName, } diff --git a/pkg/apiserver/rest/usecase/application_test.go b/pkg/apiserver/rest/usecase/application_test.go index b1e20e961..3270aec1f 100644 --- a/pkg/apiserver/rest/usecase/application_test.go +++ b/pkg/apiserver/rest/usecase/application_test.go @@ -50,7 +50,7 @@ var _ = Describe("Test application usecase function", func() { }) It("Test CreateApplication function", func() { By("test sample create") - req := v1.CreateApplicationRequest{ + req := v1.CreateApplicationPlanRequest{ Name: "test-app", Namespace: "test-app-namespace", Description: "this is a test app", @@ -66,7 +66,7 @@ var _ = Describe("Test application usecase function", func() { By("test with oam yaml config create") bs, err := ioutil.ReadFile("./testdata/example-app.yaml") Expect(err).Should(Succeed()) - req = v1.CreateApplicationRequest{ + req = v1.CreateApplicationPlanRequest{ Name: "test-app-sadasd", Namespace: "test-app-namespace", Description: "this is a test app", @@ -78,7 +78,7 @@ var _ = Describe("Test application usecase function", func() { Expect(err).Should(BeNil()) Expect(cmp.Diff(base.Description, req.Description)).Should(BeEmpty()) - req = v1.CreateApplicationRequest{ + req = v1.CreateApplicationPlanRequest{ Name: "test-app-sadasd2", Namespace: "test-app-namespace", Description: "this is a test app", @@ -93,7 +93,7 @@ var _ = Describe("Test application usecase function", func() { bs, err = ioutil.ReadFile("./testdata/example-app-error.yaml") Expect(err).Should(Succeed()) - req = v1.CreateApplicationRequest{ + req = v1.CreateApplicationPlanRequest{ Name: "test-app-sadasd3", Namespace: "test-app-namespace", Description: "this is a test app", @@ -106,7 +106,7 @@ var _ = Describe("Test application usecase function", func() { Expect(equal).Should(BeTrue()) By("Test create app with env binding") - req = v1.CreateApplicationRequest{ + req = v1.CreateApplicationPlanRequest{ Name: "test-app-sadasd4", Namespace: "test-app-namespace", Description: "this is a test app", @@ -140,7 +140,7 @@ var _ = Describe("Test application usecase function", func() { }) It("Test ListApplications function", func() { - apps, err := appUsecase.ListApplications(context.TODO(), v1.ListApplicatioOptions{}) + apps, err := appUsecase.ListApplications(context.TODO(), v1.ListApplicatioPlanOptions{}) Expect(err).Should(BeNil()) Expect(cmp.Diff(len(apps), 3)).Should(BeEmpty()) }) @@ -217,7 +217,7 @@ var _ = Describe("Test application usecase function", func() { appModel, err := appUsecase.GetApplication(context.TODO(), "test-app-sadasd") Expect(err).Should(BeNil()) Expect(cmp.Diff(appModel.Namespace, "test-app-namespace")).Should(BeEmpty()) - base, err := appUsecase.AddComponent(context.TODO(), appModel, v1.CreateComponentRequest{ + base, err := appUsecase.AddComponent(context.TODO(), appModel, v1.CreateComponentPlanRequest{ Name: "test2", Description: "this is a test2 component", Labels: map[string]string{}, diff --git a/pkg/apiserver/rest/usecase/workflow.go b/pkg/apiserver/rest/usecase/workflow.go index 7df6b40fa..9a228bac5 100644 --- a/pkg/apiserver/rest/usecase/workflow.go +++ b/pkg/apiserver/rest/usecase/workflow.go @@ -35,13 +35,13 @@ import ( // WorkflowUsecase workflow manage api type WorkflowUsecase interface { - ListApplicationWorkflow(ctx context.Context, app *model.Application, enable *bool) ([]*apisv1.WorkflowBase, error) - GetWorkflow(ctx context.Context, workflowName string) (*model.Workflow, error) - DetailWorkflow(ctx context.Context, workflow *model.Workflow) (*apisv1.DetailWorkflowResponse, error) - GetApplicationDefaultWorkflow(ctx context.Context, app *model.Application) (*model.Workflow, error) + ListApplicationWorkflow(ctx context.Context, app *model.ApplicationPlan, enable *bool) ([]*apisv1.WorkflowPlanBase, error) + GetWorkflow(ctx context.Context, workflowName string) (*model.WorkflowPlan, error) + DetailWorkflow(ctx context.Context, workflow *model.WorkflowPlan) (*apisv1.DetailWorkflowPlanResponse, error) + GetApplicationDefaultWorkflow(ctx context.Context, app *model.ApplicationPlan) (*model.WorkflowPlan, error) DeleteWorkflow(ctx context.Context, workflowName string) error - CreateWorkflow(ctx context.Context, app *model.Application, req apisv1.CreateWorkflowRequest) (*apisv1.DetailWorkflowResponse, error) - UpdateWorkflow(ctx context.Context, workflow *model.Workflow, req apisv1.UpdateWorkflowRequest) (*apisv1.DetailWorkflowResponse, error) + CreateWorkflow(ctx context.Context, app *model.ApplicationPlan, req apisv1.CreateWorkflowPlanRequest) (*apisv1.DetailWorkflowPlanResponse, error) + UpdateWorkflow(ctx context.Context, workflow *model.WorkflowPlan, req apisv1.UpdateWorkflowPlanRequest) (*apisv1.DetailWorkflowPlanResponse, error) ListWorkflowRecords(ctx context.Context, workflowName string, page, pageSize int) (*apisv1.ListWorkflowRecordsResponse, error) DetailWorkflowRecord(ctx context.Context, workflowName, recordName string) (*apisv1.DetailWorkflowRecordResponse, error) } @@ -57,7 +57,7 @@ type workflowUsecaseImpl struct { // DeleteWorkflow delete application workflow func (w *workflowUsecaseImpl) DeleteWorkflow(ctx context.Context, workflowName string) error { - var workflow = &model.Workflow{ + var workflow = &model.WorkflowPlan{ Name: workflowName, } if err := w.ds.Delete(ctx, workflow); err != nil { @@ -69,7 +69,7 @@ func (w *workflowUsecaseImpl) DeleteWorkflow(ctx context.Context, workflowName s return nil } -func (w *workflowUsecaseImpl) CreateWorkflow(ctx context.Context, app *model.Application, req apisv1.CreateWorkflowRequest) (*apisv1.DetailWorkflowResponse, error) { +func (w *workflowUsecaseImpl) CreateWorkflow(ctx context.Context, app *model.ApplicationPlan, req apisv1.CreateWorkflowPlanRequest) (*apisv1.DetailWorkflowPlanResponse, error) { var steps []model.WorkflowStep for _, step := range req.Steps { properties, err := model.NewJSONStructByString(step.Properties) @@ -86,7 +86,7 @@ func (w *workflowUsecaseImpl) CreateWorkflow(ctx context.Context, app *model.App }) } // It is allowed to set multiple workflows as default, and only one takes effect. - var workflow = model.Workflow{ + var workflow = model.WorkflowPlan{ Steps: steps, Name: req.Name, Enable: req.Enable, @@ -100,7 +100,7 @@ func (w *workflowUsecaseImpl) CreateWorkflow(ctx context.Context, app *model.App return w.DetailWorkflow(ctx, &workflow) } -func (w *workflowUsecaseImpl) UpdateWorkflow(ctx context.Context, workflow *model.Workflow, req apisv1.UpdateWorkflowRequest) (*apisv1.DetailWorkflowResponse, error) { +func (w *workflowUsecaseImpl) UpdateWorkflow(ctx context.Context, workflow *model.WorkflowPlan, req apisv1.UpdateWorkflowPlanRequest) (*apisv1.DetailWorkflowPlanResponse, error) { var steps []model.WorkflowStep for _, step := range req.Steps { properties, err := model.NewJSONStructByString(step.Properties) @@ -128,7 +128,7 @@ func (w *workflowUsecaseImpl) UpdateWorkflow(ctx context.Context, workflow *mode } // DetailWorkflow detail workflow -func (w *workflowUsecaseImpl) DetailWorkflow(ctx context.Context, workflow *model.Workflow) (*apisv1.DetailWorkflowResponse, error) { +func (w *workflowUsecaseImpl) DetailWorkflow(ctx context.Context, workflow *model.WorkflowPlan) (*apisv1.DetailWorkflowPlanResponse, error) { var steps []apisv1.WorkflowStep for _, step := range workflow.Steps { apiStep := apisv1.WorkflowStep{ @@ -143,8 +143,8 @@ func (w *workflowUsecaseImpl) DetailWorkflow(ctx context.Context, workflow *mode } steps = append(steps, apiStep) } - return &apisv1.DetailWorkflowResponse{ - WorkflowBase: apisv1.WorkflowBase{ + return &apisv1.DetailWorkflowPlanResponse{ + WorkflowPlanBase: apisv1.WorkflowPlanBase{ Name: workflow.Name, Description: workflow.Description, Enable: workflow.Enable, @@ -157,8 +157,8 @@ func (w *workflowUsecaseImpl) DetailWorkflow(ctx context.Context, workflow *mode } // GetWorkflow get workflow model -func (w *workflowUsecaseImpl) GetWorkflow(ctx context.Context, workflowName string) (*model.Workflow, error) { - var workflow = model.Workflow{ +func (w *workflowUsecaseImpl) GetWorkflow(ctx context.Context, workflowName string) (*model.WorkflowPlan, error) { + var workflow = model.WorkflowPlan{ Name: workflowName, } if err := w.ds.Get(ctx, &workflow); err != nil { @@ -168,8 +168,8 @@ func (w *workflowUsecaseImpl) GetWorkflow(ctx context.Context, workflowName stri } // ListApplicationWorkflow list application workflows -func (w *workflowUsecaseImpl) ListApplicationWorkflow(ctx context.Context, app *model.Application, enable *bool) ([]*apisv1.WorkflowBase, error) { - var workflow = model.Workflow{ +func (w *workflowUsecaseImpl) ListApplicationWorkflow(ctx context.Context, app *model.ApplicationPlan, enable *bool) ([]*apisv1.WorkflowPlanBase, error) { + var workflow = model.WorkflowPlan{ AppPrimaryKey: app.PrimaryKey(), } if enable != nil { @@ -179,10 +179,10 @@ func (w *workflowUsecaseImpl) ListApplicationWorkflow(ctx context.Context, app * if err != nil { return nil, err } - var list []*apisv1.WorkflowBase + var list []*apisv1.WorkflowPlanBase for _, workflow := range workflows { - wm := workflow.(*model.Workflow) - list = append(list, &apisv1.WorkflowBase{ + wm := workflow.(*model.WorkflowPlan) + list = append(list, &apisv1.WorkflowPlanBase{ Name: wm.Name, Description: wm.Description, Enable: wm.Enable, @@ -195,8 +195,8 @@ func (w *workflowUsecaseImpl) ListApplicationWorkflow(ctx context.Context, app * } // GetApplicationDefaultWorkflow get application default workflow -func (w *workflowUsecaseImpl) GetApplicationDefaultWorkflow(ctx context.Context, app *model.Application) (*model.Workflow, error) { - var workflow = model.Workflow{ +func (w *workflowUsecaseImpl) GetApplicationDefaultWorkflow(ctx context.Context, app *model.ApplicationPlan) (*model.WorkflowPlan, error) { + var workflow = model.WorkflowPlan{ AppPrimaryKey: app.PrimaryKey(), Default: true, } @@ -205,7 +205,7 @@ func (w *workflowUsecaseImpl) GetApplicationDefaultWorkflow(ctx context.Context, return nil, err } if len(workflows) > 0 { - return workflows[0].(*model.Workflow), nil + return workflows[0].(*model.WorkflowPlan), nil } return nil, bcode.ErrWorkflowNoDefault } diff --git a/pkg/apiserver/rest/usecase/workflow_test.go b/pkg/apiserver/rest/usecase/workflow_test.go index 37c36a491..9477d2f77 100644 --- a/pkg/apiserver/rest/usecase/workflow_test.go +++ b/pkg/apiserver/rest/usecase/workflow_test.go @@ -40,22 +40,22 @@ var _ = Describe("Test workflow usecase functions", func() { workflowUsecase = &workflowUsecaseImpl{ds: ds} }) It("Test CreateWorkflow function", func() { - req := apisv1.CreateWorkflowRequest{ + req := apisv1.CreateWorkflowPlanRequest{ Name: "test-workflow-1", Description: "this is a workflow", } - base, err := workflowUsecase.CreateWorkflow(context.TODO(), &model.Application{ + base, err := workflowUsecase.CreateWorkflow(context.TODO(), &model.ApplicationPlan{ Name: "test-app", }, req) Expect(err).Should(BeNil()) Expect(cmp.Diff(base.Name, req.Name)).Should(BeEmpty()) - req = apisv1.CreateWorkflowRequest{ + req = apisv1.CreateWorkflowPlanRequest{ Name: "test-workflow-2", Description: "this is test workflow", Default: true, } - base, err = workflowUsecase.CreateWorkflow(context.TODO(), &model.Application{ + base, err = workflowUsecase.CreateWorkflow(context.TODO(), &model.ApplicationPlan{ Name: "test-app", }, req) Expect(err).Should(BeNil()) @@ -63,7 +63,7 @@ var _ = Describe("Test workflow usecase functions", func() { }) It("Test GetApplicationDefaultWorkflow function", func() { - workflow, err := workflowUsecase.GetApplicationDefaultWorkflow(context.TODO(), &model.Application{ + workflow, err := workflowUsecase.GetApplicationDefaultWorkflow(context.TODO(), &model.ApplicationPlan{ Name: "test-app", }) Expect(err).Should(BeNil()) diff --git a/pkg/apiserver/rest/webservice/application.go b/pkg/apiserver/rest/webservice/application.go index 77d06273b..b23f15da5 100644 --- a/pkg/apiserver/rest/webservice/application.go +++ b/pkg/apiserver/rest/webservice/application.go @@ -42,7 +42,7 @@ func NewApplicationWebService(applicationUsecase usecase.ApplicationUsecase) Web func (c *applicationWebService) GetWebService() *restful.WebService { ws := new(restful.WebService) - ws.Path(versionPrefix+"/applications"). + ws.Path(versionPrefix+"/applicationplans"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML). Doc("api for application manage") @@ -55,17 +55,17 @@ func (c *applicationWebService) GetWebService() *restful.WebService { Param(ws.QueryParameter("query", "Fuzzy search based on name or description").DataType("string")). Param(ws.QueryParameter("namespace", "Namespace-based search").DataType("string")). Param(ws.QueryParameter("cluster", "Cluster-based search").DataType("string")). - Returns(200, "", apis.ListApplicationResponse{}). + Returns(200, "", apis.ListApplicationPlanResponse{}). Returns(400, "", bcode.Bcode{}). - Writes(apis.ListApplicationResponse{})) + Writes(apis.ListApplicationPlanResponse{})) ws.Route(ws.POST("/").To(c.createApplication). Doc("create one application"). Metadata(restfulspec.KeyOpenAPITags, tags). - Reads(apis.CreateApplicationRequest{}). - Returns(200, "", apis.ApplicationBase{}). + Reads(apis.CreateApplicationPlanRequest{}). + Returns(200, "", apis.ApplicationPlanBase{}). Returns(400, "", bcode.Bcode{}). - Writes(apis.ApplicationBase{})) + Writes(apis.ApplicationPlanBase{})) ws.Route(ws.DELETE("/{name}").To(c.deleteApplication). Doc("delete one application"). @@ -81,9 +81,9 @@ func (c *applicationWebService) GetWebService() *restful.WebService { Metadata(restfulspec.KeyOpenAPITags, tags). Filter(c.appCheckFilter). Param(ws.PathParameter("name", "identifier of the application").DataType("string")). - Returns(200, "", apis.DetailApplicationResponse{}). + Returns(200, "", apis.DetailApplicationPlanResponse{}). Returns(400, "", bcode.Bcode{}). - Writes(apis.DetailApplicationResponse{})) + Writes(apis.DetailApplicationPlanResponse{})) ws.Route(ws.POST("/{name}/template").To(c.publishApplicationTemplate). Doc("create one application template"). @@ -104,34 +104,34 @@ func (c *applicationWebService) GetWebService() *restful.WebService { Returns(400, "", bcode.Bcode{}). Writes(apis.ApplicationDeployResponse{})) - ws.Route(ws.GET("/{name}/components").To(c.listApplicationComponents). - Doc("gets the component topology of the application"). + ws.Route(ws.GET("/{name}/componentplans").To(c.listApplicationComponents). + Doc("gets the componentplan topology of the application"). Filter(c.appCheckFilter). Param(ws.PathParameter("name", "identifier of the application").DataType("string")). - Param(ws.PathParameter("cluster", "list components that deployed in define cluster").DataType("string")). + Param(ws.QueryParameter("envName", "list components that deployed in define env").DataType("string")). Metadata(restfulspec.KeyOpenAPITags, tags). - Returns(200, "", apis.ComponentListResponse{}). + Returns(200, "", apis.ComponentPlanListResponse{}). Returns(400, "", bcode.Bcode{}). - Writes(apis.ComponentListResponse{})) + Writes(apis.ComponentPlanListResponse{})) - ws.Route(ws.POST("/{name}/components").To(c.createComponent). - Doc("create component for application"). + ws.Route(ws.POST("/{name}/componentplans").To(c.createComponent). + Doc("create component plan for application plan"). Filter(c.appCheckFilter). Param(ws.PathParameter("name", "identifier of the application").DataType("string")). Metadata(restfulspec.KeyOpenAPITags, tags). - Reads(apis.CreateComponentRequest{}). - Returns(200, "", apis.ComponentBase{}). + Reads(apis.CreateComponentPlanRequest{}). + Returns(200, "", apis.ComponentPlanBase{}). Returns(400, "", bcode.Bcode{}). - Writes(apis.ComponentBase{})) + Writes(apis.ComponentPlanBase{})) - ws.Route(ws.GET("/{name}/components/{componentName}").To(c.detailComponent). - Doc("detail component for application"). + ws.Route(ws.GET("/{name}/componentplans/{componentName}").To(c.detailComponent). + Doc("detail component plan for application plan"). Filter(c.appCheckFilter). Param(ws.PathParameter("name", "identifier of the application").DataType("string")). Metadata(restfulspec.KeyOpenAPITags, tags). - Returns(200, "", apis.DetailComponentResponse{}). + Returns(200, "", apis.DetailComponentPlanResponse{}). Returns(400, "", bcode.Bcode{}). - Writes(apis.DetailComponentResponse{})) + Writes(apis.DetailComponentPlanResponse{})) ws.Route(ws.GET("/{name}/policies").To(c.listApplicationPolicies). Doc("list policy for application"). @@ -197,7 +197,7 @@ func (c *applicationWebService) appCheckFilter(req *restful.Request, res *restfu func (c *applicationWebService) createApplication(req *restful.Request, res *restful.Response) { // Verify the validity of parameters - var createReq apis.CreateApplicationRequest + var createReq apis.CreateApplicationPlanRequest if err := req.ReadEntity(&createReq); err != nil { bcode.ReturnError(req, res, err) return @@ -222,7 +222,7 @@ func (c *applicationWebService) createApplication(req *restful.Request, res *res } func (c *applicationWebService) listApplications(req *restful.Request, res *restful.Response) { - apps, err := c.applicationUsecase.ListApplications(req.Request.Context(), apis.ListApplicatioOptions{ + apps, err := c.applicationUsecase.ListApplications(req.Request.Context(), apis.ListApplicatioPlanOptions{ Namespace: req.QueryParameter("namespace"), Cluster: req.QueryParameter("cluster"), Query: req.QueryParameter("query"), @@ -231,14 +231,14 @@ func (c *applicationWebService) listApplications(req *restful.Request, res *rest bcode.ReturnError(req, res, err) return } - if err := res.WriteEntity(apis.ListApplicationResponse{Applications: apps}); err != nil { + if err := res.WriteEntity(apis.ListApplicationPlanResponse{ApplicationPlans: apps}); err != nil { bcode.ReturnError(req, res, err) return } } func (c *applicationWebService) detailApplication(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) detail, err := c.applicationUsecase.DetailApplication(req.Request.Context(), app) if err != nil { bcode.ReturnError(req, res, err) @@ -251,7 +251,7 @@ func (c *applicationWebService) detailApplication(req *restful.Request, res *res } func (c *applicationWebService) publishApplicationTemplate(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) base, err := c.applicationUsecase.PublishApplicationTemplate(req.Request.Context(), app) if err != nil { bcode.ReturnError(req, res, err) @@ -265,7 +265,7 @@ func (c *applicationWebService) publishApplicationTemplate(req *restful.Request, // deployApplication TODO: return event model func (c *applicationWebService) deployApplication(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) // Verify the validity of parameters var createReq apis.ApplicationDeployRequest if err := req.ReadEntity(&createReq); err != nil { @@ -288,7 +288,7 @@ func (c *applicationWebService) deployApplication(req *restful.Request, res *res } func (c *applicationWebService) deleteApplication(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) err := c.applicationUsecase.DeleteApplication(req.Request.Context(), app) if err != nil { bcode.ReturnError(req, res, err) @@ -301,22 +301,22 @@ func (c *applicationWebService) deleteApplication(req *restful.Request, res *res } func (c *applicationWebService) listApplicationComponents(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) components, err := c.applicationUsecase.ListComponents(req.Request.Context(), app) if err != nil { bcode.ReturnError(req, res, err) return } - if err := res.WriteEntity(apis.ComponentListResponse{Components: components}); err != nil { + if err := res.WriteEntity(apis.ComponentPlanListResponse{ComponentPlans: components}); err != nil { bcode.ReturnError(req, res, err) return } } func (c *applicationWebService) createComponent(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) // Verify the validity of parameters - var createReq apis.CreateComponentRequest + var createReq apis.CreateComponentPlanRequest if err := req.ReadEntity(&createReq); err != nil { bcode.ReturnError(req, res, err) return @@ -337,7 +337,7 @@ func (c *applicationWebService) createComponent(req *restful.Request, res *restf } func (c *applicationWebService) detailComponent(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) detail, err := c.applicationUsecase.DetailComponent(req.Request.Context(), app, req.PathParameter("componentName")) if err != nil { bcode.ReturnError(req, res, err) @@ -350,7 +350,7 @@ func (c *applicationWebService) detailComponent(req *restful.Request, res *restf } func (c *applicationWebService) createApplicationPolicy(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) // Verify the validity of parameters var createReq apis.CreatePolicyRequest if err := req.ReadEntity(&createReq); err != nil { @@ -373,7 +373,7 @@ func (c *applicationWebService) createApplicationPolicy(req *restful.Request, re } func (c *applicationWebService) listApplicationPolicies(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) policies, err := c.applicationUsecase.ListPolicies(req.Request.Context(), app) if err != nil { bcode.ReturnError(req, res, err) @@ -386,7 +386,7 @@ func (c *applicationWebService) listApplicationPolicies(req *restful.Request, re } func (c *applicationWebService) detailApplicationPolicy(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) detail, err := c.applicationUsecase.DetailPolicy(req.Request.Context(), app, req.PathParameter("policyName")) if err != nil { bcode.ReturnError(req, res, err) @@ -399,7 +399,7 @@ func (c *applicationWebService) detailApplicationPolicy(req *restful.Request, re } func (c *applicationWebService) deleteApplicationPolicy(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) err := c.applicationUsecase.DeletePolicy(req.Request.Context(), app, req.PathParameter("policyName")) if err != nil { bcode.ReturnError(req, res, err) @@ -412,7 +412,7 @@ func (c *applicationWebService) deleteApplicationPolicy(req *restful.Request, re } func (c *applicationWebService) updateApplicationPolicy(req *restful.Request, res *restful.Response) { - app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.Application) + app := req.Request.Context().Value(&apis.CtxKeyApplication).(*model.ApplicationPlan) // Verify the validity of parameters var updateReq apis.UpdatePolicyRequest if err := req.ReadEntity(&updateReq); err != nil { diff --git a/pkg/apiserver/rest/webservice/validate_test.go b/pkg/apiserver/rest/webservice/validate_test.go index 7b71fab51..1113e6b5e 100644 --- a/pkg/apiserver/rest/webservice/validate_test.go +++ b/pkg/apiserver/rest/webservice/validate_test.go @@ -27,26 +27,26 @@ import ( var _ = Describe("Test validate function", func() { It("Test check name validate ", func() { Expect(cmp.Diff(nameRegexp.MatchString("///Asd asda "), false)).Should(BeEmpty()) - var app0 = apisv1.CreateApplicationRequest{ + var app0 = apisv1.CreateApplicationPlanRequest{ Name: "a", Namespace: "namespace", } err := validate.Struct(&app0) Expect(err).ShouldNot(BeNil()) - var app1 = apisv1.CreateApplicationRequest{ + var app1 = apisv1.CreateApplicationPlanRequest{ Name: "Asdasd", Namespace: "namespace", } err = validate.Struct(&app1) Expect(err).ShouldNot(BeNil()) - var app2 = apisv1.CreateApplicationRequest{ + var app2 = apisv1.CreateApplicationPlanRequest{ Name: "asdasd asdasd ++", Namespace: "namespace", } err = validate.Struct(&app2) Expect(err).ShouldNot(BeNil()) - var app3 = apisv1.CreateApplicationRequest{ + var app3 = apisv1.CreateApplicationPlanRequest{ Name: "asdasd", Namespace: "namespace", } diff --git a/pkg/apiserver/rest/webservice/workflow.go b/pkg/apiserver/rest/webservice/workflow.go index 1f9e4718f..30bcedd26 100644 --- a/pkg/apiserver/rest/webservice/workflow.go +++ b/pkg/apiserver/rest/webservice/workflow.go @@ -46,7 +46,7 @@ type workflowWebService struct { func (w *workflowWebService) GetWebService() *restful.WebService { ws := new(restful.WebService) - ws.Path(versionPrefix+"/workflows"). + ws.Path(versionPrefix+"/workflowplans"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML). Doc("api for cluster manage") @@ -58,31 +58,31 @@ func (w *workflowWebService) GetWebService() *restful.WebService { Param(ws.QueryParameter("appName", "identifier of the application.").DataType("string")). Param(ws.QueryParameter("enable", "query based on enable status").DataType("boolean")). Metadata(restfulspec.KeyOpenAPITags, tags). - Writes(apis.ListWorkflowResponse{}).Do(returns200, returns500)) + Writes(apis.ListWorkflowPlanResponse{}).Do(returns200, returns500)) ws.Route(ws.POST("/").To(w.createApplicationWorkflow). Doc("create application workflow"). Metadata(restfulspec.KeyOpenAPITags, tags). - Reads(apis.CreateWorkflowRequest{}). - Returns(200, "create success", apis.DetailWorkflowResponse{}). + Reads(apis.CreateWorkflowPlanRequest{}). + Returns(200, "create success", apis.DetailWorkflowPlanResponse{}). Returns(400, "create failure", bcode.Bcode{}). - Writes(apis.DetailWorkflowResponse{}).Do(returns200, returns500)) + Writes(apis.DetailWorkflowPlanResponse{}).Do(returns200, returns500)) ws.Route(ws.GET("/{name}").To(w.detailWorkflow). Doc("detail application workflow"). Param(ws.PathParameter("name", "identifier of the workflow.").DataType("string")). Metadata(restfulspec.KeyOpenAPITags, tags). Filter(w.workflowCheckFilter). - Returns(200, "create success", apis.DetailWorkflowResponse{}). - Writes(apis.DetailWorkflowResponse{}).Do(returns200, returns500)) + Returns(200, "create success", apis.DetailWorkflowPlanResponse{}). + Writes(apis.DetailWorkflowPlanResponse{}).Do(returns200, returns500)) ws.Route(ws.PUT("/{name}").To(w.updateWorkflow). Doc("update application workflow config"). Metadata(restfulspec.KeyOpenAPITags, tags). Filter(w.workflowCheckFilter). Param(ws.PathParameter("name", "identifier of the workflow").DataType("string")). - Reads(apis.UpdateWorkflowRequest{}). - Writes(apis.DetailWorkflowResponse{}).Do(returns200, returns500)) + Reads(apis.UpdateWorkflowPlanRequest{}). + Writes(apis.DetailWorkflowPlanResponse{}).Do(returns200, returns500)) ws.Route(ws.DELETE("/{name}").To(w.deleteWorkflow). Doc("deletet workflow"). @@ -140,7 +140,7 @@ func (w *workflowWebService) listApplicationWorkflows(req *restful.Request, res bcode.ReturnError(req, res, err) return } - if err := res.WriteEntity(apis.ListWorkflowResponse{Workflows: workflows}); err != nil { + if err := res.WriteEntity(apis.ListWorkflowPlanResponse{WorkflowPlans: workflows}); err != nil { bcode.ReturnError(req, res, err) return } @@ -148,7 +148,7 @@ func (w *workflowWebService) listApplicationWorkflows(req *restful.Request, res func (w *workflowWebService) createApplicationWorkflow(req *restful.Request, res *restful.Response) { // Verify the validity of parameters - var createReq apis.CreateWorkflowRequest + var createReq apis.CreateWorkflowPlanRequest if err := req.ReadEntity(&createReq); err != nil { bcode.ReturnError(req, res, err) return @@ -178,7 +178,7 @@ func (w *workflowWebService) createApplicationWorkflow(req *restful.Request, res } func (w *workflowWebService) detailWorkflow(req *restful.Request, res *restful.Response) { - workflow := req.Request.Context().Value(&apis.CtxKeyWorkflow).(*model.Workflow) + workflow := req.Request.Context().Value(&apis.CtxKeyWorkflow).(*model.WorkflowPlan) detail, err := w.workflowUsecase.DetailWorkflow(req.Request.Context(), workflow) if err != nil { bcode.ReturnError(req, res, err) @@ -191,9 +191,9 @@ func (w *workflowWebService) detailWorkflow(req *restful.Request, res *restful.R } func (w *workflowWebService) updateWorkflow(req *restful.Request, res *restful.Response) { - workflow := req.Request.Context().Value(&apis.CtxKeyWorkflow).(*model.Workflow) + workflow := req.Request.Context().Value(&apis.CtxKeyWorkflow).(*model.WorkflowPlan) // Verify the validity of parameters - var updateReq apis.UpdateWorkflowRequest + var updateReq apis.UpdateWorkflowPlanRequest if err := req.ReadEntity(&updateReq); err != nil { bcode.ReturnError(req, res, err) return diff --git a/test/e2e-apiserver-test/application_test.go b/test/e2e-apiserver-test/application_test.go index ab335074a..5bf6b078b 100644 --- a/test/e2e-apiserver-test/application_test.go +++ b/test/e2e-apiserver-test/application_test.go @@ -36,7 +36,7 @@ import ( var _ = Describe("Test application rest api", func() { It("Test create app", func() { defer GinkgoRecover() - var req = apisv1.CreateApplicationRequest{ + var req = apisv1.CreateApplicationPlanRequest{ Name: "test-app-sadasd", Namespace: "test-app-namespace", Description: "this is a test app", @@ -48,13 +48,13 @@ var _ = Describe("Test application rest api", func() { } bodyByte, err := json.Marshal(req) Expect(err).ShouldNot(HaveOccurred()) - res, err := http.Post("http://127.0.0.1:8000/api/v1/applications", "application/json", bytes.NewBuffer(bodyByte)) + res, err := http.Post("http://127.0.0.1:8000/api/v1/applicationplans", "application/json", bytes.NewBuffer(bodyByte)) Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) Expect(res.Body).ShouldNot(BeNil()) defer res.Body.Close() - var appBase apisv1.ApplicationBase + var appBase apisv1.ApplicationPlanBase err = json.NewDecoder(res.Body).Decode(&appBase) Expect(err).ShouldNot(HaveOccurred()) Expect(cmp.Diff(appBase.Name, req.Name)).Should(BeEmpty()) @@ -66,7 +66,7 @@ var _ = Describe("Test application rest api", func() { It("Test delete app", func() { defer GinkgoRecover() - req, err := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8000/api/v1/applications/test-app-sadasd", nil) + req, err := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd", nil) Expect(err).ShouldNot(HaveOccurred()) res, err := http.DefaultClient.Do(req) Expect(err).ShouldNot(HaveOccurred()) @@ -78,7 +78,7 @@ var _ = Describe("Test application rest api", func() { defer GinkgoRecover() bs, err := ioutil.ReadFile("./testdata/example-app.yaml") Expect(err).Should(Succeed()) - var req = apisv1.CreateApplicationRequest{ + var req = apisv1.CreateApplicationPlanRequest{ Name: "test-app-sadasd", Namespace: "test-app-namespace", Description: "this is a test app", @@ -88,13 +88,13 @@ var _ = Describe("Test application rest api", func() { } bodyByte, err := json.Marshal(req) Expect(err).ShouldNot(HaveOccurred()) - res, err := http.Post("http://127.0.0.1:8000/api/v1/applications", "application/json", bytes.NewBuffer(bodyByte)) + res, err := http.Post("http://127.0.0.1:8000/api/v1/applicationplans", "application/json", bytes.NewBuffer(bodyByte)) Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) Expect(res.Body).ShouldNot(BeNil()) defer res.Body.Close() - var appBase apisv1.ApplicationBase + var appBase apisv1.ApplicationPlanBase err = json.NewDecoder(res.Body).Decode(&appBase) Expect(err).ShouldNot(HaveOccurred()) Expect(cmp.Diff(appBase.Name, req.Name)).Should(BeEmpty()) @@ -105,21 +105,21 @@ var _ = Describe("Test application rest api", func() { It("Test list components", func() { defer GinkgoRecover() - res, err := http.Get("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/components") + res, err := http.Get("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/componentplans") Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) Expect(res.Body).ShouldNot(BeNil()) defer res.Body.Close() - var components apisv1.ComponentListResponse + var components apisv1.ComponentPlanListResponse err = json.NewDecoder(res.Body).Decode(&components) Expect(err).ShouldNot(HaveOccurred()) - Expect(cmp.Diff(len(components.Components), 2)).Should(BeEmpty()) + Expect(cmp.Diff(len(components.ComponentPlans), 2)).Should(BeEmpty()) }) It("Test list policies", func() { defer GinkgoRecover() - res, err := http.Get("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies") + res, err := http.Get("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies") Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) @@ -133,7 +133,7 @@ var _ = Describe("Test application rest api", func() { It("Test get workflow", func() { // defer GinkgoRecover() - // res, err := http.Get("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies") + // res, err := http.Get("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies") // Expect(err).ShouldNot(HaveOccurred()) // Expect(res).ShouldNot(BeNil()) // Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) @@ -147,13 +147,13 @@ var _ = Describe("Test application rest api", func() { It("Test detail application", func() { defer GinkgoRecover() - res, err := http.Get("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd") + res, err := http.Get("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd") Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) Expect(res.Body).ShouldNot(BeNil()) defer res.Body.Close() - var detail apisv1.DetailApplicationResponse + var detail apisv1.DetailApplicationPlanResponse err = json.NewDecoder(res.Body).Decode(&detail) Expect(err).ShouldNot(HaveOccurred()) Expect(cmp.Diff(len(detail.Policies), 1)).Should(BeEmpty()) @@ -168,7 +168,7 @@ var _ = Describe("Test application rest api", func() { } bodyByte, err := json.Marshal(req) Expect(err).ShouldNot(HaveOccurred()) - res, err := http.Post("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/deploy", "application/json", bytes.NewBuffer(bodyByte)) + res, err := http.Post("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/deploy", "application/json", bytes.NewBuffer(bodyByte)) Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) @@ -188,7 +188,7 @@ var _ = Describe("Test application rest api", func() { It("Test create component", func() { defer GinkgoRecover() - var req = apisv1.CreateComponentRequest{ + var req = apisv1.CreateComponentPlanRequest{ Name: "test2", Description: "this is a test2 component", Labels: map[string]string{}, @@ -198,13 +198,13 @@ var _ = Describe("Test application rest api", func() { } bodyByte, err := json.Marshal(req) Expect(err).ShouldNot(HaveOccurred()) - res, err := http.Post("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/components", "application/json", bytes.NewBuffer(bodyByte)) + res, err := http.Post("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/componentplans", "application/json", bytes.NewBuffer(bodyByte)) Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) Expect(res.Body).ShouldNot(BeNil()) defer res.Body.Close() - var response apisv1.ComponentBase + var response apisv1.ComponentPlanBase err = json.NewDecoder(res.Body).Decode(&response) Expect(err).ShouldNot(HaveOccurred()) Expect(cmp.Diff(response.ComponentType, "worker")).Should(BeEmpty()) @@ -212,13 +212,13 @@ var _ = Describe("Test application rest api", func() { It("Test detail component", func() { defer GinkgoRecover() - res, err := http.Get("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/components/test2") + res, err := http.Get("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/componentplans/test2") Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) Expect(res.Body).ShouldNot(BeNil()) defer res.Body.Close() - var response apisv1.DetailComponentResponse + var response apisv1.DetailComponentPlanResponse err = json.NewDecoder(res.Body).Decode(&response) Expect(err).ShouldNot(HaveOccurred()) Expect(cmp.Diff(len(response.DependsOn), 1)).Should(BeEmpty()) @@ -233,7 +233,7 @@ var _ = Describe("Test application rest api", func() { } bodyByte, err := json.Marshal(req) Expect(err).ShouldNot(HaveOccurred()) - res, err := http.Post("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies", "application/json", bytes.NewBuffer(bodyByte)) + res, err := http.Post("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies", "application/json", bytes.NewBuffer(bodyByte)) Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 400)).Should(BeEmpty()) @@ -245,7 +245,7 @@ var _ = Describe("Test application rest api", func() { } bodyByte2, err := json.Marshal(req2) Expect(err).ShouldNot(HaveOccurred()) - res, err = http.Post("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies", "application/json", bytes.NewBuffer(bodyByte2)) + res, err = http.Post("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies", "application/json", bytes.NewBuffer(bodyByte2)) Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) @@ -260,7 +260,7 @@ var _ = Describe("Test application rest api", func() { It("Test detail application policy", func() { defer GinkgoRecover() - res, err := http.Get("http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies/test2") + res, err := http.Get("http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies/test2") Expect(err).ShouldNot(HaveOccurred()) Expect(res).ShouldNot(BeNil()) Expect(cmp.Diff(res.StatusCode, 200)).Should(BeEmpty()) @@ -280,7 +280,7 @@ var _ = Describe("Test application rest api", func() { } bodyByte2, err := json.Marshal(req2) Expect(err).ShouldNot(HaveOccurred()) - req, err := http.NewRequest(http.MethodPut, "http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies/test2", bytes.NewBuffer(bodyByte2)) + req, err := http.NewRequest(http.MethodPut, "http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies/test2", bytes.NewBuffer(bodyByte2)) Expect(err).ShouldNot(HaveOccurred()) req.Header.Set("Content-Type", "application/json") res, err := http.DefaultClient.Do(req) @@ -298,7 +298,7 @@ var _ = Describe("Test application rest api", func() { It("Test delete application policy", func() { defer GinkgoRecover() - req, err := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8000/api/v1/applications/test-app-sadasd/policies/test2", nil) + req, err := http.NewRequest(http.MethodDelete, "http://127.0.0.1:8000/api/v1/applicationplans/test-app-sadasd/policies/test2", nil) Expect(err).ShouldNot(HaveOccurred()) res, err := http.DefaultClient.Do(req) Expect(err).ShouldNot(HaveOccurred())