Skip to content

Commit

Permalink
fix(registry): modify chart version restapi
Browse files Browse the repository at this point in the history
  • Loading branch information
jianzhuang authored and tke-robot committed Sep 3, 2020
1 parent 55a706a commit 15897f6
Show file tree
Hide file tree
Showing 19 changed files with 958 additions and 331 deletions.
93 changes: 93 additions & 0 deletions api/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/registry/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ type ChartVersion struct {
ChartSize int64
TimeCreated metav1.Time
Description string
AppVersion string
Icon string
}

// Visibility defines the visible properties of the repo or namespace.
Expand Down Expand Up @@ -355,6 +357,10 @@ type ChartInfoSpec struct {
Values map[string]string
// +optional
RawFiles map[string]string
// +optional
ChartSpec
// +optional
ChartVersion
}

// +genclient
Expand Down
363 changes: 270 additions & 93 deletions api/registry/v1/generated.pb.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions api/registry/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/registry/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ type ChartVersion struct {
ChartSize int64 `json:"chartSize,omitempty" protobuf:"varint,2,opt,name=chartSize"`
TimeCreated metav1.Time `json:"timeCreated,omitempty" protobuf:"bytes,3,opt,name=timeCreated"`
Description string `json:"description,omitempty" protobuf:"bytes,4,opt,name=description"`
AppVersion string `json:"appVersion,omitempty" protobuf:"bytes,5,opt,name=appVersion"`
Icon string `json:"icon,omitempty" protobuf:"bytes,6,opt,name=icon"`
}

// Visibility defines the visible properties of the repo or namespace.
Expand Down Expand Up @@ -358,6 +360,10 @@ type ChartInfoSpec struct {
Values map[string]string `json:"values,omitempty" protobuf:"bytes,2,opt,name=values"`
// +optional
RawFiles map[string]string `json:"rawFiles,omitempty" protobuf:"bytes,3,opt,name=rawFiles"`
// +optional
ChartSpec `json:",inline" protobuf:"bytes,4,opt,name=chartSpec"`
// +optional
ChartVersion `json:",inline" protobuf:"bytes,5,opt,name=chartVersion"`
}

// +genclient
Expand Down
16 changes: 16 additions & 0 deletions api/registry/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/registry/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/registry/v1/zz_generated.defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/registry/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/aws/aws-sdk-go v1.29.32
github.com/bitly/go-simplejson v0.5.0
github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0
github.com/casbin/casbin/v2 v2.2.1
github.com/chartmuseum/storage v0.8.0
github.com/coreos/go-oidc v2.2.1+incompatible
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembj
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0 h1:MnIURgMAFAMyxAHu8h2TbnjxMMd7SKVCPyTZz5EfwNA=
github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0/go.mod h1:hQL8hyiiVE/BSo7gh13njx+DpvoPh/yE8/BkKKc62RA=
github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8=
github.com/casbin/casbin/v2 v2.2.1 h1:ijrSMfBfbQlDc4LnMTGtGYWmhKuuR6RLSQRj8vHrMzc=
github.com/casbin/casbin/v2 v2.2.1/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
Expand Down Expand Up @@ -1325,12 +1327,14 @@ k8s.io/apimachinery v0.18.0/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftc
k8s.io/apimachinery v0.18.2 h1:44CmtbmkzVDAhCpRVSiP2R5PPrC2RtlIv/MoB8xpdRA=
k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA=
k8s.io/apimachinery v0.18.6 h1:RtFHnfGNfd1N0LeSrKCUznz5xtUP1elRGvHJbL3Ntag=
k8s.io/apimachinery v0.18.8 h1:jimPrycCqgx2QPearX3to1JePz7wSbVLq+7PdBTTwQ0=
k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad/go.mod h1:XPCXEwhjaFN29a8NldXA901ElnKeKLrLtREO9ZhFyhg=
k8s.io/apiserver v0.0.0-20191122221311-9d521947b1e1/go.mod h1:RbsZY5zzBIWnz4KbctZsTVjwIuOpTp4Z8oCgFHN4kZQ=
k8s.io/apiserver v0.18.0/go.mod h1:3S2O6FeBBd6XTo0njUrLxiqk8GNy6wWOftjhJcXYnjw=
k8s.io/apiserver v0.18.2 h1:fwKxdTWwwYhxvtjo0UUfX+/fsitsNtfErPNegH2x9ic=
k8s.io/apiserver v0.18.2/go.mod h1:Xbh066NqrZO8cbsoenCwyDJ1OSi8Ag8I2lezeHxzwzw=
k8s.io/apiserver v0.18.6 h1:HcWwcOfhj4Yv6y2igP4ZUuovyPjVLGoZcG0Tsph4Mxo=
k8s.io/apiserver v0.18.8 h1:Au4kMn8sb1zFdyKqc8iMHLsYLxRI6Y+iAhRNKKQtlBY=
k8s.io/cli-runtime v0.18.0/go.mod h1:1eXfmBsIJosjn9LjEBUd2WVPoPAY9XGTqTFcPMIBsUQ=
k8s.io/cli-runtime v0.18.2 h1:JiTN5RgkFNTiMxHBRyrl6n26yKWAuNRlei1ZJALUmC8=
k8s.io/cli-runtime v0.18.2/go.mod h1:yfFR2sQQzDsV0VEKGZtrJwEy4hLZ2oj4ZIfodgxAHWQ=
Expand Down
31 changes: 11 additions & 20 deletions pkg/registry/chartmuseum/authorization/create_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ func (a *authorization) afterAPICreateChart(ctx context.Context, chartGroup *reg
return err
}

