Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM registry.access.redhat.com/ubi9/nodejs-20:latest
USER root
RUN npm i -g yarn
WORKDIR /workspace
127 changes: 127 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
.PHONY: help build-dev-image build lint type-check i18n clean update-lockfile \
build-image push-image helm-lint deploy undeploy

# Configuration
REGISTRY ?= quay.io/edge-infrastructure
IMAGE_NAME ?= console-plugin-nvidia-gpu
IMAGE_TAG ?= $(shell git rev-parse --short HEAD)
NAMESPACE ?= nvidia-gpu-operator
RELEASE_NAME ?= console-plugin-nvidia-gpu

# Container runtime (podman preferred, falls back to docker)
CONTAINER_TOOL ?= $(shell command -v podman 2>/dev/null || echo docker)
DEV_IMAGE ?= $(IMAGE_NAME)-dev

# Colors for output
BLUE := \033[36m
GREEN := \033[32m
YELLOW := \033[33m
RESET := \033[0m

# All JS/TS targets run inside a container (no Node.js required on host).
# Run 'make build-dev-image' once before using other targets.
# For hot-reload development, use: yarn start (requires Node.js on host)

help: ## Show this help
@echo "$(BLUE)Available targets:$(RESET)"
@echo ""
@echo "$(YELLOW)Development (containerized - no Node.js required):$(RESET)"
@grep -E '^(build-dev-image|build|lint|type-check|i18n|clean|update-lockfile):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(BLUE)%-18s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$(YELLOW)Container Image:$(RESET)"
@grep -E '^(build-image|push-image):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(BLUE)%-18s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$(YELLOW)Helm:$(RESET)"
@grep -E '^(helm-lint|deploy|undeploy):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(BLUE)%-18s$(RESET) %s\n", $$1, $$2}'
@echo ""
@echo "$(YELLOW)Variables:$(RESET)"
@echo " IMAGE_TAG=$(IMAGE_TAG) (default: git commit hash)"
@echo " NAMESPACE=$(NAMESPACE)"
@echo ""
@echo "$(YELLOW)Examples:$(RESET)"
@echo " make build-dev-image # Run once to create dev container"
@echo " make build-image IMAGE_TAG=0.3.0"
@echo " make deploy NAMESPACE=my-namespace"

##@ Development (containerized)

build-dev-image: ## Build the dev container image (run once)
@echo "$(GREEN)Building dev image: $(DEV_IMAGE)...$(RESET)"
$(CONTAINER_TOOL) build -t $(DEV_IMAGE) -f Dockerfile.dev .
@echo "$(GREEN)✓ Dev image ready. Run 'make build', 'make lint', etc.$(RESET)"

build: ## Build plugin for production
@echo "$(GREEN)Building plugin (containerized)...$(RESET)"
@$(CONTAINER_TOOL) run --rm \
-v "$(CURDIR):/workspace:z" \
-w /workspace \
$(DEV_IMAGE) \
sh -c "yarn install --frozen-lockfile && yarn build"

lint: ## Lint the code
@echo "$(GREEN)Linting code (containerized)...$(RESET)"
@$(CONTAINER_TOOL) run --rm \
-v "$(CURDIR):/workspace:z" \
-w /workspace \
$(DEV_IMAGE) \
sh -c "yarn install --frozen-lockfile && yarn lint"

type-check: ## Check TypeScript types
@echo "$(GREEN)Type checking (containerized)...$(RESET)"
@$(CONTAINER_TOOL) run --rm \
-v "$(CURDIR):/workspace:z" \
-w /workspace \
$(DEV_IMAGE) \
sh -c "yarn install --frozen-lockfile && yarn type-check"

i18n: ## Generate i18n translations
@echo "$(GREEN)Generating i18n (containerized)...$(RESET)"
@$(CONTAINER_TOOL) run --rm \
-v "$(CURDIR):/workspace:z" \
-w /workspace \
$(DEV_IMAGE) \
sh -c "yarn install --frozen-lockfile && yarn i18n"

clean: ## Clean build artifacts
@echo "$(GREEN)Cleaning build artifacts...$(RESET)"
rm -rf dist/ *.tgz

update-lockfile: ## Regenerate yarn.lock
@echo "$(GREEN)Regenerating yarn.lock (containerized)...$(RESET)"
@$(CONTAINER_TOOL) run --rm \
-v "$(CURDIR):/workspace:z" \
-w /workspace \
--user root \
$(DEV_IMAGE) \
sh -c "rm -f yarn.lock && yarn install --ignore-engines && chown $(shell id -u):$(shell id -g) yarn.lock"
@echo "$(GREEN)✓ yarn.lock regenerated$(RESET)"

##@ Container Image

build-image: ## Build container image
@echo "$(GREEN)Building image: $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)$(RESET)"
$(CONTAINER_TOOL) build -t $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) .

push-image: build-image ## Build and push container image
@echo "$(GREEN)Pushing image: $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)$(RESET)"
$(CONTAINER_TOOL) push $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
@echo "$(GREEN)✓ Pushed: $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)$(RESET)"

##@ Helm

helm-lint: ## Lint the Helm chart
@echo "$(GREEN)Linting Helm chart...$(RESET)"
helm lint deployment/$(RELEASE_NAME)

deploy: ## Deploy plugin to cluster (install or upgrade)
@echo "$(GREEN)Deploying plugin...$(RESET)"
helm upgrade --install -n $(NAMESPACE) $(RELEASE_NAME) \
--set image.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.tag=$(IMAGE_TAG) \
./deployment/$(RELEASE_NAME)
Comment on lines +116 to +121
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n Makefile | sed -n '110,130p'

Repository: rh-ecosystem-edge/console-plugin-nvidia-gpu

Length of output: 864


🏁 Script executed:

# Search for any other namespace-related configurations in the project
rg -i "namespace\|--create-namespace" --type makefile --type yaml --type sh

Repository: rh-ecosystem-edge/console-plugin-nvidia-gpu

Length of output: 119


🌐 Web query:

helm upgrade --install --create-namespace flag documentation

💡 Result:

The --create-namespace flag (helm upgrade) tells Helm to create the target release namespace if it does not exist — but it only takes effect when used together with --install (i.e., when upgrade will install if release is missing). Example: helm upgrade --install my-release ./chart --namespace my-ns --create-namespace. Source: Helm docs (upgrade command) and Helm FAQ. [1][2]

Sources

  • Helm upgrade reference (description of --create-namespace). [1]
  • Helm FAQ / Changes since Helm 2 (notes on automatic namespace creation and --create-namespace). [2]

Add --create-namespace to support fresh cluster deployments.

helm upgrade --install fails if the target namespace doesn't exist. Add --create-namespace to automatically create the namespace on first deploy.

✅ Suggested change
-	helm upgrade --install -n $(NAMESPACE) $(RELEASE_NAME) \
+	helm upgrade --install -n $(NAMESPACE) --create-namespace $(RELEASE_NAME) \
 		--set image.repository=$(REGISTRY)/$(IMAGE_NAME) \
 		--set image.tag=$(IMAGE_TAG) \
 		./deployment/$(RELEASE_NAME)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
deploy: ## Deploy plugin to cluster (install or upgrade)
@echo "$(GREEN)Deploying plugin...$(RESET)"
helm upgrade --install -n $(NAMESPACE) $(RELEASE_NAME) \
--set image.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.tag=$(IMAGE_TAG) \
./deployment/$(RELEASE_NAME)
deploy: ## Deploy plugin to cluster (install or upgrade)
`@echo` "$(GREEN)Deploying plugin...$(RESET)"
helm upgrade --install -n $(NAMESPACE) --create-namespace $(RELEASE_NAME) \
--set image.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.tag=$(IMAGE_TAG) \
./deployment/$(RELEASE_NAME)
🧰 Tools
🪛 checkmake (0.2.2)

[warning] 116-116: Target body for "deploy" exceeds allowed length of 5 (6).

(maxbodylength)

🤖 Prompt for AI Agents
In `@Makefile` around lines 116 - 121, The deploy target's helm command (in the
Makefile target named "deploy") should include the --create-namespace flag so
fresh clusters succeed when the namespace (NAMESPACE) does not exist; update the
helm upgrade --install invocation that uses $(RELEASE_NAME), $(NAMESPACE),
$(REGISTRY)/$(IMAGE_NAME) and $(IMAGE_TAG) to add --create-namespace so the
namespace is created automatically on first deploy.

@echo "$(GREEN)✓ Deployed $(RELEASE_NAME)$(RESET)"

undeploy: ## Remove plugin from cluster
@echo "$(GREEN)Removing $(RELEASE_NAME)...$(RESET)"
helm uninstall -n $(NAMESPACE) $(RELEASE_NAME)
@echo "$(GREEN)✓ Removed $(RELEASE_NAME)$(RESET)"