Skip to content

Commit

Permalink
Fix clientset generation and add for informers and listers (#275)
Browse files Browse the repository at this point in the history
* fix generate-client Makefile target

* add SchemeGroupVersion var in v1alpha2 package

* add Resource function in v1alpha1 and v1alpha2 packages

* add +genclient directive in all APIs

* generate clientset, informers, and listers
  • Loading branch information
matheusfm authored Apr 22, 2024
1 parent 98e8e91 commit 2d0d0ec
Show file tree
Hide file tree
Showing 58 changed files with 3,146 additions and 16 deletions.
16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,15 @@ manifests: controller-gen addlicense ## Generate WebhookConfiguration, ClusterRo
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

PROJECT_PACKAGE ?= $(shell go list -m)
.PHONY: generate-client
generate-client: ## Generate client
@rm -r pkg/clientset || echo -n
@rm -r pkg/clientset pkg/informers pkg/listers || echo -n
$(CONTAINER_TOOL) run -i --rm \
-v $(PWD):/go/src/$(PROJECT_PACKAGE) \
-e PROJECT_PACKAGE=$(PROJECT_PACKAGE) \
-e CLIENT_GENERATOR_OUT=$(PROJECT_PACKAGE)/pkg \
-e APIS_ROOT=$(PROJECT_PACKAGE)/api \
-e GROUPS_VERSION="zora:v1alpha1" \
-e GENERATION_TARGETS="client" \
-e BOILERPLATE_PATH="hack/boilerplate.go.txt" \
ghcr.io/slok/kube-code-generator:v0.1.0
-v $(PWD):/app \
ghcr.io/slok/kube-code-generator:v0.1.0 \
--apis-in ./api \
--go-gen-out ./pkg \
--debug

.PHONY: generate-helm-docs
generate-helm-docs: helm-docs ## Generate documentation for helm chart.
Expand Down
2 changes: 0 additions & 2 deletions api/zora/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ func (in *ClusterStatus) SetResources(res discovery.ClusterResources) {

// Cluster is the Schema for the clusters API
// +genclient
// +genclient:onlyVerbs=list,get
// +genclient:noStatus
type Cluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion api/zora/v1alpha1/clusterissue_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ type ClusterIssueStatus struct {

// ClusterIssue is the Schema for the clusterissues API
// +genclient
// +genclient:noStatus
type ClusterIssue struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
2 changes: 0 additions & 2 deletions api/zora/v1alpha1/clusterscan_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ type PluginScanStatus struct {

// ClusterScan is the Schema for the clusterscans API
// +genclient
// +genclient:onlyVerbs=list,get
// +genclient:noStatus
type ClusterScan struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions api/zora/v1alpha1/customcheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type CustomCheckStatus struct {
//+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",priority=0

// CustomCheck is the Schema for the customchecks API
// +genclient
type CustomCheck struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/zora/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ var (
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
1 change: 1 addition & 0 deletions api/zora/v1alpha1/plugin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type PluginStatus struct {
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// Plugin is the Schema for the plugins API
// +genclient
type Plugin struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion api/zora/v1alpha1/vulnerabilityreport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (in *VulnerabilityReport) SaaSStatusIsTrue() bool {

// VulnerabilityReport is the Schema for the vulnerabilityreports API
// +genclient
// +genclient:noStatus
type VulnerabilityReport struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions api/zora/v1alpha2/customcheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type CustomCheckStatus struct {
//+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",priority=0

// CustomCheck is the Schema for the customchecks API
// +genclient
type CustomCheck struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions api/zora/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "zora.undistro.io", Version: "v1alpha2"}

// SchemeGroupVersion is a copy of GroupVersion, used by client-gen
SchemeGroupVersion = GroupVersion

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

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

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
13 changes: 13 additions & 0 deletions pkg/clientset/versioned/clientset.go

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

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

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

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

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

2 changes: 2 additions & 0 deletions pkg/clientset/versioned/scheme/register.go

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

109 changes: 109 additions & 0 deletions pkg/clientset/versioned/typed/zora/v1alpha1/cluster.go

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

17 changes: 17 additions & 0 deletions pkg/clientset/versioned/typed/zora/v1alpha1/clusterissue.go

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

Loading

0 comments on commit 2d0d0ec

Please sign in to comment.