Skip to content

Commit

Permalink
Merge pull request #45 from wansir/master
Browse files Browse the repository at this point in the history
update extension template
  • Loading branch information
wansir committed Aug 3, 2023
2 parents cfc62e9 + 39d64ba commit 7b778d1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
15 changes: 8 additions & 7 deletions pkg/extension/templates/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ home: https://kubesphere.io
sources:
- https://github.com/kubesphere
kubeVersion: ">=1.19.0"
ksVersion: ">=3.0.0"
ksVersion: ">=4.0.0-alpha"
maintainers:
- name: "[[ .Author ]]"
email: "[[ .Email ]]"
Expand All @@ -24,19 +24,20 @@ provider:
name: "[[ .Author ]]"
email: "[[ .Email ]]"
url: "[[ .URL ]]"
# All static files need to be placed in the same directory,
# including the icon/screenshots below and the images referenced in the README file.
staticFileDirectory: static
icon: ./static/favicon.svg
screenshots:
- ./static/screenshots/screenshot.png
dependencies:
- name: frontend
condition: frontend.enabled
tags:
- extension
- name: backend
condition: backend.enabled
tags:
- agent
# installationMode describes how to install subcharts, it can be HostOnly or Multicluster.
#installationMode: Multicluster
# In Multicluster mode, the subchart with tag `extension` will only be deployed to the host cluster,
# and the subchart with tag `agent` will be deployed to all selected clusters.
installationMode: HostOnly
# external dependencies example
#externalDependencies:
# - name: a
Expand Down
33 changes: 16 additions & 17 deletions pkg/extension/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,22 @@ var Categories = []string{
type Metadata struct {
APIVersion string `json:"apiVersion" validate:"required"`
// The name of the chart. Required.
Name string `json:"name" validate:"required"`
Version string `json:"version" validate:"required"`
DisplayName Locales `json:"displayName" validate:"required"`
Description Locales `json:"description" validate:"required"`
Category string `json:"category" validate:"required"`
Keywords []string `json:"keywords,omitempty"`
Home string `json:"home,omitempty"`
Sources []string `json:"sources,omitempty"`
KubeVersion string `json:"kubeVersion,omitempty"`
KSVersion string `json:"ksVersion,omitempty"`
Maintainers []*chart.Maintainer `json:"maintainers,omitempty"`
Provider map[LanguageCode]*chart.Maintainer `json:"provider" validate:"required"`
StaticFileDirectory string `json:"staticFileDirectory" validate:"required"`
Icon string `json:"icon" validate:"required"`
Screenshots []string `json:"screenshots,omitempty"`
Dependencies []*chart.Dependency `json:"dependencies,omitempty"`
InstallationMode string `json:"installationMode,omitempty"`
Name string `json:"name" validate:"required"`
Version string `json:"version" validate:"required"`
DisplayName Locales `json:"displayName" validate:"required"`
Description Locales `json:"description" validate:"required"`
Category string `json:"category" validate:"required"`
Keywords []string `json:"keywords,omitempty"`
Home string `json:"home,omitempty"`
Sources []string `json:"sources,omitempty"`
KubeVersion string `json:"kubeVersion,omitempty"`
KSVersion string `json:"ksVersion,omitempty"`
Maintainers []*chart.Maintainer `json:"maintainers,omitempty"`
Provider map[LanguageCode]*chart.Maintainer `json:"provider" validate:"required"`
Icon string `json:"icon" validate:"required"`
Screenshots []string `json:"screenshots,omitempty"`
Dependencies []*chart.Dependency `json:"dependencies,omitempty"`
InstallationMode string `json:"installationMode,omitempty"`
}

func (md *Metadata) Validate() error {
Expand Down
42 changes: 20 additions & 22 deletions pkg/parser/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ import (
)

type Extension struct {
ChartMetadata *chart.Metadata
DisplayName extension.Locales
Description extension.Locales
README extension.Locales
Changelog extension.Locales
Category string
KSVersion string
StaticFileDirectory string
Screenshots []string
Provider map[extension.LanguageCode]*chart.Maintainer
SupportedLanguages []extension.LanguageCode
ChartMetadata *chart.Metadata
DisplayName extension.Locales
Description extension.Locales
README extension.Locales
Changelog extension.Locales
Category string
KSVersion string
Screenshots []string
Provider map[extension.LanguageCode]*chart.Maintainer
SupportedLanguages []extension.LanguageCode
}

func ParseExtension(name string, zipFile []byte) (*Extension, error) {
Expand Down Expand Up @@ -66,17 +65,16 @@ func ParseExtension(name string, zipFile []byte) (*Extension, error) {
}

return &Extension{
ChartMetadata: chartMetadata,
DisplayName: metadata.DisplayName,
Description: metadata.Description,
KSVersion: metadata.KSVersion,
README: readmeData,
Changelog: changelogData,
Category: metadata.Category,
StaticFileDirectory: metadata.StaticFileDirectory,
Screenshots: metadata.Screenshots,
Provider: metadata.Provider,
SupportedLanguages: supportedLanguages,
ChartMetadata: chartMetadata,
DisplayName: metadata.DisplayName,
Description: metadata.Description,
KSVersion: metadata.KSVersion,
README: readmeData,
Changelog: changelogData,
Category: metadata.Category,
Screenshots: metadata.Screenshots,
Provider: metadata.Provider,
SupportedLanguages: supportedLanguages,
}, nil
}

Expand Down

0 comments on commit 7b778d1

Please sign in to comment.