add list events

This commit is contained in:
pengcong06
2020-06-02 21:40:58 +08:00
parent 59839439d5
commit 55354bf20d
60 changed files with 628 additions and 11388 deletions

View File

@@ -94,6 +94,9 @@ func (c *applicationOperator) ListApplications(conditions *params.Conditions, li
if status := conditions.Match[Status]; status != "" {
describeClustersRequest.Status = strings.Split(status, "|")
}
if zone := conditions.Match[Zone]; zone != "" {
describeClustersRequest.Zone = []string{zone}
}
if orderBy != "" {
describeClustersRequest.SortKey = &wrappers.StringValue{Value: orderBy}
}
@@ -360,8 +363,8 @@ func (c *applicationOperator) CreateApplication(runtimeId, namespace string, req
AppId: &wrappers.StringValue{Value: request.AppId},
VersionId: &wrappers.StringValue{Value: request.VersionId},
RuntimeId: &wrappers.StringValue{Value: request.RuntimeId},
Namespace: &wrappers.StringValue{Value: namespace},
Conf: &wrappers.StringValue{Value: request.Conf},
Zone: &wrappers.StringValue{Value: namespace},
})
if err != nil {
@@ -407,7 +410,6 @@ func (c *applicationOperator) UpgradeApplication(request UpgradeClusterRequest)
_, err := c.opClient.UpgradeCluster(openpitrix.ContextWithUsername(request.Username), &pb.UpgradeClusterRequest{
ClusterId: &wrappers.StringValue{Value: request.ClusterId},
VersionId: &wrappers.StringValue{Value: request.VersionId},
Conf: &wrappers.StringValue{Value: request.Conf},
})
if err != nil {

View File

@@ -1,19 +1,9 @@
/*
Copyright 2020 The KubeSphere Authors.
<<<<<<< HEAD
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
=======
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
>>>>>>> support UpgradeCluster
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -104,6 +94,7 @@ func TestApplicationOperator_CreateApplication(t *testing.T) {
VersionId: &wrappers.StringValue{Value: test.createClusterRequest.VersionId},
RuntimeId: &wrappers.StringValue{Value: test.createClusterRequest.RuntimeId},
Conf: &wrappers.StringValue{Value: test.createClusterRequest.Conf},
Zone: &wrappers.StringValue{Value: test.targetNamespace},
}).Return(&pb.CreateClusterResponse{}, nil).AnyTimes()
t.Run(test.description, func(t *testing.T) {

View File

@@ -4,7 +4,6 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
>>>>>>> support UpgradeCluster
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@@ -1,19 +1,9 @@
/*
Copyright 2020 The KubeSphere Authors.
<<<<<<< HEAD
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
=======
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
>>>>>>> support UpgradeCluster
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@@ -1,19 +1,9 @@
/*
Copyright 2020 The KubeSphere Authors.
<<<<<<< HEAD
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
=======
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
>>>>>>> support UpgradeCluster
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,6 +34,7 @@ type RepoInterface interface {
ListRepos(conditions *params.Conditions, orderBy string, reverse bool, limit, offset int) (*models.PageableResponse, error)
ValidateRepo(request *ValidateRepoRequest) (*ValidateRepoResponse, error)
DoRepoAction(repoId string, request *RepoActionRequest) error
ListEvents(conditions *params.Conditions, orderBy string, reverse bool, limit, offset int) (*models.PageableResponse, error)
ListRepoEvents(repoId string, conditions *params.Conditions, limit, offset int) (*models.PageableResponse, error)
}
@@ -274,3 +265,33 @@ func (c *repoOperator) ListRepoEvents(repoId string, conditions *params.Conditio
return &models.PageableResponse{Items: items, TotalCount: int(resp.TotalCount)}, nil
}
func (c *repoOperator) ListEvents(conditions *params.Conditions, orderBy string, reverse bool, limit, offset int) (*models.PageableResponse, error) {
describeRepoEventsRequest := &pb.DescribeRepoEventsRequest{}
if repoId := conditions.Match["repo_id"]; repoId != "" {
describeRepoEventsRequest.RepoId = strings.Split(repoId, "|")
}
if eventId := conditions.Match["repo_event_id"]; eventId != "" {
describeRepoEventsRequest.RepoEventId = strings.Split(eventId, "|")
}
if status := conditions.Match["status"]; status != "" {
describeRepoEventsRequest.Status = strings.Split(status, "|")
}
describeRepoEventsRequest.Limit = uint32(limit)
describeRepoEventsRequest.Offset = uint32(offset)
resp, err := c.opClient.DescribeRepoEvents(openpitrix.SystemContext(), describeRepoEventsRequest)
if err != nil {
klog.Error(err)
return nil, err
}
items := make([]interface{}, 0)
for _, item := range resp.RepoEventSet {
items = append(items, convertRepoEvent(item))
}
return &models.PageableResponse{Items: items, TotalCount: int(resp.TotalCount)}, nil
}