Skip to content

Commit

Permalink
Create CRDs with schema
Browse files Browse the repository at this point in the history
Fixes an issue where CRDs were being created without schema, allowing
resources with invalid content to be created, later stalling the
controller ListWatch event channel when the invalid resources could not
be deserialized.

Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Apr 18, 2023
1 parent 257fa2c commit 7e26671
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions pkg/crd/crds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package crd

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

func List() []crd.CRD {
addon := crd.NamespacedType("Addon.k3s.cattle.io/v1").
WithSchemaFromStruct(v1.Addon{}).
WithColumn("Source", ".status.source").
WithColumn("Checksum", ".status.checksum")

return []crd.CRD{addon}
}
8 changes: 4 additions & 4 deletions pkg/server/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"os"
"runtime"

helmcrd "github.com/k3s-io/helm-controller/pkg/crd"
"github.com/k3s-io/helm-controller/pkg/generated/controllers/helm.cattle.io"
addoncrd "github.com/k3s-io/k3s/pkg/crd"
"github.com/k3s-io/k3s/pkg/deploy"
"github.com/k3s-io/k3s/pkg/generated/controllers/k3s.cattle.io"
"github.com/k3s-io/k3s/pkg/version"
Expand Down Expand Up @@ -82,10 +84,8 @@ func crds(ctx context.Context, config *rest.Config) error {
return err
}

factory.BatchCreateCRDs(ctx, crd.NamespacedTypes(
"Addon.k3s.cattle.io/v1",
"HelmChart.helm.cattle.io/v1",
"HelmChartConfig.helm.cattle.io/v1")...)
types := append(helmcrd.List(), addoncrd.List()...)
factory.BatchCreateCRDs(ctx, types...)

return factory.BatchWait()
}

0 comments on commit 7e26671

Please sign in to comment.