mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
feat(crd-gen): automate the CRDs generation with validations for APIs (#75)
- To generate the CRD spec `make manifest` generate then under deploy/yamls directory - added a update-crd script to automate the steps to generate CRDs and its validation of each types Signed-off-by: prateekpandey14 <prateek.pandey@mayadata.io>
This commit is contained in:
parent
8a9ac43ab5
commit
6033789c17
26 changed files with 509 additions and 82 deletions
|
|
@ -19,7 +19,7 @@ limitations under the License.
|
|||
package internalclientset
|
||||
|
||||
import (
|
||||
openebsv1alpha1 "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/typed/zfs/v1alpha1"
|
||||
zfsv1alpha1 "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/typed/zfs/v1alpha1"
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
rest "k8s.io/client-go/rest"
|
||||
flowcontrol "k8s.io/client-go/util/flowcontrol"
|
||||
|
|
@ -27,19 +27,19 @@ import (
|
|||
|
||||
type Interface interface {
|
||||
Discovery() discovery.DiscoveryInterface
|
||||
OpenebsV1alpha1() openebsv1alpha1.OpenebsV1alpha1Interface
|
||||
ZfsV1alpha1() zfsv1alpha1.ZfsV1alpha1Interface
|
||||
}
|
||||
|
||||
// Clientset contains the clients for groups. Each group has exactly one
|
||||
// version included in a Clientset.
|
||||
type Clientset struct {
|
||||
*discovery.DiscoveryClient
|
||||
openebsV1alpha1 *openebsv1alpha1.OpenebsV1alpha1Client
|
||||
zfsV1alpha1 *zfsv1alpha1.ZfsV1alpha1Client
|
||||
}
|
||||
|
||||
// OpenebsV1alpha1 retrieves the OpenebsV1alpha1Client
|
||||
func (c *Clientset) OpenebsV1alpha1() openebsv1alpha1.OpenebsV1alpha1Interface {
|
||||
return c.openebsV1alpha1
|
||||
// ZfsV1alpha1 retrieves the ZfsV1alpha1Client
|
||||
func (c *Clientset) ZfsV1alpha1() zfsv1alpha1.ZfsV1alpha1Interface {
|
||||
return c.zfsV1alpha1
|
||||
}
|
||||
|
||||
// Discovery retrieves the DiscoveryClient
|
||||
|
|
@ -58,7 +58,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
|||
}
|
||||
var cs Clientset
|
||||
var err error
|
||||
cs.openebsV1alpha1, err = openebsv1alpha1.NewForConfig(&configShallowCopy)
|
||||
cs.zfsV1alpha1, err = zfsv1alpha1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
|||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
var cs Clientset
|
||||
cs.openebsV1alpha1 = openebsv1alpha1.NewForConfigOrDie(c)
|
||||
cs.zfsV1alpha1 = zfsv1alpha1.NewForConfigOrDie(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||
return &cs
|
||||
|
|
@ -83,7 +83,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
|||
// New creates a new Clientset for the given RESTClient.
|
||||
func New(c rest.Interface) *Clientset {
|
||||
var cs Clientset
|
||||
cs.openebsV1alpha1 = openebsv1alpha1.New(c)
|
||||
cs.zfsV1alpha1 = zfsv1alpha1.New(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||
return &cs
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ package fake
|
|||
|
||||
import (
|
||||
clientset "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset"
|
||||
openebsv1alpha1 "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/typed/zfs/v1alpha1"
|
||||
fakeopenebsv1alpha1 "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/typed/zfs/v1alpha1/fake"
|
||||
zfsv1alpha1 "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/typed/zfs/v1alpha1"
|
||||
fakezfsv1alpha1 "github.com/openebs/zfs-localpv/pkg/generated/clientset/internalclientset/typed/zfs/v1alpha1/fake"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/discovery"
|
||||
|
|
@ -71,7 +71,7 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
|||
|
||||
var _ clientset.Interface = &Clientset{}
|
||||
|
||||
// OpenebsV1alpha1 retrieves the OpenebsV1alpha1Client
|
||||
func (c *Clientset) OpenebsV1alpha1() openebsv1alpha1.OpenebsV1alpha1Interface {
|
||||
return &fakeopenebsv1alpha1.FakeOpenebsV1alpha1{Fake: &c.Fake}
|
||||
// ZfsV1alpha1 retrieves the ZfsV1alpha1Client
|
||||
func (c *Clientset) ZfsV1alpha1() zfsv1alpha1.ZfsV1alpha1Interface {
|
||||
return &fakezfsv1alpha1.FakeZfsV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ limitations under the License.
|
|||
package fake
|
||||
|
||||
import (
|
||||
openebsv1alpha1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1alpha1"
|
||||
zfsv1alpha1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
@ -31,7 +31,7 @@ var scheme = runtime.NewScheme()
|
|||
var codecs = serializer.NewCodecFactory(scheme)
|
||||
var parameterCodec = runtime.NewParameterCodec(scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
openebsv1alpha1.AddToScheme,
|
||||
zfsv1alpha1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ limitations under the License.
|
|||
package scheme
|
||||
|
||||
import (
|
||||
openebsv1alpha1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1alpha1"
|
||||
zfsv1alpha1 "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme()
|
|||
var Codecs = serializer.NewCodecFactory(Scheme)
|
||||
var ParameterCodec = runtime.NewParameterCodec(Scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
openebsv1alpha1.AddToScheme,
|
||||
zfsv1alpha1.AddToScheme,
|
||||
}
|
||||
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
|
|
|
|||
|
|
@ -24,21 +24,21 @@ import (
|
|||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
type FakeOpenebsV1alpha1 struct {
|
||||
type FakeZfsV1alpha1 struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
func (c *FakeOpenebsV1alpha1) ZFSSnapshots(namespace string) v1alpha1.ZFSSnapshotInterface {
|
||||
func (c *FakeZfsV1alpha1) ZFSSnapshots(namespace string) v1alpha1.ZFSSnapshotInterface {
|
||||
return &FakeZFSSnapshots{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeOpenebsV1alpha1) ZFSVolumes(namespace string) v1alpha1.ZFSVolumeInterface {
|
||||
func (c *FakeZfsV1alpha1) ZFSVolumes(namespace string) v1alpha1.ZFSVolumeInterface {
|
||||
return &FakeZFSVolumes{c, namespace}
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeOpenebsV1alpha1) RESTClient() rest.Interface {
|
||||
func (c *FakeZfsV1alpha1) RESTClient() rest.Interface {
|
||||
var ret *rest.RESTClient
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ import (
|
|||
|
||||
// FakeZFSSnapshots implements ZFSSnapshotInterface
|
||||
type FakeZFSSnapshots struct {
|
||||
Fake *FakeOpenebsV1alpha1
|
||||
Fake *FakeZfsV1alpha1
|
||||
ns string
|
||||
}
|
||||
|
||||
var zfssnapshotsResource = schema.GroupVersionResource{Group: "openebs.io", Version: "v1alpha1", Resource: "zfssnapshots"}
|
||||
var zfssnapshotsResource = schema.GroupVersionResource{Group: "zfs.openebs.io", Version: "v1alpha1", Resource: "zfssnapshots"}
|
||||
|
||||
var zfssnapshotsKind = schema.GroupVersionKind{Group: "openebs.io", Version: "v1alpha1", Kind: "ZFSSnapshot"}
|
||||
var zfssnapshotsKind = schema.GroupVersionKind{Group: "zfs.openebs.io", Version: "v1alpha1", Kind: "ZFSSnapshot"}
|
||||
|
||||
// Get takes name of the zFSSnapshot, and returns the corresponding zFSSnapshot object, and an error if there is any.
|
||||
func (c *FakeZFSSnapshots) Get(name string, options v1.GetOptions) (result *v1alpha1.ZFSSnapshot, err error) {
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ import (
|
|||
|
||||
// FakeZFSVolumes implements ZFSVolumeInterface
|
||||
type FakeZFSVolumes struct {
|
||||
Fake *FakeOpenebsV1alpha1
|
||||
Fake *FakeZfsV1alpha1
|
||||
ns string
|
||||
}
|
||||
|
||||
var zfsvolumesResource = schema.GroupVersionResource{Group: "openebs.io", Version: "v1alpha1", Resource: "zfsvolumes"}
|
||||
var zfsvolumesResource = schema.GroupVersionResource{Group: "zfs.openebs.io", Version: "v1alpha1", Resource: "zfsvolumes"}
|
||||
|
||||
var zfsvolumesKind = schema.GroupVersionKind{Group: "openebs.io", Version: "v1alpha1", Kind: "ZFSVolume"}
|
||||
var zfsvolumesKind = schema.GroupVersionKind{Group: "zfs.openebs.io", Version: "v1alpha1", Kind: "ZFSVolume"}
|
||||
|
||||
// Get takes name of the zFSVolume, and returns the corresponding zFSVolume object, and an error if there is any.
|
||||
func (c *FakeZFSVolumes) Get(name string, options v1.GetOptions) (result *v1alpha1.ZFSVolume, err error) {
|
||||
|
|
|
|||
|
|
@ -25,27 +25,27 @@ import (
|
|||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type OpenebsV1alpha1Interface interface {
|
||||
type ZfsV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
ZFSSnapshotsGetter
|
||||
ZFSVolumesGetter
|
||||
}
|
||||
|
||||
// OpenebsV1alpha1Client is used to interact with features provided by the openebs.io group.
|
||||
type OpenebsV1alpha1Client struct {
|
||||
// ZfsV1alpha1Client is used to interact with features provided by the zfs.openebs.io group.
|
||||
type ZfsV1alpha1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
func (c *OpenebsV1alpha1Client) ZFSSnapshots(namespace string) ZFSSnapshotInterface {
|
||||
func (c *ZfsV1alpha1Client) ZFSSnapshots(namespace string) ZFSSnapshotInterface {
|
||||
return newZFSSnapshots(c, namespace)
|
||||
}
|
||||
|
||||
func (c *OpenebsV1alpha1Client) ZFSVolumes(namespace string) ZFSVolumeInterface {
|
||||
func (c *ZfsV1alpha1Client) ZFSVolumes(namespace string) ZFSVolumeInterface {
|
||||
return newZFSVolumes(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new OpenebsV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*OpenebsV1alpha1Client, error) {
|
||||
// NewForConfig creates a new ZfsV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*ZfsV1alpha1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -54,12 +54,12 @@ func NewForConfig(c *rest.Config) (*OpenebsV1alpha1Client, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &OpenebsV1alpha1Client{client}, nil
|
||||
return &ZfsV1alpha1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new OpenebsV1alpha1Client for the given config and
|
||||
// NewForConfigOrDie creates a new ZfsV1alpha1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *OpenebsV1alpha1Client {
|
||||
func NewForConfigOrDie(c *rest.Config) *ZfsV1alpha1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -67,9 +67,9 @@ func NewForConfigOrDie(c *rest.Config) *OpenebsV1alpha1Client {
|
|||
return client
|
||||
}
|
||||
|
||||
// New creates a new OpenebsV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *OpenebsV1alpha1Client {
|
||||
return &OpenebsV1alpha1Client{c}
|
||||
// New creates a new ZfsV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *ZfsV1alpha1Client {
|
||||
return &ZfsV1alpha1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
|
|
@ -87,7 +87,7 @@ func setConfigDefaults(config *rest.Config) error {
|
|||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *OpenebsV1alpha1Client) RESTClient() rest.Interface {
|
||||
func (c *ZfsV1alpha1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ type zFSSnapshots struct {
|
|||
}
|
||||
|
||||
// newZFSSnapshots returns a ZFSSnapshots
|
||||
func newZFSSnapshots(c *OpenebsV1alpha1Client, namespace string) *zFSSnapshots {
|
||||
func newZFSSnapshots(c *ZfsV1alpha1Client, namespace string) *zFSSnapshots {
|
||||
return &zFSSnapshots{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ type zFSVolumes struct {
|
|||
}
|
||||
|
||||
// newZFSVolumes returns a ZFSVolumes
|
||||
func newZFSVolumes(c *OpenebsV1alpha1Client, namespace string) *zFSVolumes {
|
||||
func newZFSVolumes(c *ZfsV1alpha1Client, namespace string) *zFSVolumes {
|
||||
return &zFSVolumes{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue