@@ -401,6 +401,18 @@ func convertAppVersion(in *v1alpha1.HelmApplicationVersion) *AppVersion {
|
||||
out.Icon = in.Spec.Icon
|
||||
}
|
||||
|
||||
// The field Maintainers and Sources were a string field, so I encode the helm field's maintainers and sources,
|
||||
// which are array, to string.
|
||||
if len(in.Spec.Maintainers) > 0 {
|
||||
maintainers, _ := json.Marshal(in.Spec.Maintainers)
|
||||
out.Maintainers = string(maintainers)
|
||||
}
|
||||
|
||||
if len(in.Spec.Sources) > 0 {
|
||||
source, _ := json.Marshal(in.Spec.Sources)
|
||||
out.Sources = string(source)
|
||||
}
|
||||
|
||||
out.Status = in.State()
|
||||
out.Owner = in.GetCreator()
|
||||
out.Name = in.GetVersionName()
|
||||
@@ -565,6 +577,8 @@ func buildApplicationVersion(app *v1alpha1.HelmApplication, chrt helmrepoindex.V
|
||||
Icon: chrt.GetIcon(),
|
||||
Home: chrt.GetHome(),
|
||||
Description: stringutils.ShortenString(chrt.GetDescription(), v1alpha1.MsgLen),
|
||||
Sources: chrt.GetRawSources(),
|
||||
Maintainers: chrt.GetRawMaintainers(),
|
||||
},
|
||||
Created: &t,
|
||||
// set data to nil before save app version to etcd
|
||||
|
||||
@@ -16,7 +16,11 @@ limitations under the License.
|
||||
|
||||
package helmrepoindex
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"kubesphere.io/api/application/v1alpha1"
|
||||
)
|
||||
|
||||
type VersionInterface interface {
|
||||
GetName() string
|
||||
@@ -28,8 +32,10 @@ type VersionInterface interface {
|
||||
GetIcon() string
|
||||
GetHome() string
|
||||
GetSources() string
|
||||
GetRawSources() []string
|
||||
GetKeywords() string
|
||||
GetMaintainers() string
|
||||
GetRawMaintainers() []*v1alpha1.Maintainer
|
||||
GetScreenshots() string
|
||||
GetPackageName() string
|
||||
GetCreateTime() time.Time
|
||||
|
||||
@@ -23,6 +23,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"kubesphere.io/api/application/v1alpha1"
|
||||
|
||||
"helm.sh/helm/v3/pkg/repo"
|
||||
"k8s.io/klog"
|
||||
|
||||
@@ -64,10 +66,27 @@ func (h HelmVersionWrapper) GetSources() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func (h HelmVersionWrapper) GetRawSources() []string {
|
||||
return h.Sources
|
||||
}
|
||||
|
||||
func (h HelmVersionWrapper) GetKeywords() string {
|
||||
return strings.Join(h.ChartVersion.Keywords, ",")
|
||||
}
|
||||
|
||||
func (h HelmVersionWrapper) GetRawMaintainers() []*v1alpha1.Maintainer {
|
||||
mt := make([]*v1alpha1.Maintainer, 0, len(h.Maintainers))
|
||||
for _, value := range h.Maintainers {
|
||||
mt = append(mt, &v1alpha1.Maintainer{
|
||||
URL: value.URL,
|
||||
Name: value.Name,
|
||||
Email: value.Email,
|
||||
})
|
||||
|
||||
}
|
||||
return mt
|
||||
}
|
||||
|
||||
func (h HelmVersionWrapper) GetMaintainers() string {
|
||||
if len(h.ChartVersion.Maintainers) == 0 {
|
||||
return ""
|
||||
|
||||
@@ -273,7 +273,7 @@ func (c *cachedRepos) addRepo(repo *v1alpha1.HelmRepo, builtin bool) error {
|
||||
// build all the versions of this app
|
||||
for _, chartVersion := range app.Charts {
|
||||
chartsCount += 1
|
||||
|
||||
hvw := helmrepoindex.HelmVersionWrapper{ChartVersion: &chartVersion.ChartVersion}
|
||||
appVerName = chartVersion.ApplicationVersionId
|
||||
version := &v1alpha1.HelmApplicationVersion{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -287,9 +287,9 @@ func (c *cachedRepos) addRepo(repo *v1alpha1.HelmRepo, builtin bool) error {
|
||||
},
|
||||
Spec: v1alpha1.HelmApplicationVersionSpec{
|
||||
Metadata: &v1alpha1.Metadata{
|
||||
Name: chartVersion.Name,
|
||||
AppVersion: chartVersion.AppVersion,
|
||||
Version: chartVersion.Version,
|
||||
Name: hvw.GetName(),
|
||||
AppVersion: hvw.GetAppVersion(),
|
||||
Version: hvw.GetVersion(),
|
||||
},
|
||||
URLs: chartVersion.URLs,
|
||||
Digest: chartVersion.Digest,
|
||||
@@ -299,6 +299,13 @@ func (c *cachedRepos) addRepo(repo *v1alpha1.HelmRepo, builtin bool) error {
|
||||
State: v1alpha1.StateActive,
|
||||
},
|
||||
}
|
||||
|
||||
// It is not necessary to store these pieces of information when this is not a built-in repo.
|
||||
if helmrepoindex.IsBuiltInRepo(repo.Name) {
|
||||
version.Spec.Sources = hvw.GetRawSources()
|
||||
version.Spec.Maintainers = hvw.GetRawMaintainers()
|
||||
version.Spec.Home = hvw.GetHome()
|
||||
}
|
||||
c.versions[chartVersion.ApplicationVersionId] = version
|
||||
|
||||
// Find the latest version.
|
||||
|
||||
Reference in New Issue
Block a user