-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
default
chartVersion: ""
to go redpanda's version
Prior to this commit `chartVersion` would default to the latest version of the redpanda chart available at the time the helm repository controller ran. This ended up being more confusing and possibly dangerous than it did being convenient. Our documentation has begun telling users to explicitly pin `chartVersion` themselves for stability. Additionally, such functionality complicated the incipient de-fluxing migration. To resolve the above, this commit has changed the behavior to instead default `chartVersion` to the version of the redpanda chart that's installed via the `go.mod` file. At the time of this commit, that version is 5.9.9.
- Loading branch information
1 parent
4976e07
commit 87317b4
Showing
14 changed files
with
208 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
// Package crds provide programmatic access to the CRDs generated by | ||
// controller-gen. | ||
package crds | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
|
||
"github.com/cockroachdb/errors" | ||
"github.com/redpanda-data/helm-charts/pkg/kube" | ||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
var ( | ||
//go:embed *.yaml | ||
//go:embed toolkit.fluxcd.io/*.yaml | ||
crdFS embed.FS | ||
|
||
crds []*apiextensionsv1.CustomResourceDefinition | ||
byName map[string]*apiextensionsv1.CustomResourceDefinition | ||
) | ||
|
||
func init() { | ||
scheme := runtime.NewScheme() | ||
must(apiextensionsv1.AddToScheme(scheme)) | ||
|
||
byName = map[string]*apiextensionsv1.CustomResourceDefinition{} | ||
|
||
must(fs.WalkDir(crdFS, ".", func(path string, d fs.DirEntry, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if d.IsDir() { | ||
return nil | ||
} | ||
|
||
data, err := fs.ReadFile(crdFS, path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
objs, err := kube.DecodeYAML(data, scheme) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, obj := range objs { | ||
crd := obj.(*apiextensionsv1.CustomResourceDefinition) | ||
|
||
crds = append(crds, crd) | ||
byName[crd.Name] = crd | ||
} | ||
|
||
return nil | ||
})) | ||
} | ||
|
||
func ByName(name string) (*apiextensionsv1.CustomResourceDefinition, error) { | ||
crd, ok := byName[name] | ||
if !ok { | ||
return nil, errors.Newf("no such CRD %q", name) | ||
} | ||
return crd, nil | ||
} | ||
|
||
func All() []*apiextensionsv1.CustomResourceDefinition { | ||
ret := make([]*apiextensionsv1.CustomResourceDefinition, len(crds)) | ||
|
||
for i, crd := range crds { | ||
ret[i] = crd.DeepCopy() | ||
} | ||
|
||
return ret | ||
} | ||
|
||
// Redpanda returns the Redpanda CustomResourceDefinition. | ||
func Redpanda() *apiextensionsv1.CustomResourceDefinition { | ||
return mustT(ByName("redpandas.cluster.redpanda.com")) | ||
} | ||
|
||
// Topic returns the Redpanda CustomResourceDefinition. | ||
func Topic() *apiextensionsv1.CustomResourceDefinition { | ||
return mustT(ByName("topics.cluster.redpanda.com")) | ||
} | ||
|
||
// Topic returns the Redpanda CustomResourceDefinition. | ||
func User() *apiextensionsv1.CustomResourceDefinition { | ||
return mustT(ByName("users.cluster.redpanda.com")) | ||
} | ||
|
||
func mustT[T any](r T, err error) T { | ||
must(err) | ||
return r | ||
} | ||
|
||
func must(err error) { | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
package crds_test | ||
|
||
import ( | ||
"testing" | ||
|
||
crds "github.com/redpanda-data/redpanda-operator/operator/config/crd/bases" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCRDS(t *testing.T) { | ||
names := map[string]struct{}{ | ||
"buckets.source.toolkit.fluxcd.io": {}, | ||
"clusters.redpanda.vectorized.io": {}, | ||
"consoles.redpanda.vectorized.io": {}, | ||
"gitrepositories.source.toolkit.fluxcd.io": {}, | ||
"helmcharts.source.toolkit.fluxcd.io": {}, | ||
"helmreleases.helm.toolkit.fluxcd.io": {}, | ||
"helmrepositories.source.toolkit.fluxcd.io": {}, | ||
"ocirepositories.source.toolkit.fluxcd.io": {}, | ||
"redpandas.cluster.redpanda.com": {}, | ||
"schemas.cluster.redpanda.com": {}, | ||
"topics.cluster.redpanda.com": {}, | ||
"users.cluster.redpanda.com": {}, | ||
} | ||
|
||
foundNames := map[string]struct{}{} | ||
for _, crd := range crds.All() { | ||
foundNames[crd.Name] = struct{}{} | ||
} | ||
|
||
require.Equal(t, names, foundNames) | ||
|
||
require.Equal(t, "redpandas.cluster.redpanda.com", crds.Redpanda().Name) | ||
require.Equal(t, "topics.cluster.redpanda.com", crds.Topic().Name) | ||
require.Equal(t, "users.cluster.redpanda.com", crds.User().Name) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.