Skip to content

Commit e2f1595

Browse files
committed
Add clientsets for NIM Operator custom CRDs
Signed-off-by: Shiva Krishna, Merla <[email protected]>
1 parent 4379241 commit e2f1595

27 files changed

+1888
-45
lines changed

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ IMG ?= nvcr.io/nvidia/cloud-native/nim-operator:v0.1.0
1717
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1818
ENVTEST_K8S_VERSION = 1.30.0
1919

20+
MODULE := github.com/NVIDIA/k8s-nim-operator
21+
GO_CMD ?= go
22+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
23+
2024
# Import versions
2125
include $(CURDIR)/versions.mk
2226

@@ -33,6 +37,8 @@ endif
3337
# tools. (i.e. podman)
3438
CONTAINER_TOOL ?= docker
3539

40+
CLIENT_GEN = $(shell pwd)/bin/client-gen
41+
3642
# DEFAULT_CHANNEL defines the default channel used in the bundle.
3743
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
3844
# To re-generate a bundle for any other default channel without changing the default setup, you can:
@@ -82,6 +88,19 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
8288
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
8389
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
8490

91+
.PHONY: generate-clientset
92+
generate-clientset: install-tools
93+
$(CLIENT_GEN) --go-header-file=$(CURDIR)/hack/boilerplate.go.txt \
94+
--clientset-name "versioned" \
95+
--output-dir $(CURDIR)/api \
96+
--output-pkg $(MODULE)/api \
97+
--input-base $(CURDIR)/api \
98+
--input v1alpha1
99+
100+
validate-generated-assets: manifests generate generate-clientset
101+
@echo "- Verifying that the generated code and manifests are in-sync..."
102+
@git diff --exit-code -- api config
103+
85104
.PHONY: fmt
86105
fmt: ## Run go fmt against code.
87106
go fmt ./...
@@ -191,6 +210,11 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
191210
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
192211
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
193212

213+
install-tools:
214+
@echo Installing tools from tools.go
215+
export GOBIN=$(PROJECT_DIR)/bin && \
216+
grep '^\s*_' tools/tools.go | awk '{print $$2}' | xargs -tI % $(GO_CMD) install -mod=readonly -modfile=tools/go.mod %
217+
194218
##@ Dependencies
195219

196220
## Location to install dependencies to

api/v1alpha1/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
)
2626

2727
var (
28-
// GroupVersion is group version used to register these objects
29-
GroupVersion = schema.GroupVersion{Group: "apps.nvidia.com", Version: "v1alpha1"}
28+
// SchemeGroupVersion is group version used to register these objects
29+
SchemeGroupVersion = schema.GroupVersion{Group: "apps.nvidia.com", Version: "v1alpha1"}
3030

3131
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32-
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
32+
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
3333

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

api/v1alpha1/nimcache_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ func (s *NIMSource) EnvFromSecrets() []v1.EnvFromSource {
211211
return []corev1.EnvFromSource{}
212212
}
213213

214+
// +genclient
214215
// +kubebuilder:object:root=true
215216
// +kubebuilder:subresource:status
216217
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0

api/v1alpha1/nimpipeline_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type NIMPipelineStatus struct {
4747
State string `json:"state,omitempty"`
4848
}
4949

50+
// +genclient
5051
// +kubebuilder:object:root=true
5152
// +kubebuilder:subresource:status
5253

api/v1alpha1/nimservice_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type NIMServiceStatus struct {
8989
State string `json:"state,omitempty"`
9090
}
9191

92+
// +genclient
9293
// +kubebuilder:object:root=true
9394
// +kubebuilder:subresource:status
9495
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0

api/versioned/clientset.go

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/versioned/fake/clientset_generated.go

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/versioned/fake/doc.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/versioned/fake/register.go

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/versioned/scheme/doc.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)