mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
more error info for apiservice and add tests
Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com> change the mock addon version Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
name: not-match-addon
|
||||
version: 1.0.0
|
||||
description: Extended workload to do continuous and progressive delivery
|
||||
icon: https://raw.githubusercontent.com/fluxcd/flux/master/docs/_files/weave-flux.png
|
||||
url: https://fluxcd.io
|
||||
|
||||
tags:
|
||||
- mock
|
||||
dependencies: []
|
||||
#- name: addon_name
|
||||
|
||||
# set invisible means this won't be list and will be enabled when depended on
|
||||
# for example, terraform-alibaba depends on terraform which is invisible,
|
||||
# when terraform-alibaba is enabled, terraform will be enabled automatically
|
||||
# default: false
|
||||
invisible: false
|
||||
|
||||
system:
|
||||
kubernetes: "<=v1.3.0"
|
||||
@@ -419,7 +419,9 @@ func (u *addonServiceImpl) EnableAddon(ctx context.Context, name string, args ap
|
||||
|
||||
// wrap this error with special bcode
|
||||
if errors.As(err, &pkgaddon.VersionUnMatchError{}) {
|
||||
return bcode.ErrAddonSystemVersionMismatch
|
||||
berr := bcode.ErrAddonSystemVersionMismatch
|
||||
berr.Message = err.Error()
|
||||
return berr
|
||||
}
|
||||
// except `addon not found`, other errors should return directly
|
||||
return err
|
||||
|
||||
@@ -17,7 +17,10 @@ limitations under the License.
|
||||
package e2e_apiserver_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@@ -188,5 +191,26 @@ var _ = Describe("Test addon rest api", func() {
|
||||
Expect(decodeResponseBody(res, &addonStatus)).Should(Succeed())
|
||||
Expect(addonStatus.Name).Should(BeEquivalentTo("mock-addon"))
|
||||
})
|
||||
|
||||
It("enable addon with not match system version requirement", func() {
|
||||
req := apisv1.EnableAddonRequest{
|
||||
Args: map[string]interface{}{
|
||||
"testkey": "testvalue",
|
||||
},
|
||||
}
|
||||
res := post("/addons/not-match-addon/enable", req)
|
||||
defer res.Body.Close()
|
||||
type errResp struct {
|
||||
BusinessCode int `json:"BusinessCode"`
|
||||
Message string `json:"Message"`
|
||||
}
|
||||
var errResponse errResp
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
Expect(err).Should(BeNil())
|
||||
err = json.Unmarshal(body, &errResponse)
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(errResponse.BusinessCode).Should(BeEquivalentTo(50018))
|
||||
Expect(strings.Contains(errResponse.Message, "fail to install"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user