Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default chartVersion: "" to go redpanda's version #276

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceptance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cucumber/godog v0.14.1
github.com/go-logr/logr v1.4.2
github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1
github.com/redpanda-data/redpanda-operator/harpoon v0.0.0-00010101000000-000000000000
github.com/redpanda-data/redpanda-operator/operator v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 1 addition & 1 deletion acceptance/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b
github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b/go.mod h1:I7umqhnMhIOSEnIA3fvLtdQU7QO/SbWGCwFfFDs3De4=
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 h1:+zsE3W1V86k2sjAGWOySIlF0xn5R1aXXQBaIdr80F48=
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20/go.mod h1:DC42/3+k5PefSo4IalYbDN3yRZrVFP0b69+gC/NwGd4=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a h1:kNx8tH6z02nJctZS+oYt7LOWWoZgfMW4Ktees89GTh0=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1 h1:Z1dclhzMIk83tZIa+aXqmojZZ2R03DvtXAfxWpWOqug=
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 h1:uTQKqF8UPNxYxKBJ11VlG6Vt2l9ctkkeXsmmjHUSUG4=
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8/go.mod h1:97qkjcMI3gDL+y+aY/w5o0xF2qGHFof6rCXIYjnTalM=
github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA=
Expand Down
2 changes: 1 addition & 1 deletion harpoon/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cucumber/godog v0.14.1
github.com/cucumber/messages/go/v21 v21.0.1
github.com/olekukonko/tablewriter v0.0.5
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
k8s.io/api v0.30.3
Expand Down
2 changes: 1 addition & 1 deletion harpoon/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a h1:kNx8tH6z02nJctZS+oYt7LOWWoZgfMW4Ktees89GTh0=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1 h1:Z1dclhzMIk83tZIa+aXqmojZZ2R03DvtXAfxWpWOqug=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
Expand Down
2 changes: 1 addition & 1 deletion operator/api/redpanda/v1alpha2/redpanda_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type ChartRef struct {
// UseFlux flag set to `false` will prevent helm controller from reconciling helm chart. The operator would be
// tight with `go` based Redpanda helm chart version. The rest of the ChartRef fields would be ignored.
//
// Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.3`
// Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.9`
// version of the Redpanda chart.
//
// RedpandaStatus might not be accurate if flag is set to `false` and HelmRelease is manually deleted.
Expand Down
15 changes: 15 additions & 0 deletions operator/api/redpanda/v1alpha2/redpanda_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/redpanda-data/helm-charts/charts/redpanda"
"github.com/redpanda-data/redpanda-operator/operator/api/apiutil"
"github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha2"
crds "github.com/redpanda-data/redpanda-operator/operator/config/crd/bases"
"github.com/redpanda-data/redpanda-operator/operator/internal/testutils"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -64,6 +65,20 @@ var (
})
)

func TestDefluxedMinimumVersion(t *testing.T) {
crd := crds.Redpanda()
// 0 is v1alpha1 and 1 is v1alpha2
recursiveProperties := crd.Spec.Versions[1].Schema.OpenAPIV3Schema.Properties

require.Containsf(
t,
recursiveProperties["spec"].Properties["chartRef"].Properties["useFlux"].Description,
redpanda.Chart.Metadata().Version,
"'useFlux' should reference the version %q of the go.mod installed redpanda chart. Do you need to run 'task generate' or update the comment?",
redpanda.Chart.Metadata().Version,
)
}

// TestRedpanda_ValuesJSON asserts that .ValuesJSON appropriately coalesces the
// value of CloudStorageEnabled into a boolean.
// NOTE: This test is close to being a duplicate of apiutil.JSONBoolean's tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ spec:
UseFlux flag set to `false` will prevent helm controller from reconciling helm chart. The operator would be
tight with `go` based Redpanda helm chart version. The rest of the ChartRef fields would be ignored.

Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.3`
Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.9`
version of the Redpanda chart.

RedpandaStatus might not be accurate if flag is set to `false` and HelmRelease is manually deleted.
Expand Down Expand Up @@ -9905,7 +9905,7 @@ spec:
UseFlux flag set to `false` will prevent helm controller from reconciling helm chart. The operator would be
tight with `go` based Redpanda helm chart version. The rest of the ChartRef fields would be ignored.

Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.3`
Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.9`
version of the Redpanda chart.

RedpandaStatus might not be accurate if flag is set to `false` and HelmRelease is manually deleted.
Expand Down
111 changes: 111 additions & 0 deletions operator/config/crd/bases/crds.go
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)
}
}
45 changes: 45 additions & 0 deletions operator/config/crd/bases/crds_test.go
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)
}
37 changes: 0 additions & 37 deletions operator/config/crd/bases/redpanda_controller_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/cert-manager/cert-manager v1.14.5
github.com/cisco-open/k8s-objectmatcher v1.9.0
github.com/cloudhut/common v0.10.0
github.com/cockroachdb/errors v1.11.1
github.com/distribution/reference v0.6.0
github.com/fluxcd/helm-controller/api v0.37.2
github.com/fluxcd/helm-controller/shim v0.0.0-00010101000000-000000000000
Expand All @@ -27,7 +28,7 @@ require (
github.com/prometheus/common v0.55.0
github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8
github.com/scalalang2/golang-fifo v1.0.2
github.com/spf13/afero v1.11.0
Expand Down Expand Up @@ -138,7 +139,6 @@ require (
github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 // indirect
github.com/clbanning/mxj/v2 v2.7.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
Expand Down
4 changes: 2 additions & 2 deletions operator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ github.com/redpanda-data/flux-controller-shim/helm/shim v0.0.0-20231227162419-a4
github.com/redpanda-data/flux-controller-shim/helm/shim v0.0.0-20231227162419-a45126310240/go.mod h1:5KLXArOMFOrwb3BihpFaRNiPCyo9AXsXhvMdUmrCdUg=
github.com/redpanda-data/flux-controller-shim/source/shim v0.0.0-20240113100428-5e301ef97b19 h1:sJjDhnIbTMOuP4Rnhm1N3GNfgv6BJlocCnGliNvhgbw=
github.com/redpanda-data/flux-controller-shim/source/shim v0.0.0-20240113100428-5e301ef97b19/go.mod h1:T39OECA7eOlhpHZPBSGg+bpuwtt/G4m03fjBkJ821CM=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a h1:kNx8tH6z02nJctZS+oYt7LOWWoZgfMW4Ktees89GTh0=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a/go.mod h1:TqCaTv9K8+VbAeZHlR/OqHVksTlj0HYAzDkUEtZNyZc=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1 h1:Z1dclhzMIk83tZIa+aXqmojZZ2R03DvtXAfxWpWOqug=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1/go.mod h1:dmmGZo7DuHNnCy0QOykXN2sY9QI8kbdlkSKgIkCT978=
github.com/redpanda-data/helm-controller v0.37.3-0.20240119022335-c90fadbd044e h1:8HB05vSCY+0MwjT2DIVq6gJV5iw7nQNIDfMqcc1NEC8=
github.com/redpanda-data/helm-controller v0.37.3-0.20240119022335-c90fadbd044e/go.mod h1:jF5kbQy3qT/zufL27DE3lecfYTRWeAzSiVmrbDDQwUw=
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 h1:uTQKqF8UPNxYxKBJ11VlG6Vt2l9ctkkeXsmmjHUSUG4=
Expand Down
Loading