mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-25 23:33:58 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c2df10299 | ||
|
|
918ed9727b | ||
|
|
fa78cb7632 |
@@ -387,7 +387,10 @@ func (c *clusterServiceImpl) DeleteKubeCluster(ctx context.Context, clusterName
|
||||
cluster, err := c.getClusterFromDataStore(ctx, clusterName)
|
||||
if err != nil {
|
||||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
return nil, bcode.ErrClusterNotFoundInDataStore
|
||||
if err = multicluster.DetachCluster(ctx, c.K8sClient, clusterName); err != nil {
|
||||
return nil, bcode.ErrClusterNotFoundInDataStore
|
||||
}
|
||||
return &apis.ClusterBase{Name: clusterName}, nil
|
||||
}
|
||||
return nil, errors.Wrapf(err, "failed to found cluster %s in data store", clusterName)
|
||||
}
|
||||
|
||||
@@ -98,6 +98,27 @@ var _ = Describe("Test cluster service function", func() {
|
||||
Expect(err).Should(Equal(bcode.ErrClusterNotFoundInDataStore))
|
||||
})
|
||||
|
||||
It("Test delete kube cluster", func() {
|
||||
service := clusterServiceImpl{
|
||||
Store: ds,
|
||||
caches: cache,
|
||||
K8sClient: k8sClient,
|
||||
}
|
||||
Expect(createClusterSecret("prism-cluster", "prism-alias")).Should(Succeed())
|
||||
Expect(ds.Add(ctx, &model.Cluster{Name: "prism-cluster", Alias: "prism-alias", Icon: "prism-icon"})).Should(Succeed())
|
||||
resp, err := service.DeleteKubeCluster(ctx, "prism-cluster")
|
||||
Expect(err).Should(Succeed())
|
||||
Expect(resp.Name).Should(Equal("prism-cluster"))
|
||||
Expect(resp.Alias).Should(Equal("prism-alias"))
|
||||
Expect(resp.Icon).Should(Equal("prism-icon"))
|
||||
_, err = service.DeleteKubeCluster(ctx, "non-exist-cluster")
|
||||
Expect(err).Should(Equal(bcode.ErrClusterNotFoundInDataStore))
|
||||
Expect(createClusterSecret("secret-exist-cm-non-exist-cluster", "secret-exist-cm-non-exist-cluster")).Should(Succeed())
|
||||
resp, err = service.DeleteKubeCluster(ctx, "secret-exist-cm-non-exist-cluster")
|
||||
Expect(err).Should(Succeed())
|
||||
Expect(resp.Name).Should(Equal("secret-exist-cm-non-exist-cluster"))
|
||||
})
|
||||
|
||||
It("Test list kube clusters", func() {
|
||||
service := clusterServiceImpl{
|
||||
Store: ds,
|
||||
|
||||
@@ -91,7 +91,7 @@ template: {
|
||||
|
||||
parameter: {
|
||||
//+usage=The name of Terraform Provider for Alibaba Cloud
|
||||
name: *"default" | string
|
||||
name: string
|
||||
//+usage=Get ALICLOUD_ACCESS_KEY per this guide https://help.aliyun.com/knowledge_detail/38738.html
|
||||
ALICLOUD_ACCESS_KEY: string
|
||||
//+usage=Get ALICLOUD_SECRET_KEY per this guide https://help.aliyun.com/knowledge_detail/38738.html
|
||||
@@ -144,7 +144,7 @@ var _ = Describe("Test config service", func() {
|
||||
Expect(err).ToNot(BeNil())
|
||||
var paramErr = &script.ParameterError{}
|
||||
Expect(errors.As(err, ¶mErr)).To(Equal(true))
|
||||
Expect(paramErr.Name).To(Equal("ALICLOUD_ACCESS_KEY"))
|
||||
Expect(paramErr.Name).To(Equal("name"))
|
||||
Expect(paramErr.Message).To(Equal("This parameter is required"))
|
||||
|
||||
config, err := configService.CreateConfig(context.TODO(), "", v1.CreateConfigRequest{
|
||||
|
||||
@@ -234,7 +234,7 @@ func (n *pipeline) GetWebServiceRoute() *restful.WebService {
|
||||
Doc("list pipelines").
|
||||
Param(ws.QueryParameter("query", "Fuzzy search based on name or description").DataType("string")).
|
||||
Param(ws.QueryParameter("projectName", "query pipelines within a project").DataType("string")).
|
||||
Param(ws.QueryParameter("detailed", "query pipelines with detail").DataType("bool").DefaultValue("true")).
|
||||
Param(ws.QueryParameter("detailed", "query pipelines with detail").DataType("boolean").DefaultValue("true")).
|
||||
Returns(200, "OK", apis.ListPipelineResponse{}).
|
||||
Returns(400, "Bad Request", bcode.Bcode{}).
|
||||
Writes(apis.ListPipelineResponse{}).Do(meta))
|
||||
|
||||
@@ -23,21 +23,21 @@ var (
|
||||
// ErrNoConfigOrTarget means there is no target or config when creating the distribution.
|
||||
ErrNoConfigOrTarget = NewBcode(400, 16002, "you must specify the config name and destination to distribute")
|
||||
|
||||
// ErrConfigExist means the config is exist
|
||||
ErrConfigExist = NewBcode(400, 16003, "the config name is exist")
|
||||
// ErrConfigExist means the config does exist
|
||||
ErrConfigExist = NewBcode(400, 16003, "the config name does exist")
|
||||
|
||||
// ErrChangeTemplate the template of the config can not be change
|
||||
ErrChangeTemplate = NewBcode(400, 16004, "the template of the config can not be change")
|
||||
// ErrChangeTemplate the template of the config can not be changed
|
||||
ErrChangeTemplate = NewBcode(400, 16004, "the template of the config can not be changed")
|
||||
|
||||
// ErrTemplateNotFound means the template is not exist
|
||||
ErrTemplateNotFound = NewBcode(404, 16005, "the template is not exist")
|
||||
// ErrTemplateNotFound means the template does not exist
|
||||
ErrTemplateNotFound = NewBcode(404, 16005, "the template does not exist")
|
||||
|
||||
// ErrConfigNotFound means the config is not exist
|
||||
ErrConfigNotFound = NewBcode(404, 16006, "the config is not exist")
|
||||
// ErrConfigNotFound means the config does not exist
|
||||
ErrConfigNotFound = NewBcode(404, 16006, "the config does not exist")
|
||||
|
||||
// ErrNotFoundDistribution means the distribution is not exist
|
||||
ErrNotFoundDistribution = NewBcode(404, 16007, "the distribution is not exist")
|
||||
// ErrNotFoundDistribution means the distribution does not exist
|
||||
ErrNotFoundDistribution = NewBcode(404, 16007, "the distribution does not exist")
|
||||
|
||||
// ErrChangeSecretType the secret type of the config can not be change
|
||||
ErrChangeSecretType = NewBcode(400, 16008, "the secret type of the config can not be change")
|
||||
// ErrChangeSecretType the secret type of the config can not be changed
|
||||
ErrChangeSecretType = NewBcode(400, 16008, "the secret type of the config can not be changed")
|
||||
)
|
||||
|
||||
@@ -76,23 +76,23 @@ var ErrSensitiveConfig = errors.New("the config is sensitive")
|
||||
// ErrNoConfigOrTarget means the config or the target is empty.
|
||||
var ErrNoConfigOrTarget = errors.New("you must specify the config name and destination to distribute")
|
||||
|
||||
// ErrNotFoundDistribution means the app of the distribution is not exist.
|
||||
var ErrNotFoundDistribution = errors.New("the distribution is not found")
|
||||
// ErrNotFoundDistribution means the app of the distribution does not exist.
|
||||
var ErrNotFoundDistribution = errors.New("the distribution does not found")
|
||||
|
||||
// ErrConfigExist means the config is exist.
|
||||
var ErrConfigExist = errors.New("the config is exist")
|
||||
// ErrConfigExist means the config does exist.
|
||||
var ErrConfigExist = errors.New("the config does exist")
|
||||
|
||||
// ErrConfigNotFound means the config is not exist
|
||||
var ErrConfigNotFound = errors.New("the config is not exist")
|
||||
// ErrConfigNotFound means the config does not exist
|
||||
var ErrConfigNotFound = errors.New("the config does not exist")
|
||||
|
||||
// ErrTemplateNotFound means the template is not exist
|
||||
var ErrTemplateNotFound = errors.New("the template is not exist")
|
||||
// ErrTemplateNotFound means the template does not exist
|
||||
var ErrTemplateNotFound = errors.New("the template does not exist")
|
||||
|
||||
// ErrChangeTemplate means the template of the config can not be change
|
||||
var ErrChangeTemplate = errors.New("the template of the config can not be change")
|
||||
// ErrChangeTemplate means the template of the config can not be changed
|
||||
var ErrChangeTemplate = errors.New("the template of the config can not be changed")
|
||||
|
||||
// ErrChangeSecretType means the secret type of the config can not be change
|
||||
var ErrChangeSecretType = errors.New("the secret type of the config can not be change")
|
||||
// ErrChangeSecretType means the secret type of the config can not be changed
|
||||
var ErrChangeSecretType = errors.New("the secret type of the config can not be changed")
|
||||
|
||||
// NamespacedName the namespace and name model
|
||||
type NamespacedName struct {
|
||||
|
||||
@@ -94,7 +94,7 @@ var _ = Describe("Test the config provider", func() {
|
||||
`, nil, "")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = p.Create(mCtx, new(wfContext.WorkflowContext), v, nil)
|
||||
Expect(strings.Contains(err.Error(), "the template is not exist")).Should(BeTrue())
|
||||
Expect(strings.Contains(err.Error(), "the template does not exist")).Should(BeTrue())
|
||||
|
||||
template, err := p.factory.ParseTemplate("test-image-registry", []byte(templateContent))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
@@ -153,7 +153,7 @@ var _ = Describe("Test the rest api about the config", func() {
|
||||
Expect(config.Secret).Should(BeNil())
|
||||
Expect(config.Properties["registry"]).Should(Equal("kubevela.test.com"))
|
||||
|
||||
By("the config name is exist")
|
||||
By("the config name does exist")
|
||||
req = v1.CreateConfigRequest{
|
||||
Name: "test-registry",
|
||||
Alias: "Test Registry",
|
||||
@@ -164,7 +164,7 @@ var _ = Describe("Test the rest api about the config", func() {
|
||||
res = post("/configs", req)
|
||||
Expect(res.StatusCode).Should(Equal(400))
|
||||
|
||||
By("the template is not exist")
|
||||
By("the template does not exist")
|
||||
req = v1.CreateConfigRequest{
|
||||
Name: "test-registry2",
|
||||
Alias: "Test Registry",
|
||||
|
||||
Reference in New Issue
Block a user