Merge pull request #3651 from xyz-li/app-fix
Fix: fix app repo and helm app bugs
This commit is contained in:
@@ -87,6 +87,9 @@ func (r *ReconcileHelmApplication) Reconcile(request reconcile.Request) (reconci
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// app has changed, update app status
|
||||
return reconcile.Result{}, updateHelmApplicationStatus(r.Client, strings.TrimSuffix(app.Name, v1alpha1.HelmApplicationAppStoreSuffix), inAppStore(app))
|
||||
} else {
|
||||
// delete app copy in appStore
|
||||
if !inAppStore(app) {
|
||||
@@ -164,11 +167,6 @@ func (r *ReconcileHelmApplication) createAppCopyInAppStore(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
if app.Status.State == "" {
|
||||
// update status if needed
|
||||
return updateHelmApplicationStatus(r.Client, originApp.Name, true)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -242,6 +242,7 @@ func (c *applicationOperator) CreateApp(req *CreateAppRequest) (*CreateAppRespon
|
||||
Spec: v1alpha1.HelmApplicationSpec{
|
||||
Name: req.Name,
|
||||
Description: stringutils.ShortenString(chrt.GetDescription(), v1alpha1.MsgLen),
|
||||
Icon: stringutils.ShortenString(chrt.GetIcon(), v1alpha1.MsgLen),
|
||||
},
|
||||
}
|
||||
app, err := c.createApp(helmApp, req.Icon)
|
||||
|
||||
@@ -230,7 +230,11 @@ func (c *applicationOperator) ListAppVersionReviews(conditions *params.Condition
|
||||
items := make([]interface{}, 0, len(filtered))
|
||||
|
||||
for i, j := offset, 0; i < len(filtered) && j < limit; i, j = i+1, j+1 {
|
||||
review := convertAppVersionReview(filtered[i])
|
||||
app, err := c.appLister.Get(filtered[i].GetHelmApplicationId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
review := convertAppVersionReview(app, filtered[i])
|
||||
items = append(items, review)
|
||||
}
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package openpitrix
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"regexp"
|
||||
@@ -406,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
|
||||
@@ -754,7 +759,7 @@ func attachmentKeyInStorage(ws, id string) string {
|
||||
return path.Join(ws, id)
|
||||
}
|
||||
|
||||
func convertAppVersionReview(appVersion *v1alpha1.HelmApplicationVersion) *AppVersionReview {
|
||||
func convertAppVersionReview(app *v1alpha1.HelmApplication, appVersion *v1alpha1.HelmApplicationVersion) *AppVersionReview {
|
||||
review := &AppVersionReview{}
|
||||
status := appVersion.Status
|
||||
review.Reviewer = status.Audit[0].Operator
|
||||
@@ -766,7 +771,7 @@ func convertAppVersionReview(appVersion *v1alpha1.HelmApplicationVersion) *AppVe
|
||||
review.VersionName = appVersion.GetVersionName()
|
||||
|
||||
review.StatusTime = strfmt.DateTime(status.Audit[0].Time.Time)
|
||||
review.AppName = appVersion.GetTrueName()
|
||||
review.AppName = app.GetTrueName()
|
||||
return review
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user