Skip to content

Commit

Permalink
Add clientsets for NIM Operator custom CRDs
Browse files Browse the repository at this point in the history
Signed-off-by: Shiva Krishna, Merla <[email protected]>
  • Loading branch information
shivamerla committed Aug 2, 2024
1 parent 44cfee6 commit ccc42d2
Show file tree
Hide file tree
Showing 25 changed files with 1,884 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ IMG ?= nvcr.io/nvidia/cloud-native/nim-operator:v0.1.0
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.30.0

MODULE := github.com/NVIDIA/k8s-nim-operator
GO_CMD ?= go
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

# Import versions
include $(CURDIR)/versions.mk

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

CLIENT_GEN = $(shell pwd)/bin/client-gen

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

.PHONY: generate-clientset
generate-clientset: install-tools
$(CLIENT_GEN) --go-header-file=$(CURDIR)/hack/boilerplate.go.txt \
--clientset-name "versioned" \
--output-dir $(CURDIR)/api \
--output-pkg $(MODULE)/api \
--input-base $(CURDIR)/api \
--input v1alpha1

validate-generated-assets: manifests generate generate-clientset
@echo "- Verifying that the generated code and manifests are in-sync..."
@git diff --exit-code -- api config

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
Expand Down Expand Up @@ -171,6 +190,11 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
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.
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

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

##@ Dependencies

## Location to install dependencies to
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
)

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

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

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/nimcache_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (s *NIMSource) EnvFromSecrets() []v1.EnvFromSource {
return []corev1.EnvFromSource{}
}

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/nimpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type NIMPipelineStatus struct {
State string `json:"state,omitempty"`
}

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

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/nimservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type NIMServiceStatus struct {
State string `json:"state,omitempty"`
}

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0
Expand Down
119 changes: 119 additions & 0 deletions api/versioned/clientset.go

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

84 changes: 84 additions & 0 deletions api/versioned/fake/clientset_generated.go

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

19 changes: 19 additions & 0 deletions api/versioned/fake/doc.go

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

55 changes: 55 additions & 0 deletions api/versioned/fake/register.go

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

19 changes: 19 additions & 0 deletions api/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 ccc42d2

Please sign in to comment.