newVersion := registry.ChartVersion{
Version: chartMeta.Version,
ChartSize: ctSize,
TimeCreated: metav1.Now(),
Description: chartMeta.Description,
AppVersion: chartMeta.AppVersion,
Icon: chartMeta.Icon,
}
if len(chartList.Items) == 0 {
if _, err := a.registryClient.Charts(chartGroup.ObjectMeta.Name).Create(ctx, &registry.Chart{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -188,14 +196,7 @@ func (a *authorization) afterAPICreateChart(ctx context.Context, chartGroup *reg
},
Status: registry.ChartStatus{
PullCount: 0,
Versions: []registry.ChartVersion{
{
Version: chartMeta.Version,
ChartSize: ctSize,
TimeCreated: metav1.Now(),
Description: chartMeta.Description,
},
},
Versions: []registry.ChartVersion{newVersion},
},
}, metav1.CreateOptions{}); err != nil {
log.Error("Failed to create chart while pushed chart",
Expand All @@ -213,12 +214,7 @@ func (a *authorization) afterAPICreateChart(ctx context.Context, chartGroup *reg
for k, v := range chartObject.Status.Versions {
if v.Version == chartMeta.Version {
existVersion = true
chartObject.Status.Versions[k] = registry.ChartVersion{
Version: chartMeta.Version,
ChartSize: ctSize,
TimeCreated: metav1.Now(),
Description: chartMeta.Description,
}
chartObject.Status.Versions[k] = newVersion
if _, err := a.registryClient.Charts(chartGroup.ObjectMeta.Name).UpdateStatus(ctx, &chartObject, metav1.UpdateOptions{}); err != nil {
log.Error("Failed to update chart version while chart pushed",
log.String("tenantID", chartGroup.Spec.TenantID),
Expand All @@ -234,12 +230,7 @@ func (a *authorization) afterAPICreateChart(ctx context.Context, chartGroup *reg
}

if !existVersion {
chartObject.Status.Versions = append(chartObject.Status.Versions, registry.ChartVersion{
Version: chartMeta.Version,
ChartSize: ctSize,
TimeCreated: metav1.Now(),
Description: chartMeta.Description,
})
chartObject.Status.Versions = append(chartObject.Status.Versions, newVersion)
if _, err := a.registryClient.Charts(chartGroup.ObjectMeta.Name).UpdateStatus(ctx, &chartObject, metav1.UpdateOptions{}); err != nil {
log.Error("Failed to create repository tag while received notification",
log.String("tenantID", chartGroup.Spec.TenantID),
Expand Down
Loading

0 comments on commit 15897f6

Please sign in to comment.