Skip to content

Commit

Permalink
fix script to generate client, listers, informets (#30)
Browse files Browse the repository at this point in the history
* fix script to generate client, listers, informets

Signed-off-by: DavidSpek <[email protected]>

* generate client when running make generate

Signed-off-by: DavidSpek <[email protected]>

* fix running command for first time

Signed-off-by: DavidSpek <[email protected]>

* don't run client generate at when running regular generate

Signed-off-by: DavidSpek <[email protected]>

* fix generate command

Signed-off-by: DavidSpek <[email protected]>

Signed-off-by: DavidSpek <[email protected]>
  • Loading branch information
davidspek authored Oct 28, 2022
1 parent 7d30097 commit 22b8b4a
Show file tree
Hide file tree
Showing 102 changed files with 6,115 additions and 219 deletions.
42 changes: 35 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ help: ## Display this help.
##@ Development

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/..." output:crd:artifacts:config=config/crd/bases

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
generate: controller-gen generate-client ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations and the clientset, informers and listers.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/..."

fmt: ## Run go fmt against code.
go fmt ./...
Expand Down Expand Up @@ -81,6 +81,19 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -

run-client-gen: client-gen
$(CLIENT_GEN) --clientset-name versioned --input-base github.com/pluralsh/plural-operator/apis --input platform/v1alpha1,vpn/v1alpha1 --output-package github.com/pluralsh/plural-operator/generated/client/clientset --go-header-file hack/boilerplate.go.txt

run-lister-gen: lister-gen
$(LISTER_GEN) --input-dirs github.com/pluralsh/plural-operator/apis/platform/v1alpha1,github.com/pluralsh/plural-operator/apis/vpn/v1alpha1 --output-package github.com/pluralsh/plural-operator/generated/client/listers --go-header-file hack/boilerplate.go.txt

run-informer-gen: informer-gen
$(INFORMER_GEN) --input-dirs github.com/pluralsh/plural-operator/apis/platform/v1alpha1,github.com/pluralsh/plural-operator/apis/vpn/v1alpha1 --versioned-clientset-package github.com/pluralsh/plural-operator/generated/client/clientset/versioned --listers-package github.com/pluralsh/plural-operator/generated/client/listers --output-package github.com/pluralsh/plural-operator/generated/client/informers --go-header-file hack/boilerplate.go.txt

generate-client: run-client-gen run-lister-gen run-informer-gen
rm -rf generated
mv github.com/pluralsh/plural-operator/generated generated
rm -rf github.com

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
Expand All @@ -90,10 +103,25 @@ KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])

client-gen:
./hack/update-codegen.sh
mv github.com/pluralsh/plural-operator/generated generated
rm -rf github.com
CLIENT_GEN = $(shell pwd)/bin/client-gen
client-gen: ## Download client-gen locally if necessary.
$(call go-get-tool,$(CLIENT_GEN),k8s.io/code-generator/cmd/[email protected])

LISTER_GEN = $(shell pwd)/bin/lister-gen
lister-gen: ## Download lister-gen locally if necessary.
$(call go-get-tool,$(LISTER_GEN),k8s.io/code-generator/cmd/[email protected])

INFORMER_GEN = $(shell pwd)/bin/informer-gen
informer-gen: ## Download informer-gen locally if necessary.
$(call go-get-tool,$(INFORMER_GEN),k8s.io/code-generator/cmd/[email protected])

DEFFAULTER_GEN = $(shell pwd)/bin/defaulter-gen
defaulter-gen: ## Download defaulter-gen locally if necessary.
$(call go-get-tool,$(DEFFAULTER_GEN),k8s.io/code-generator/cmd/[email protected])

DEEPCOPY_GEN = $(shell pwd)/bin/deepcopy-gen
deepcopy-gen: ## Download deepcopy-gen locally if necessary.
$(call go-get-tool,$(DEEPCOPY_GEN),k8s.io/code-generator/cmd/[email protected])

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/configurationoverlay_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type ConfigurationOverlayStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/defaultstorageclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type DefaultStorageClassStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/license_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type LicenseStatus struct {
Secrets map[string]string `json:"secrets"`
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
2 changes: 2 additions & 0 deletions apis/platform/v1alpha1/registrycredential_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1alpha1

import (
"fmt"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -36,6 +37,7 @@ type RegistryCredentialStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/resourcegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ResourceGroupStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/runbook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ type RunbookStatus struct {
Alerts []*RunbookAlertStatus `json:"alerts"`
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/secretsync_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SecretSyncStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
1 change: 1 addition & 0 deletions apis/platform/v1alpha1/statefulsetresize_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type StatefulSetResizeStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
3 changes: 3 additions & 0 deletions apis/vpn/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// +groupName=vpn.plural.sh

package v1alpha1
12 changes: 12 additions & 0 deletions apis/vpn/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// SchemeGroupVersion is group version used to register these objects.
var SchemeGroupVersion = GroupVersion

func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
1 change: 1 addition & 0 deletions apis/vpn/v1alpha1/wireguardpeer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type WireguardPeerStatus struct {
Conditions crhelperTypes.Conditions `json:"conditions,omitempty"`
}

//+genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Wireguard Server",type="string",JSONPath=".spec.wireguardRef",description="The Wireguard Server this peer belongs to"
Expand Down
1 change: 1 addition & 0 deletions apis/vpn/v1alpha1/wireguardserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type WireguardServerStatus struct {
Conditions crhelperTypes.Conditions `json:"conditions,omitempty"`
}

//+genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Hostname",type="string",JSONPath=".status.hostname",description="WireguardServer hostname"
Expand Down

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

File renamed without changes.

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

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

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

Loading

0 comments on commit 22b8b4a

Please sign in to comment.