refactor code structure (#1738)
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package openpitrix
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/strfmt"
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
"k8s.io/klog"
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
|
||||
"kubesphere.io/kubesphere/pkg/server/params"
|
||||
cs "kubesphere.io/kubesphere/pkg/simple/client"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
@@ -83,13 +85,13 @@ func ListApps(conditions *params.Conditions, orderBy string, reverse bool, limit
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.AppSet {
|
||||
items = append(items, convertApp(item))
|
||||
items = append(items, utils.ConvertApp(item))
|
||||
}
|
||||
|
||||
return &models.PageableResponse{Items: items, TotalCount: int(resp.TotalCount)}, nil
|
||||
}
|
||||
|
||||
func DescribeApp(id string) (*App, error) {
|
||||
func DescribeApp(id string) (*types.App, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -104,10 +106,10 @@ func DescribeApp(id string) (*App, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var app *App
|
||||
var app *types.App
|
||||
|
||||
if len(resp.AppSet) > 0 {
|
||||
app = convertApp(resp.AppSet[0])
|
||||
app = utils.ConvertApp(resp.AppSet[0])
|
||||
return app, nil
|
||||
} else {
|
||||
err := status.New(codes.NotFound, "resource not found").Err()
|
||||
@@ -132,7 +134,7 @@ func DeleteApp(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateApp(request *CreateAppRequest) (*CreateAppResponse, error) {
|
||||
func CreateApp(request *types.CreateAppRequest) (*types.CreateAppResponse, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -157,13 +159,13 @@ func CreateApp(request *CreateAppRequest) (*CreateAppResponse, error) {
|
||||
klog.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return &CreateAppResponse{
|
||||
return &types.CreateAppResponse{
|
||||
AppID: resp.GetAppId().GetValue(),
|
||||
VersionID: resp.GetVersionId().GetValue(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func PatchApp(appId string, request *ModifyAppRequest) error {
|
||||
func PatchApp(appId string, request *types.ModifyAppRequest) error {
|
||||
client, err := cs.ClientSets().OpenPitrix()
|
||||
|
||||
if err != nil {
|
||||
@@ -237,7 +239,7 @@ func PatchApp(appId string, request *ModifyAppRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateAppVersion(request *CreateAppVersionRequest) (*CreateAppVersionResponse, error) {
|
||||
func CreateAppVersion(request *types.CreateAppVersionRequest) (*types.CreateAppVersionResponse, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -259,12 +261,12 @@ func CreateAppVersion(request *CreateAppVersionRequest) (*CreateAppVersionRespon
|
||||
klog.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return &CreateAppVersionResponse{
|
||||
return &types.CreateAppVersionResponse{
|
||||
VersionId: resp.GetVersionId().GetValue(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ValidatePackage(request *ValidatePackageRequest) (*ValidatePackageResponse, error) {
|
||||
func ValidatePackage(request *types.ValidatePackageRequest) (*types.ValidatePackageResponse, error) {
|
||||
client, err := cs.ClientSets().OpenPitrix()
|
||||
|
||||
if err != nil {
|
||||
@@ -288,7 +290,7 @@ func ValidatePackage(request *ValidatePackageRequest) (*ValidatePackageResponse,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := &ValidatePackageResponse{}
|
||||
result := &types.ValidatePackageResponse{}
|
||||
|
||||
if resp.Error != nil {
|
||||
result.Error = resp.Error.Value
|
||||
@@ -330,7 +332,7 @@ func DeleteAppVersion(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func PatchAppVersion(id string, request *ModifyAppVersionRequest) error {
|
||||
func PatchAppVersion(id string, request *types.ModifyAppVersionRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -361,7 +363,7 @@ func PatchAppVersion(id string, request *ModifyAppVersionRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DescribeAppVersion(id string) (*AppVersion, error) {
|
||||
func DescribeAppVersion(id string) (*types.AppVersion, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -376,10 +378,10 @@ func DescribeAppVersion(id string) (*AppVersion, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var app *AppVersion
|
||||
var app *types.AppVersion
|
||||
|
||||
if len(resp.AppVersionSet) > 0 {
|
||||
app = convertAppVersion(resp.AppVersionSet[0])
|
||||
app = utils.ConvertAppVersion(resp.AppVersionSet[0])
|
||||
return app, nil
|
||||
} else {
|
||||
err := status.New(codes.NotFound, "resource not found").Err()
|
||||
@@ -388,7 +390,7 @@ func DescribeAppVersion(id string) (*AppVersion, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageResponse, error) {
|
||||
func GetAppVersionPackage(appId, versionId string) (*types.GetAppVersionPackageResponse, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -402,7 +404,7 @@ func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageRespons
|
||||
return nil, err
|
||||
}
|
||||
|
||||
app := &GetAppVersionPackageResponse{
|
||||
app := &types.GetAppVersionPackageResponse{
|
||||
AppId: appId,
|
||||
VersionId: versionId,
|
||||
}
|
||||
@@ -414,7 +416,7 @@ func GetAppVersionPackage(appId, versionId string) (*GetAppVersionPackageRespons
|
||||
return app, nil
|
||||
}
|
||||
|
||||
func DoAppAction(appId string, request *ActionRequest) error {
|
||||
func DoAppAction(appId string, request *types.ActionRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
|
||||
if err != nil {
|
||||
@@ -479,7 +481,7 @@ func DoAppAction(appId string, request *ActionRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DoAppVersionAction(versionId string, request *ActionRequest) error {
|
||||
func DoAppVersionAction(versionId string, request *types.ActionRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
|
||||
if err != nil {
|
||||
@@ -529,7 +531,7 @@ func DoAppVersionAction(versionId string, request *ActionRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAppVersionFiles(versionId string, request *GetAppVersionFilesRequest) (*GetAppVersionPackageFilesResponse, error) {
|
||||
func GetAppVersionFiles(versionId string, request *types.GetAppVersionFilesRequest) (*types.GetAppVersionPackageFilesResponse, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -548,7 +550,7 @@ func GetAppVersionFiles(versionId string, request *GetAppVersionFilesRequest) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
version := &GetAppVersionPackageFilesResponse{
|
||||
version := &types.GetAppVersionPackageFilesResponse{
|
||||
VersionId: versionId,
|
||||
}
|
||||
|
||||
@@ -600,7 +602,7 @@ func ListAppVersionAudits(conditions *params.Conditions, orderBy string, reverse
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.AppVersionAuditSet {
|
||||
appVersion := convertAppVersionAudit(item)
|
||||
appVersion := utils.ConvertAppVersionAudit(item)
|
||||
items = append(items, appVersion)
|
||||
}
|
||||
|
||||
@@ -640,7 +642,7 @@ func ListAppVersionReviews(conditions *params.Conditions, orderBy string, revers
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.AppVersionReviewSet {
|
||||
appVersion := convertAppVersionReview(item)
|
||||
appVersion := utils.ConvertAppVersionReview(item)
|
||||
items = append(items, appVersion)
|
||||
}
|
||||
|
||||
@@ -682,7 +684,7 @@ func ListAppVersions(conditions *params.Conditions, orderBy string, reverse bool
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.AppVersionSet {
|
||||
appVersion := convertAppVersion(item)
|
||||
appVersion := utils.ConvertAppVersion(item)
|
||||
items = append(items, appVersion)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
package openpitrix
|
||||
package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -32,6 +32,8 @@ import (
|
||||
"k8s.io/klog"
|
||||
"kubesphere.io/kubesphere/pkg/constants"
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
|
||||
"kubesphere.io/kubesphere/pkg/server/params"
|
||||
cs "kubesphere.io/kubesphere/pkg/simple/client"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
@@ -42,8 +44,8 @@ import (
|
||||
type Interface interface {
|
||||
List(conditions *params.Conditions, limit, offset int, orderBy string, reverse bool) (*models.PageableResponse, error)
|
||||
Get(namespace, clusterID string) (*Application, error)
|
||||
Create(namespace string, request CreateClusterRequest) error
|
||||
Patch(request ModifyClusterAttributesRequest) error
|
||||
Create(namespace string, request types.CreateClusterRequest) error
|
||||
Patch(request types.ModifyClusterAttributesRequest) error
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
@@ -61,9 +63,9 @@ func NewApplicaitonOperator(informers informers.SharedInformerFactory, client pb
|
||||
|
||||
type Application struct {
|
||||
Name string `json:"name" description:"application name"`
|
||||
Cluster *Cluster `json:"cluster,omitempty" description:"application cluster info"`
|
||||
Version *AppVersion `json:"version,omitempty" description:"application template version info"`
|
||||
App *App `json:"app,omitempty" description:"application template info"`
|
||||
Cluster *types.Cluster `json:"cluster,omitempty" description:"application cluster info"`
|
||||
Version *types.AppVersion `json:"version,omitempty" description:"application template version info"`
|
||||
App *types.App `json:"app,omitempty" description:"application template info"`
|
||||
WorkLoads *workLoads `json:"workloads,omitempty" description:"application workloads"`
|
||||
Services []v1.Service `json:"services,omitempty" description:"application services"`
|
||||
Ingresses []v1beta1.Ingress `json:"ingresses,omitempty" description:"application ingresses"`
|
||||
@@ -130,14 +132,14 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
|
||||
}
|
||||
var app Application
|
||||
app.Name = cluster.Name.Value
|
||||
app.Cluster = convertCluster(cluster)
|
||||
app.Cluster = utils.ConvertCluster(cluster)
|
||||
versionInfo, err := op.App().DescribeAppVersions(openpitrix.SystemContext(), &pb.DescribeAppVersionsRequest{VersionId: []string{cluster.GetVersionId().GetValue()}})
|
||||
if err != nil {
|
||||
klog.Errorln(err)
|
||||
return nil, err
|
||||
}
|
||||
if len(versionInfo.AppVersionSet) > 0 {
|
||||
app.Version = convertAppVersion(versionInfo.AppVersionSet[0])
|
||||
app.Version = utils.ConvertAppVersion(versionInfo.AppVersionSet[0])
|
||||
}
|
||||
appInfo, err := op.App().DescribeApps(openpitrix.SystemContext(), &pb.DescribeAppsRequest{AppId: []string{cluster.GetAppId().GetValue()}, Limit: 1})
|
||||
if err != nil {
|
||||
@@ -145,7 +147,7 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
|
||||
return nil, err
|
||||
}
|
||||
if len(appInfo.AppSet) > 0 {
|
||||
app.App = convertApp(appInfo.GetAppSet()[0])
|
||||
app.App = utils.ConvertApp(appInfo.GetAppSet()[0])
|
||||
}
|
||||
return &app, nil
|
||||
}
|
||||
@@ -350,7 +352,7 @@ func (c *applicationOperator) getIng(namespace string, services []v1.Service) []
|
||||
return ings
|
||||
}
|
||||
|
||||
func (c *applicationOperator) Create(namespace string, request CreateClusterRequest) error {
|
||||
func (c *applicationOperator) Create(namespace string, request types.CreateClusterRequest) error {
|
||||
ns, err := c.informers.Core().V1().Namespaces().Lister().Get(namespace)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -385,7 +387,7 @@ func (c *applicationOperator) Create(namespace string, request CreateClusterRequ
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *applicationOperator) Patch(request ModifyClusterAttributesRequest) error {
|
||||
func (c *applicationOperator) Patch(request types.ModifyClusterAttributesRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
|
||||
if err != nil {
|
||||
@@ -16,18 +16,20 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package openpitrix
|
||||
package attachment
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"k8s.io/klog"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
|
||||
cs "kubesphere.io/kubesphere/pkg/simple/client"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
"openpitrix.io/openpitrix/pkg/pb"
|
||||
)
|
||||
|
||||
func DescribeAttachment(id string) (*Attachment, error) {
|
||||
func DescribeAttachment(id string) (*types.Attachment, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -41,7 +43,7 @@ func DescribeAttachment(id string) (*Attachment, error) {
|
||||
return nil, err
|
||||
}
|
||||
if len(resp.Attachments) > 0 {
|
||||
return convertAttachment(resp.Attachments[id]), nil
|
||||
return utils.ConvertAttachment(resp.Attachments[id]), nil
|
||||
} else {
|
||||
err := status.New(codes.NotFound, "resource not found").Err()
|
||||
klog.Error(err)
|
||||
@@ -16,7 +16,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package openpitrix
|
||||
package category
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/ptypes/wrappers"
|
||||
@@ -24,13 +24,15 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
"k8s.io/klog"
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
|
||||
"kubesphere.io/kubesphere/pkg/server/params"
|
||||
cs "kubesphere.io/kubesphere/pkg/simple/client"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
"openpitrix.io/openpitrix/pkg/pb"
|
||||
)
|
||||
|
||||
func CreateCategory(request *CreateCategoryRequest) (*CreateCategoryResponse, error) {
|
||||
func CreateCategory(request *types.CreateCategoryRequest) (*types.CreateCategoryResponse, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -50,7 +52,7 @@ func CreateCategory(request *CreateCategoryRequest) (*CreateCategoryResponse, er
|
||||
klog.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return &CreateCategoryResponse{
|
||||
return &types.CreateCategoryResponse{
|
||||
CategoryId: resp.GetCategoryId().GetValue(),
|
||||
}, nil
|
||||
}
|
||||
@@ -71,7 +73,7 @@ func DeleteCategory(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func PatchCategory(id string, request *ModifyCategoryRequest) error {
|
||||
func PatchCategory(id string, request *types.ModifyCategoryRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -101,7 +103,7 @@ func PatchCategory(id string, request *ModifyCategoryRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DescribeCategory(id string) (*Category, error) {
|
||||
func DescribeCategory(id string) (*types.Category, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -116,10 +118,10 @@ func DescribeCategory(id string) (*Category, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var category *Category
|
||||
var category *types.Category
|
||||
|
||||
if len(resp.CategorySet) > 0 {
|
||||
category = convertCategory(resp.CategorySet[0])
|
||||
category = utils.ConvertCategory(resp.CategorySet[0])
|
||||
return category, nil
|
||||
} else {
|
||||
err := status.New(codes.NotFound, "resource not found").Err()
|
||||
@@ -156,7 +158,7 @@ func ListCategories(conditions *params.Conditions, orderBy string, reverse bool,
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.CategorySet {
|
||||
items = append(items, convertCategory(item))
|
||||
items = append(items, utils.ConvertCategory(item))
|
||||
}
|
||||
|
||||
return &models.PageableResponse{Items: items, TotalCount: int(resp.TotalCount)}, nil
|
||||
@@ -16,7 +16,7 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package openpitrix
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
"k8s.io/klog"
|
||||
"kubesphere.io/kubesphere/pkg/models"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/utils"
|
||||
"kubesphere.io/kubesphere/pkg/server/params"
|
||||
cs "kubesphere.io/kubesphere/pkg/simple/client"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
|
||||
@@ -32,7 +34,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func CreateRepo(request *CreateRepoRequest) (*CreateRepoResponse, error) {
|
||||
func CreateRepo(request *types.CreateRepoRequest) (*types.CreateRepoResponse, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -61,7 +63,7 @@ func CreateRepo(request *CreateRepoRequest) (*CreateRepoResponse, error) {
|
||||
klog.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
return &CreateRepoResponse{
|
||||
return &types.CreateRepoResponse{
|
||||
RepoID: resp.GetRepoId().GetValue(),
|
||||
}, nil
|
||||
}
|
||||
@@ -82,7 +84,7 @@ func DeleteRepo(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func PatchRepo(id string, request *ModifyRepoRequest) error {
|
||||
func PatchRepo(id string, request *types.ModifyRepoRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -132,7 +134,7 @@ func PatchRepo(id string, request *ModifyRepoRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DescribeRepo(id string) (*Repo, error) {
|
||||
func DescribeRepo(id string) (*types.Repo, error) {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -147,10 +149,10 @@ func DescribeRepo(id string) (*Repo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var repo *Repo
|
||||
var repo *types.Repo
|
||||
|
||||
if len(resp.RepoSet) > 0 {
|
||||
repo = convertRepo(resp.RepoSet[0])
|
||||
repo = utils.ConvertRepo(resp.RepoSet[0])
|
||||
return repo, nil
|
||||
} else {
|
||||
err := status.New(codes.NotFound, "resource not found").Err()
|
||||
@@ -202,13 +204,13 @@ func ListRepos(conditions *params.Conditions, orderBy string, reverse bool, limi
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.RepoSet {
|
||||
items = append(items, convertRepo(item))
|
||||
items = append(items, utils.ConvertRepo(item))
|
||||
}
|
||||
|
||||
return &models.PageableResponse{Items: items, TotalCount: int(resp.TotalCount)}, nil
|
||||
}
|
||||
|
||||
func ValidateRepo(request *ValidateRepoRequest) (*ValidateRepoResponse, error) {
|
||||
func ValidateRepo(request *types.ValidateRepoRequest) (*types.ValidateRepoResponse, error) {
|
||||
client, err := cs.ClientSets().OpenPitrix()
|
||||
|
||||
if err != nil {
|
||||
@@ -227,13 +229,13 @@ func ValidateRepo(request *ValidateRepoRequest) (*ValidateRepoResponse, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ValidateRepoResponse{
|
||||
return &types.ValidateRepoResponse{
|
||||
ErrorCode: int64(resp.ErrorCode),
|
||||
Ok: resp.Ok.Value,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func DoRepoAction(repoId string, request *RepoActionRequest) error {
|
||||
func DoRepoAction(repoId string, request *types.RepoActionRequest) error {
|
||||
op, err := cs.ClientSets().OpenPitrix()
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
@@ -289,7 +291,7 @@ func ListRepoEvents(repoId string, conditions *params.Conditions, limit, offset
|
||||
items := make([]interface{}, 0)
|
||||
|
||||
for _, item := range resp.RepoEventSet {
|
||||
items = append(items, convertRepoEvent(item))
|
||||
items = append(items, utils.ConvertRepoEvent(item))
|
||||
}
|
||||
|
||||
return &models.PageableResponse{Items: items, TotalCount: int(resp.TotalCount)}, nil
|
||||
@@ -1,4 +1,4 @@
|
||||
package openpitrix
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/strfmt"
|
||||
@@ -16,28 +16,29 @@
|
||||
* /
|
||||
*/
|
||||
|
||||
package openpitrix
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/strfmt"
|
||||
"kubesphere.io/kubesphere/pkg/models/openpitrix/type"
|
||||
"openpitrix.io/openpitrix/pkg/pb"
|
||||
"time"
|
||||
)
|
||||
|
||||
func convertApp(in *pb.App) *App {
|
||||
func ConvertApp(in *pb.App) *types.App {
|
||||
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
categorySet := make(AppCategorySet, 0)
|
||||
categorySet := make(types.AppCategorySet, 0)
|
||||
|
||||
for _, item := range in.CategorySet {
|
||||
category := convertResourceCategory(item)
|
||||
category := ConvertResourceCategory(item)
|
||||
categorySet = append(categorySet, category)
|
||||
}
|
||||
|
||||
out := App{
|
||||
out := types.App{
|
||||
CategorySet: categorySet,
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ func convertApp(in *pb.App) *App {
|
||||
out.Keywords = in.Keywords.Value
|
||||
}
|
||||
if in.LatestAppVersion != nil {
|
||||
out.LatestAppVersion = convertAppVersion(in.LatestAppVersion)
|
||||
out.LatestAppVersion = ConvertAppVersion(in.LatestAppVersion)
|
||||
}
|
||||
if in.Name != nil {
|
||||
out.Name = in.Name.Value
|
||||
@@ -130,11 +131,11 @@ func convertApp(in *pb.App) *App {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertAppVersion(in *pb.AppVersion) *AppVersion {
|
||||
func ConvertAppVersion(in *pb.AppVersion) *types.AppVersion {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := AppVersion{}
|
||||
out := types.AppVersion{}
|
||||
if in.AppId != nil {
|
||||
out.AppId = in.AppId.Value
|
||||
}
|
||||
@@ -209,11 +210,11 @@ func convertAppVersion(in *pb.AppVersion) *AppVersion {
|
||||
|
||||
}
|
||||
|
||||
func convertResourceCategory(in *pb.ResourceCategory) *ResourceCategory {
|
||||
func ConvertResourceCategory(in *pb.ResourceCategory) *types.ResourceCategory {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := ResourceCategory{}
|
||||
out := types.ResourceCategory{}
|
||||
|
||||
if in.CategoryId != nil {
|
||||
out.CategoryId = in.CategoryId.Value
|
||||
@@ -239,11 +240,11 @@ func convertResourceCategory(in *pb.ResourceCategory) *ResourceCategory {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertCategory(in *pb.Category) *Category {
|
||||
func ConvertCategory(in *pb.Category) *types.Category {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := Category{}
|
||||
out := types.Category{}
|
||||
|
||||
if in.CategoryId != nil {
|
||||
out.CategoryID = in.CategoryId.Value
|
||||
@@ -275,11 +276,11 @@ func convertCategory(in *pb.Category) *Category {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertAttachment(in *pb.Attachment) *Attachment {
|
||||
func ConvertAttachment(in *pb.Attachment) *types.Attachment {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := Attachment{}
|
||||
out := types.Attachment{}
|
||||
|
||||
out.AttachmentID = in.AttachmentId
|
||||
|
||||
@@ -297,11 +298,11 @@ func convertAttachment(in *pb.Attachment) *Attachment {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertRepo(in *pb.Repo) *Repo {
|
||||
func ConvertRepo(in *pb.Repo) *types.Repo {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := Repo{}
|
||||
out := types.Repo{}
|
||||
|
||||
if in.RepoId != nil {
|
||||
out.RepoId = in.RepoId.Value
|
||||
@@ -316,10 +317,10 @@ func convertRepo(in *pb.Repo) *Repo {
|
||||
out.Credential = in.Credential.Value
|
||||
}
|
||||
|
||||
categorySet := make(RepoCategorySet, 0)
|
||||
categorySet := make(types.RepoCategorySet, 0)
|
||||
|
||||
for _, item := range in.CategorySet {
|
||||
category := convertResourceCategory(item)
|
||||
category := ConvertResourceCategory(item)
|
||||
categorySet = append(categorySet, category)
|
||||
}
|
||||
|
||||
@@ -338,10 +339,10 @@ func convertRepo(in *pb.Repo) *Repo {
|
||||
out.Description = in.Description.Value
|
||||
}
|
||||
|
||||
labelSet := make(RepoLabels, 0)
|
||||
labelSet := make(types.RepoLabels, 0)
|
||||
|
||||
for _, item := range in.Labels {
|
||||
label := convertRepoLabel(item)
|
||||
label := ConvertRepoLabel(item)
|
||||
labelSet = append(labelSet, label)
|
||||
}
|
||||
|
||||
@@ -357,10 +358,10 @@ func convertRepo(in *pb.Repo) *Repo {
|
||||
out.RepoId = in.RepoId.Value
|
||||
}
|
||||
|
||||
selectorSet := make(RepoSelectors, 0)
|
||||
selectorSet := make(types.RepoSelectors, 0)
|
||||
|
||||
for _, item := range in.Selectors {
|
||||
selector := convertRepoSelector(item)
|
||||
selector := ConvertRepoSelector(item)
|
||||
selectorSet = append(selectorSet, selector)
|
||||
}
|
||||
|
||||
@@ -384,11 +385,11 @@ func convertRepo(in *pb.Repo) *Repo {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertRepoLabel(in *pb.RepoLabel) *RepoLabel {
|
||||
func ConvertRepoLabel(in *pb.RepoLabel) *types.RepoLabel {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := RepoLabel{}
|
||||
out := types.RepoLabel{}
|
||||
if in.CreateTime != nil {
|
||||
date := strfmt.DateTime(time.Unix(in.CreateTime.Seconds, 0))
|
||||
out.CreateTime = &date
|
||||
@@ -402,11 +403,11 @@ func convertRepoLabel(in *pb.RepoLabel) *RepoLabel {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertRepoSelector(in *pb.RepoSelector) *RepoSelector {
|
||||
func ConvertRepoSelector(in *pb.RepoSelector) *types.RepoSelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := RepoSelector{}
|
||||
out := types.RepoSelector{}
|
||||
if in.CreateTime != nil {
|
||||
date := strfmt.DateTime(time.Unix(in.CreateTime.Seconds, 0))
|
||||
out.CreateTime = &date
|
||||
@@ -420,11 +421,11 @@ func convertRepoSelector(in *pb.RepoSelector) *RepoSelector {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertAppVersionAudit(in *pb.AppVersionAudit) *AppVersionAudit {
|
||||
func ConvertAppVersionAudit(in *pb.AppVersionAudit) *types.AppVersionAudit {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := AppVersionAudit{}
|
||||
out := types.AppVersionAudit{}
|
||||
if in.AppId != nil {
|
||||
out.AppId = in.AppId.Value
|
||||
}
|
||||
@@ -462,11 +463,11 @@ func convertAppVersionAudit(in *pb.AppVersionAudit) *AppVersionAudit {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
|
||||
func ConvertAppVersionReview(in *pb.AppVersionReview) *types.AppVersionReview {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := AppVersionReview{}
|
||||
out := types.AppVersionReview{}
|
||||
if in.AppId != nil {
|
||||
out.AppId = in.AppId.Value
|
||||
}
|
||||
@@ -474,9 +475,9 @@ func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
|
||||
out.AppName = in.AppName.Value
|
||||
}
|
||||
if in.Phase != nil {
|
||||
out.Phase = make(AppVersionReviewPhaseOAIGen)
|
||||
out.Phase = make(types.AppVersionReviewPhaseOAIGen)
|
||||
for k, v := range in.Phase {
|
||||
out.Phase[k] = *convertAppVersionReviewPhase(v)
|
||||
out.Phase[k] = *ConvertAppVersionReviewPhase(v)
|
||||
}
|
||||
}
|
||||
if in.ReviewId != nil {
|
||||
@@ -503,11 +504,11 @@ func convertAppVersionReview(in *pb.AppVersionReview) *AppVersionReview {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertAppVersionReviewPhase(in *pb.AppVersionReviewPhase) *AppVersionReviewPhase {
|
||||
func ConvertAppVersionReviewPhase(in *pb.AppVersionReviewPhase) *types.AppVersionReviewPhase {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := AppVersionReviewPhase{}
|
||||
out := types.AppVersionReviewPhase{}
|
||||
if in.Message != nil {
|
||||
out.Message = in.Message.Value
|
||||
}
|
||||
@@ -531,11 +532,11 @@ func convertAppVersionReviewPhase(in *pb.AppVersionReviewPhase) *AppVersionRevie
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertRepoEvent(in *pb.RepoEvent) *RepoEvent {
|
||||
func ConvertRepoEvent(in *pb.RepoEvent) *types.RepoEvent {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := RepoEvent{}
|
||||
out := types.RepoEvent{}
|
||||
if in.CreateTime != nil {
|
||||
date := strfmt.DateTime(time.Unix(in.CreateTime.Seconds, 0))
|
||||
out.CreateTime = &date
|
||||
@@ -563,11 +564,11 @@ func convertRepoEvent(in *pb.RepoEvent) *RepoEvent {
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertCluster(in *pb.Cluster) *Cluster {
|
||||
func ConvertCluster(in *pb.Cluster) *types.Cluster {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := Cluster{}
|
||||
out := types.Cluster{}
|
||||
if in.AdditionalInfo != nil {
|
||||
out.AdditionalInfo = in.AdditionalInfo.Value
|
||||
}
|
||||
Reference in New Issue
Block a user