Skip to content

Commit e77aa6f

Browse files
authored
feat: adding operator gen check to CI (#4139)
1 parent 0c66b2d commit e77aa6f

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

.github/workflows/container-validation-backends.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ jobs:
7575
run: |
7676
cd deploy/cloud/operator
7777
docker build --target tester --progress=plain --build-arg DOCKER_PROXY=${ECR_HOSTNAME}/dockerhub/ .
78+
79+
- name: Set up Go
80+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
81+
with:
82+
go-version: '1.24'
83+
- name: Check for uncommitted changes
84+
shell: bash
85+
env:
86+
ECR_HOSTNAME: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com
87+
run: |
88+
sudo apt-get update && sudo apt-get install -y make
89+
cd deploy/cloud/operator
90+
make check
7891
- name: Build Container
7992
id: build-image
8093
shell: bash

deploy/cloud/operator/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ help: ## Display this help.
4444

4545
##@ Development
4646

47+
.PHONY: check
48+
check: generate manifests generate-api-docs
49+
@echo "> Checking for uncommitted changes"
50+
@if [ -n "$$(git status --porcelain)" ]; then \
51+
echo "ERROR: Git tree is dirty after running validation steps."; \
52+
echo "Please check the diff to identify the step that dirtied the tree."; \
53+
git --no-pager status; \
54+
git --no-pager diff; \
55+
exit 1; \
56+
fi
57+
@echo "> Check complete"
58+
59+
4760
.PHONY: ensure-yq
4861
ensure-yq:
4962
@if ! command -v yq &> /dev/null; then \
@@ -100,6 +113,29 @@ manifests: controller-gen ensure-yq ## Generate WebhookConfiguration, ClusterRol
100113
if [ -d "../helm/crds/templates/" ]; then \
101114
cp config/crd/bases/*.yaml ../helm/crds/templates/; \
102115
fi
116+
echo "Adding NVIDIA header to RBAC files"
117+
for file in config/rbac/*.yaml; do \
118+
if [ -f "$$file" ] && ! head -20 "$$file" | grep -q "NVIDIA CORPORATION"; then \
119+
{ printf '%s\n' \
120+
'# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.' \
121+
'# SPDX-License-Identifier: Apache-2.0' \
122+
'#' \
123+
'# Licensed under the Apache License, Version 2.0 (the "License");' \
124+
'# you may not use this file except in compliance with the License.' \
125+
'# You may obtain a copy of the License at' \
126+
'#' \
127+
'# http://www.apache.org/licenses/LICENSE-2.0' \
128+
'#' \
129+
'# Unless required by applicable law or agreed to in writing, software' \
130+
'# distributed under the License is distributed on an "AS IS" BASIS,' \
131+
'# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' \
132+
'# See the License for the specific language governing permissions and' \
133+
'# limitations under the License.' \
134+
''; \
135+
cat "$$file"; \
136+
} > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
137+
fi; \
138+
done
103139

104140
.PHONY: generate
105141
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

deploy/cloud/operator/config/rbac/role.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
315

416
---
517
apiVersion: rbac.authorization.k8s.io/v1

0 commit comments

Comments
 (0)