auto-generate configuration CRD (#3102)

* auto-generate configuration CRD
* make all subconfig optional
* remove field enable crd validation
* update field descriptions which use proxy types
This commit is contained in:
Felix Kunde
2026-06-22 10:44:46 +02:00
committed by GitHub
parent e4e686588e
commit a664816c09
20 changed files with 2662 additions and 2249 deletions
@@ -32,18 +32,26 @@ import (
// fakeOperatorConfigurations implements OperatorConfigurationInterface
type fakeOperatorConfigurations struct {
*gentype.FakeClient[*v1.OperatorConfiguration]
*gentype.FakeClientWithList[*v1.OperatorConfiguration, *v1.OperatorConfigurationList]
Fake *FakeAcidV1
}
func newFakeOperatorConfigurations(fake *FakeAcidV1, namespace string) acidzalandov1.OperatorConfigurationInterface {
return &fakeOperatorConfigurations{
gentype.NewFakeClient[*v1.OperatorConfiguration](
gentype.NewFakeClientWithList[*v1.OperatorConfiguration, *v1.OperatorConfigurationList](
fake.Fake,
namespace,
v1.SchemeGroupVersion.WithResource("operatorconfigurations"),
v1.SchemeGroupVersion.WithKind("OperatorConfiguration"),
func() *v1.OperatorConfiguration { return &v1.OperatorConfiguration{} },
func() *v1.OperatorConfigurationList { return &v1.OperatorConfigurationList{} },
func(dst, src *v1.OperatorConfigurationList) { dst.ListMeta = src.ListMeta },
func(list *v1.OperatorConfigurationList) []*v1.OperatorConfiguration {
return gentype.ToPointerSlice(list.Items)
},
func(list *v1.OperatorConfigurationList, items []*v1.OperatorConfiguration) {
list.Items = gentype.FromPointerSlice(items)
},
),
fake,
}
@@ -30,6 +30,8 @@ import (
acidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
scheme "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
gentype "k8s.io/client-go/gentype"
)
@@ -41,24 +43,32 @@ type OperatorConfigurationsGetter interface {
// OperatorConfigurationInterface has methods to work with OperatorConfiguration resources.
type OperatorConfigurationInterface interface {
Create(ctx context.Context, operatorConfiguration *acidzalandov1.OperatorConfiguration, opts metav1.CreateOptions) (*acidzalandov1.OperatorConfiguration, error)
Update(ctx context.Context, operatorConfiguration *acidzalandov1.OperatorConfiguration, opts metav1.UpdateOptions) (*acidzalandov1.OperatorConfiguration, error)
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
Get(ctx context.Context, name string, opts metav1.GetOptions) (*acidzalandov1.OperatorConfiguration, error)
List(ctx context.Context, opts metav1.ListOptions) (*acidzalandov1.OperatorConfigurationList, error)
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *acidzalandov1.OperatorConfiguration, err error)
OperatorConfigurationExpansion
}
// operatorConfigurations implements OperatorConfigurationInterface
type operatorConfigurations struct {
*gentype.Client[*acidzalandov1.OperatorConfiguration]
*gentype.ClientWithList[*acidzalandov1.OperatorConfiguration, *acidzalandov1.OperatorConfigurationList]
}
// newOperatorConfigurations returns a OperatorConfigurations
func newOperatorConfigurations(c *AcidV1Client, namespace string) *operatorConfigurations {
return &operatorConfigurations{
gentype.NewClient[*acidzalandov1.OperatorConfiguration](
gentype.NewClientWithList[*acidzalandov1.OperatorConfiguration, *acidzalandov1.OperatorConfigurationList](
"operatorconfigurations",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *acidzalandov1.OperatorConfiguration { return &acidzalandov1.OperatorConfiguration{} },
func() *acidzalandov1.OperatorConfigurationList { return &acidzalandov1.OperatorConfigurationList{} },
),
}
}
@@ -30,6 +30,8 @@ import (
// Interface provides access to all the informers in this group version.
type Interface interface {
// OperatorConfigurations returns a OperatorConfigurationInformer.
OperatorConfigurations() OperatorConfigurationInformer
// PostgresTeams returns a PostgresTeamInformer.
PostgresTeams() PostgresTeamInformer
// Postgresqls returns a PostgresqlInformer.
@@ -47,6 +49,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// OperatorConfigurations returns a OperatorConfigurationInformer.
func (v *version) OperatorConfigurations() OperatorConfigurationInformer {
return &operatorConfigurationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// PostgresTeams returns a PostgresTeamInformer.
func (v *version) PostgresTeams() PostgresTeamInformer {
return &postgresTeamInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
@@ -0,0 +1,96 @@
/*
Copyright 2026 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Code generated by informer-gen. DO NOT EDIT.
package v1
import (
context "context"
time "time"
apisacidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
versioned "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces"
acidzalandov1 "github.com/zalando/postgres-operator/pkg/generated/listers/acid.zalan.do/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
)
// OperatorConfigurationInformer provides access to a shared informer and lister for
// OperatorConfigurations.
type OperatorConfigurationInformer interface {
Informer() cache.SharedIndexInformer
Lister() acidzalandov1.OperatorConfigurationLister
}
type operatorConfigurationInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewOperatorConfigurationInformer constructs a new informer for OperatorConfiguration type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewOperatorConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredOperatorConfigurationInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredOperatorConfigurationInformer constructs a new informer for OperatorConfiguration type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredOperatorConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AcidV1().OperatorConfigurations(namespace).List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.AcidV1().OperatorConfigurations(namespace).Watch(context.TODO(), options)
},
},
&apisacidzalandov1.OperatorConfiguration{},
resyncPeriod,
indexers,
)
}
func (f *operatorConfigurationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredOperatorConfigurationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *operatorConfigurationInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apisacidzalandov1.OperatorConfiguration{}, f.defaultInformer)
}
func (f *operatorConfigurationInformer) Lister() acidzalandov1.OperatorConfigurationLister {
return acidzalandov1.NewOperatorConfigurationLister(f.Informer().GetIndexer())
}
@@ -60,6 +60,8 @@ func (f *genericInformer) Lister() cache.GenericLister {
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=acid.zalan.do, Version=v1
case v1.SchemeGroupVersion.WithResource("operatorconfigurations"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Acid().V1().OperatorConfigurations().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("postgresteams"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Acid().V1().PostgresTeams().Informer()}, nil
case v1.SchemeGroupVersion.WithResource("postgresqls"):
@@ -24,6 +24,14 @@ SOFTWARE.
package v1
// OperatorConfigurationListerExpansion allows custom methods to be added to
// OperatorConfigurationLister.
type OperatorConfigurationListerExpansion interface{}
// OperatorConfigurationNamespaceListerExpansion allows custom methods to be added to
// OperatorConfigurationNamespaceLister.
type OperatorConfigurationNamespaceListerExpansion interface{}
// PostgresTeamListerExpansion allows custom methods to be added to
// PostgresTeamLister.
type PostgresTeamListerExpansion interface{}
@@ -0,0 +1,76 @@
/*
Copyright 2026 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1
import (
acidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
labels "k8s.io/apimachinery/pkg/labels"
listers "k8s.io/client-go/listers"
cache "k8s.io/client-go/tools/cache"
)
// OperatorConfigurationLister helps list OperatorConfigurations.
// All objects returned here must be treated as read-only.
type OperatorConfigurationLister interface {
// List lists all OperatorConfigurations in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*acidzalandov1.OperatorConfiguration, err error)
// OperatorConfigurations returns an object that can list and get OperatorConfigurations.
OperatorConfigurations(namespace string) OperatorConfigurationNamespaceLister
OperatorConfigurationListerExpansion
}
// operatorConfigurationLister implements the OperatorConfigurationLister interface.
type operatorConfigurationLister struct {
listers.ResourceIndexer[*acidzalandov1.OperatorConfiguration]
}
// NewOperatorConfigurationLister returns a new OperatorConfigurationLister.
func NewOperatorConfigurationLister(indexer cache.Indexer) OperatorConfigurationLister {
return &operatorConfigurationLister{listers.New[*acidzalandov1.OperatorConfiguration](indexer, acidzalandov1.Resource("operatorconfiguration"))}
}
// OperatorConfigurations returns an object that can list and get OperatorConfigurations.
func (s *operatorConfigurationLister) OperatorConfigurations(namespace string) OperatorConfigurationNamespaceLister {
return operatorConfigurationNamespaceLister{listers.NewNamespaced[*acidzalandov1.OperatorConfiguration](s.ResourceIndexer, namespace)}
}
// OperatorConfigurationNamespaceLister helps list and get OperatorConfigurations.
// All objects returned here must be treated as read-only.
type OperatorConfigurationNamespaceLister interface {
// List lists all OperatorConfigurations in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*acidzalandov1.OperatorConfiguration, err error)
// Get retrieves the OperatorConfiguration from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*acidzalandov1.OperatorConfiguration, error)
OperatorConfigurationNamespaceListerExpansion
}
// operatorConfigurationNamespaceLister implements the OperatorConfigurationNamespaceLister
// interface.
type operatorConfigurationNamespaceLister struct {
listers.ResourceIndexer[*acidzalandov1.OperatorConfiguration]
}