Skip to content

Commit

Permalink
feat(api): add generated clientset & fake clients (openebs-archive#164)
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubham14bajpai authored Oct 21, 2021
1 parent 021531a commit 3bb1ca7
Show file tree
Hide file tree
Showing 20 changed files with 1,255 additions and 6 deletions.
25 changes: 23 additions & 2 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set -o pipefail
# so we can install the tools.
#cd $(dirname "${0}")
cd vendor/k8s.io/code-generator/
go install ./cmd/{defaulter-gen,deepcopy-gen}
go install ./cmd/{defaulter-gen,client-gen,deepcopy-gen}
)

function codegen::join() { local IFS="$1"; shift; echo "$*"; }
Expand All @@ -55,6 +55,13 @@ deepcopy_inputs=(
pkg/apis/openebs/v1alpha1 \
)

client_subpackage="pkg/client"
client_package="${module_name}/${client_subpackage}"
# Generate clientsets, listers and informers for user-facing API types
client_inputs=(
pkg/apis/openebs/v1alpha1 \
)

gen-deepcopy() {
# clean pkg/apis 'zz_generated.deepcopy.go'
echo "Generating deepcopy methods..." >&2
Expand All @@ -70,5 +77,19 @@ gen-deepcopy() {
# done
}

gen-deepcopy
gen-clientsets() {
# clean "${client_subpackage}"/clientset '*.go'
echo "Generating clientset..." >&2
prefixed_inputs=( "${client_inputs[@]/#/$module_name/}" )
joined=$( IFS=$','; echo "${prefixed_inputs[*]}" )
"${GOPATH}/bin/client-gen" \
--go-header-file hack/custom-boilerplate.go.txt \
--clientset-name versioned \
--input-base "" \
--input "$joined" \
--output-package "${client_package}"/clientset
# copyfiles "${client_subpackage}/clientset" "*.go"
}

gen-deepcopy
gen-clientsets
3 changes: 1 addition & 2 deletions pkg/apis/openebs/v1alpha1/jivavolume_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ type JivaVolumeStatus struct {
Phase JivaVolumePhase `json:"phase,omitempty"`
}

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

// +genclient
// JivaVolume is the Schema for the jivavolumes API
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/openebs/v1alpha1/jivavolumepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ type JivaVolumePolicyStatus struct {
Phase string `json:"phase"`
}

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

// +genclient
// JivaVolumePolicy is the Schema for the jivavolumes API
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/openebs/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

// SchemeGroupVersion is group version used to register these objects,
// needed for client-go generation
SchemeGroupVersion = GroupVersion
)
97 changes: 97 additions & 0 deletions pkg/client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/client/clientset/versioned/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions pkg/client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/client/clientset/versioned/fake/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/client/clientset/versioned/scheme/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3bb1ca7

Please sign in to comment.