Skip to content

Commit

Permalink
Move CRD list logic to CRD package for other packages to consume
Browse files Browse the repository at this point in the history
Signed-off-by: Arvind Iyengar <[email protected]>
  • Loading branch information
Arvind Iyengar authored and brandond committed Sep 7, 2022
1 parent d123709 commit e64bc27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
17 changes: 3 additions & 14 deletions hack/crdgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,11 @@ package main
import (
"os"

v1 "github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io/v1"
"github.com/k3s-io/helm-controller/pkg/crd"
_ "github.com/k3s-io/helm-controller/pkg/generated/controllers/helm.cattle.io/v1"
"github.com/rancher/wrangler/pkg/crd"
wcrd "github.com/rancher/wrangler/pkg/crd"
)

func main() {
chart := crd.NamespacedType("HelmChart.helm.cattle.io/v1").
WithSchemaFromStruct(v1.HelmChart{}).
WithColumn("Job", ".status.jobName").
WithColumn("Chart", ".spec.chart").
WithColumn("TargetNamespace", ".spec.targetNamespace").
WithColumn("Version", ".spec.version").
WithColumn("Repo", ".spec.repo").
WithColumn("HelmVersion", ".spec.helmVersion").
WithColumn("Bootstrap", ".spec.bootstrap")
config := crd.NamespacedType("HelmChartConfig.helm.cattle.io/v1").
WithSchemaFromStruct(v1.HelmChartConfig{})
crd.Print(os.Stdout, []crd.CRD{chart, config})
wcrd.Print(os.Stdout, crd.List())
}
23 changes: 23 additions & 0 deletions pkg/crd/crds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package crd

import (
v1 "github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io/v1"
"github.com/rancher/wrangler/pkg/crd"
)

func List() []crd.CRD {
chart := crd.NamespacedType("HelmChart.helm.cattle.io/v1").
WithSchemaFromStruct(v1.HelmChart{}).
WithColumn("Job", ".status.jobName").
WithColumn("Chart", ".spec.chart").
WithColumn("TargetNamespace", ".spec.targetNamespace").
WithColumn("Version", ".spec.version").
WithColumn("Repo", ".spec.repo").
WithColumn("HelmVersion", ".spec.helmVersion").
WithColumn("Bootstrap", ".spec.bootstrap")

config := crd.NamespacedType("HelmChartConfig.helm.cattle.io/v1").
WithSchemaFromStruct(v1.HelmChartConfig{})

return []crd.CRD{chart, config}
}

0 comments on commit e64bc27

Please sign in to comment.