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

feat(spec): adding v1 CRD for ZFS-LocalPV #140

Merged
merged 2 commits into from
Jun 4, 2020
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ SRC_PKG := github.com/openebs/zfs-localpv/pkg
# code generation for custom resources
.PHONY: kubegen
kubegen: kubegendelete deepcopy-install clientset-install lister-install informer-install
@GEN_SRC=openebs.io/zfs/v1alpha1 make deepcopy clientset lister informer
@GEN_SRC=openebs.io/zfs/v1 make deepcopy clientset lister informer

# deletes generated code by codegen
.PHONY: kubegendelete
Expand Down
18 changes: 13 additions & 5 deletions buildscripts/generate-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#set -o errexit
set -o errexit
set -o nounset
set -o pipefail

Expand All @@ -28,9 +28,7 @@ then
exit 1;
fi

SCRIPT_ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)

$CONTROLLER_GEN crd:trivialVersions=true,preserveUnknownFields=false paths=${SCRIPT_ROOT}/pkg/apis/openebs.io/zfs/v1alpha1 output:crd:artifacts:config=deploy/yamls
$CONTROLLER_GEN crd:trivialVersions=false,preserveUnknownFields=false paths=./pkg/apis/... output:crd:artifacts:config=deploy/yamls

## create the the crd yamls

Expand Down Expand Up @@ -74,7 +72,17 @@ echo '# This manifest is autogenerated via `make manifests` command
# with associated CRs & RBAC rules.
' > deploy/zfs-operator.yaml

cat deploy/yamls/namespace.yaml deploy/yamls/zfsvolume-crd.yaml deploy/yamls/zfssnapshot-crd.yaml deploy/yamls/zfs-driver.yaml >> deploy/zfs-operator.yaml
# Add namespace creation to the Operator yaml
cat deploy/yamls/namespace.yaml >> deploy/zfs-operator.yaml

# Add ZFSVolume v1alpha1 and v1 CRDs to the Operator yaml
cat deploy/yamls/zfsvolume-crd.yaml >> deploy/zfs-operator.yaml

# Add ZFSSnapshot v1alpha1 and v1 CRDs to the Operator yaml
cat deploy/yamls/zfssnapshot-crd.yaml >> deploy/zfs-operator.yaml

# Add the driver deployment to the Operator
cat deploy/yamls/zfs-driver.yaml >> deploy/zfs-operator.yaml

# To use your own boilerplate text use:
# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt
1 change: 1 addition & 0 deletions changelogs/unreleased/140-pawanpraka1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
adding v1 CRD for ZFS-LocalPV
7 changes: 5 additions & 2 deletions deploy/yamls/zfssnapshot-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,14 @@ spec:
- spec
- status
type: object
version: v1alpha1
version: v1
versions:
- name: v1alpha1
- name: v1
served: true
storage: true
- name: v1alpha1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
7 changes: 5 additions & 2 deletions deploy/yamls/zfsvolume-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,14 @@ spec:
required:
- spec
type: object
version: v1alpha1
version: v1
versions:
- name: v1alpha1
- name: v1
served: true
storage: true
- name: v1alpha1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
14 changes: 10 additions & 4 deletions deploy/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,14 @@ spec:
required:
- spec
type: object
version: v1alpha1
version: v1
versions:
- name: v1alpha1
- name: v1
served: true
storage: true
- name: v1alpha1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down Expand Up @@ -449,11 +452,14 @@ spec:
- spec
- status
type: object
version: v1alpha1
version: v1
versions:
- name: v1alpha1
- name: v1
served: true
storage: true
- name: v1alpha1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/openebs.io/zfs/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2020 The OpenEBS Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package,register

// Package v1 is the API version
// +groupName=zfs.openebs.io
package v1
79 changes: 79 additions & 0 deletions pkg/apis/openebs.io/zfs/v1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2020 The OpenEBS Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// SchemeGroupVersion is group version used
// to register custom resources
//
// NOTE:
// This variable name should not be changed
var SchemeGroupVersion = schema.GroupVersion{
Group: "zfs.openebs.io",
Version: "v1",
}

// Resource takes an unqualified resource and
// returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.
WithResource(resource).
GroupResource()
}

var (
// SchemeBuilder is the scheme builder
// with scheme init functions to run
// for this API package
SchemeBuilder runtime.SchemeBuilder

localSchemeBuilder = &SchemeBuilder

// AddToScheme is a global function that
// registers this API group & version to
// a scheme
AddToScheme = localSchemeBuilder.AddToScheme
)

func init() {
// We only register manually written functions
// here. This registration of generated functions
// takes place in the generated files.
//
// NOTE:
// This separation makes the code compile even
// when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(
SchemeGroupVersion,
&ZFSVolume{},
&ZFSVolumeList{},
&ZFSSnapshot{},
&ZFSSnapshotList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
52 changes: 52 additions & 0 deletions pkg/apis/openebs.io/zfs/v1/zfssnapshot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2020 The OpenEBS Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=zfssnapshot

// ZFSSnapshot represents a ZFS Snapshot of the zfsvolume
// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,shortName=zfssnap
type ZFSSnapshot struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec VolumeInfo `json:"spec"`
Status SnapStatus `json:"status"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=zfssnapshots

// ZFSSnapshotList is a list of ZFSSnapshot resources
type ZFSSnapshotList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []ZFSSnapshot `json:"items"`
}

type SnapStatus struct {
State string `json:"state,omitempty"`
}
Loading