Files
kubevela/makefiles/develop.mk
Ayush Kumar 36f217e258 Feat: webhook reject unknown cr outputs (#6932)
* feat: implement output resource existence validation in component, trait, and policy definitions

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add validation tests for ComponentDefinition and TraitDefinition outputs

- Implement tests for ComponentDefinition with non-existent CRDs in outputs, ensuring they are rejected.
- Add tests for valid outputs in ComponentDefinition, confirming acceptance.
- Include tests for mixed valid and non-K8s outputs in ComponentDefinition, verifying they pass validation.
- Test handling of empty outputs in ComponentDefinition, ensuring they are accepted.
- Introduce tests for invalid apiVersion formats in ComponentDefinition, confirming rejection.
- Add tests for TraitDefinition with mixed valid and invalid outputs, ensuring proper rejection.
- Create YAML manifests for valid and invalid ComponentDefinitions and TraitDefinitions to support e2e tests.
- Ensure comprehensive coverage of edge cases in output validation logic.

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

fix: handle errors in resource validation for component, trait, and policy definitions

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

fix: improve error handling in Go module tidy and resource validation

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add webhook debugging setup and validation tests for ComponentDefinition and TraitDefinition

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add VS Code launch configuration for debugging webhook validation

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

refactor: streamline error handling in Go module tidy and remove obsolete test manifests

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add mock context support for CUE template compilation

Signed-off-by: Reetika Malhotra <malhotra.reetika25@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: enhance validation for WorkflowStepDefinition resources and improve output resource checks

Signed-off-by: viskumar <viskumar@guidewire.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: implement resource validation for CUE templates and add unit tests

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: enhance logging and validation for component, policy, and trait definitions

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: improve error handling and logging in validation handlers for component, policy, trait, and workflow step definitions

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

Remove testUnknownResource folder from repository

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: implement structured logging for validation handlers and remove deprecated request_logger

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: enhance structured logging and error handling in admission validation handlers

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: improve logging messages in validating handlers for better clarity

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: refactor logging field definitions for consistency and improve error handling in resource validation

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

chore: add license header to invalid_resource_check.go and invalid_resource_check_test.go

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: enhance validation tests for WorkflowStepDefinition and improve error messages

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add e2e-test-local target for k3d cluster setup and webhook validation

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add webhook configuration for workflow step definitions with validation rules

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: update e2e-test-local configuration and improve Ingress API version compatibility

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add installation of FluxCD CRDs in pre-hook to prevent webhook validation errors

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add ValidateResourcesExist feature gate and enhance resource validation in webhook handlers

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: enhance resource validation in e2e tests and improve addon definition checks

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: enhance addon definition detection by using owner references for validation

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: add ValidateResourcesExist feature gate and implement webhook validation for resource existence

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: update Ingress API version to v1 and adjust service references in tests

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

chore: remove webhook test commands and related YAML files from makefiles and tests

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

chore: remove architecture section from webhook debugging guide

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

feat: update webhook setup script with k3d host gateway IP note and improve cluster creation logic

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

* Fix: Correct path in Ingress resource definition in template tests

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>

* Chore: add empty line to re-trigger failing workflow

Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com>

* Chore: remove space to re-trigger workflow

Signed-off-by: Chaitanya Reddy Onteddu <co@guidewire.com>

---------

Signed-off-by: Ayush Kumar <ayushshyamkumar888@gmail.com>
Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com>
Signed-off-by: Chaitanya Reddy Onteddu <co@guidewire.com>
Co-authored-by: Chaitanya Reddy Onteddu <chaitanyareddy0702@gmail.com>
Co-authored-by: Amit Singh <amisingh@guidewire.com>
2025-09-30 09:30:53 -07:00

105 lines
3.6 KiB
Makefile

# Install CRDs and Definitions of Vela Core into a cluster, this is for develop convenient.
.PHONY: core-install
core-install: manifests
kubectl apply -f hack/namespace.yaml
kubectl apply -f charts/vela-core/crds/
@$(OK) install succeed
# Uninstall CRDs and Definitions of Vela Core from a cluster, this is for develop convenient.
.PHONY: core-uninstall
core-uninstall: manifests
kubectl delete -f charts/vela-core/crds/
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run
run:
go run ./cmd/core/main.go --application-revision-limit 5
# Run against the configured Kubernetes cluster in ~/.kube/config with debug logs
.PHONY: core-debug-run
core-debug-run: fmt vet manifests
go run ./cmd/core/main.go --log-debug=true
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: core-run
core-run: fmt vet manifests
go run ./cmd/core/main.go
## gen-cue: Generate CUE files from Go files. Variable DIR is the directory of the Go files, FLAGS is the flags for vela def gen-cue command.
.PHONY: gen-cue
gen-cue:
./hack/cuegen/cuegen.sh $(DIR) $(FLAGS)
# ==============================================================================
# Webhook Debug and Development Targets
K3D_CLUSTER_NAME ?= kubevela-debug
K3D_VERSION ?= v1.31.5
## webhook-help: Show webhook debugging help
.PHONY: webhook-help
webhook-help:
@echo "=== KubeVela Webhook Debugging Guide ==="
@echo ""
@echo "Quick Start (recommended):"
@echo " 1. make webhook-debug-setup # Complete setup"
@echo " 2. Start VS Code debugger (F5) with 'Debug Webhook Validation'"
@echo ""
@echo "Individual Commands:"
@echo " make k3d-create # Create k3d cluster"
@echo " make k3d-delete # Delete k3d cluster"
@echo " make webhook-setup # Setup webhook (certs + config)"
@echo " make webhook-clean # Clean up webhook setup"
## k3d-create: Create a k3d cluster for debugging
.PHONY: k3d-create
k3d-create:
@echo "Creating k3d cluster: $(K3D_CLUSTER_NAME)"
@if k3d cluster list | grep -q "^$(K3D_CLUSTER_NAME)"; then \
echo "k3d cluster $(K3D_CLUSTER_NAME) already exists"; \
else \
k3d cluster create "$(K3D_CLUSTER_NAME)" \
--servers 1 \
--agents 1 \
--wait || (echo "Failed to create k3d cluster" && exit 1); \
fi
@kubectl config use-context "k3d-$(K3D_CLUSTER_NAME)"
@echo "k3d cluster $(K3D_CLUSTER_NAME) ready"
## k3d-delete: Delete the k3d cluster
.PHONY: k3d-delete
k3d-delete:
@echo "Deleting k3d cluster: $(K3D_CLUSTER_NAME)"
@k3d cluster delete "$(K3D_CLUSTER_NAME)" || true
## webhook-setup: Setup webhook certificates and configuration
.PHONY: webhook-setup
webhook-setup:
@echo "Setting up webhook certificates and configuration..."
@chmod +x hack/debug-webhook-setup.sh
@./hack/debug-webhook-setup.sh
## webhook-debug-setup: Complete webhook debug environment setup
.PHONY: webhook-debug-setup
webhook-debug-setup:
@echo "Setting up complete webhook debug environment..."
@$(MAKE) k3d-create
@echo "Waiting for cluster to be ready..."
@sleep 5
@kubectl wait --for=condition=Ready nodes --all --timeout=60s || true
@echo "Installing KubeVela CRDs..."
@$(MAKE) manifests
@kubectl apply -f charts/vela-core/crds/ --validate=false
@echo "Setting up webhook..."
@$(MAKE) webhook-setup
## webhook-clean: Clean up webhook debug environment
.PHONY: webhook-clean
webhook-clean:
@echo "Cleaning up webhook debug environment..."
@rm -rf k8s-webhook-server/
@kubectl delete secret webhook-server-cert -n vela-system --ignore-not-found
@kubectl delete validatingwebhookconfiguration kubevela-vela-core-admission --ignore-not-found
@echo "Webhook debug environment cleaned"