@@ -218,7 +218,11 @@ func (h *openpitrixHandler) DescribeRepo(req *restful.Request, resp *restful.Res
|
||||
|
||||
if err != nil {
|
||||
klog.Errorln(err)
|
||||
handleOpenpitrixError(resp, err)
|
||||
if apierrors.IsNotFound(err) {
|
||||
api.HandleNotFound(resp, nil, err)
|
||||
return
|
||||
}
|
||||
api.HandleInternalError(resp, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -160,7 +159,8 @@ func (c *repoOperator) ModifyRepo(id string, request *ModifyRepoRequest) error {
|
||||
repoCopy.Spec.Description = stringutils.ShortenString(*request.Description, DescriptionLen)
|
||||
}
|
||||
|
||||
if request.Name != nil && len(*request.Name) > 0 && *request.Name != repoCopy.Name {
|
||||
// modify name of the repo
|
||||
if request.Name != nil && len(*request.Name) > 0 && *request.Name != repoCopy.Spec.Name {
|
||||
items, err := c.repoLister.List(labels.SelectorFromSet(map[string]string{constants.WorkspaceLabelKey: repo.GetWorkspace()}))
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
klog.Errorf("list helm repo failed: %s", err)
|
||||
@@ -207,10 +207,12 @@ func (c *repoOperator) ModifyRepo(id string, request *ModifyRepoRequest) error {
|
||||
|
||||
repoCopy.Spec.Credential = *cred
|
||||
repoCopy.Spec.Url = parsedUrl.String()
|
||||
|
||||
// change repo name and description won't change version
|
||||
repoCopy.Spec.Version += 1
|
||||
}
|
||||
|
||||
patch := client.MergeFrom(repo)
|
||||
repoCopy.Spec.Version += 1
|
||||
data, err := patch.Data(repoCopy)
|
||||
if err != nil {
|
||||
klog.Error("create patch failed", err)
|
||||
@@ -238,16 +240,8 @@ func (c *repoOperator) DescribeRepo(id string) (*Repo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var desRepo Repo
|
||||
|
||||
desRepo.URL = repo.Spec.Url
|
||||
desRepo.Description = repo.Spec.Description
|
||||
desRepo.Name = repo.GetTrueName()
|
||||
desRepo.RepoId = repo.Name
|
||||
dt, _ := strfmt.ParseDateTime(repo.CreationTimestamp.String())
|
||||
desRepo.CreateTime = &dt
|
||||
|
||||
return &desRepo, nil
|
||||
retRepo := convertRepo(repo)
|
||||
return retRepo, nil
|
||||
}
|
||||
|
||||
func (c *repoOperator) ListRepos(conditions *params.Conditions, orderBy string, reverse bool, limit, offset int) (*models.PageableResponse, error) {
|
||||
|
||||
@@ -690,8 +690,8 @@ type Repo struct {
|
||||
// repository name
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// owner
|
||||
Owner string `json:"owner,omitempty"`
|
||||
// creator
|
||||
Creator string `json:"creator,omitempty"`
|
||||
|
||||
// runtime provider eg.[qingcloud|aliyun|aws|kubernetes]
|
||||
Providers []string `json:"providers"`
|
||||
|
||||
@@ -407,6 +407,10 @@ func convertRepo(in *v1alpha1.HelmRepo) *Repo {
|
||||
out.CreateTime = &date
|
||||
|
||||
out.Description = in.Spec.Description
|
||||
out.Creator = in.GetCreator()
|
||||
|
||||
cred, _ := json.Marshal(in.Spec.Credential)
|
||||
out.Credential = string(cred)
|
||||
|
||||
out.URL = in.Spec.Url
|
||||
return &out
|
||||
|
||||
Reference in New Issue
Block a user