kustomize := "bazel run //hack/tools:kustomize --" kubectl := "bazel run //hack/tools:kubectl --" just := "just --justfile=" + justfile_directory() + "/../../../justfile" # build the operator, provider and web/identity build: bazel build ... # push the containers to your local repo push registry="localhost:21700": #!/usr/bin/env bash echo "🔨 pushing images and building if necessary" bazel run //cmd/tools/pusha -- --repo={{registry}} --insecure-repository=true cmd/edge/device-registrar/... wait-for-deploy namespace="device-registrar" name="device-registrar" : #!/usr/bin/env bash echo "⏳ hang on, waiting for {{name}} deployment.." while true; do kubectl rollout status deployment/{{name}} -n {{namespace}} if [ $? -eq 0 ]; then break else echo "💪 trying again.. " sleep 5 fi done fwd: #!/usr/bin/env bash echo "🔁 forwarding device-registrar-service on 8080" kubectl port-forward service/device-registrar-svc -n device-registrar 8080:80 > /dev/null 2>&1 & stopfwd port="8080": #!/usr/bin/env bash kill $(ps aux | grep kubectl | grep port-forward | grep {{port}} | awk '{print $2}') exit 0 # apply the CRDs to a cluster crds: #!/usr/bin/env bash echo "📦 deploying all required crds" kubectl apply -k {{invocation_directory()}}/config/pallets/edge/device-registrar/base/crds kubectl apply -f {{invocation_directory()}}/config/components/edge-iam-v2/crds/iam.edge-infra.dev_clients.yaml kubectl apply -f {{invocation_directory()}}/config/pallets/sds/nodeagent/base/crds/dsds.edge.ncr.com_ienodes.yaml cert-manager: #!/usr/bin/env bash echo "🚀 deploying cert manager" kubectl apply -f {{invocation_directory()}}/third_party/k8s/certmanager/manifests.yaml deploy: #!/usr/bin/env bash echo "🚀 deploying the crds, cronjob and sample external Application" kubectl apply -k {{invocation_directory()}}/config/pallets/edge/device-registrar/kind reset: #!/usr/bin/env bash echo "🔥 deleting all resources" kubectl delete -k {{invocation_directory()}}/config/pallets/edge/device-registrar/kind || true sleep 5 label-kind-nodes: #!/usr/bin/env bash kubectl label node edge-worker node.ncr.com/role=controlplane --overwrite kind: stopfwd reset crds push label-kind-nodes deploy wait-for-deploy fwd update: gen-code update-manifests {{just}} gazelle update-manifests: gen-crds gen-rbac {{just}} fmt-manifests gen-crds: {{just}} run pkg/edge/device-registrar/api:gen_crds gen-rbac: {{just}} run pkg/edge/device-registrar/controller:gen_rbac gen-code: {{just}} run pkg/edge/device-registrar/api:gen_code docs: docker pull swaggerapi/swagger-ui echo "🚀 swagger-ui will be running on http://localhost:8082" docker run -p 8082:8080 -e SWAGGER_JSON=/docs/spec.json -v {{invocation_directory()}}/docs/edge/components/device-registrar:/docs swaggerapi/swagger-ui gen-docs: swagger-linter-fix swagger-gen swagger-linter-revert swagger-gen: #!/usr/bin/env bash RED='\033[31m' BOLD='\033[1m' NC='\033[0m' echo "📝 To change the ordering of the tags or the tag descriptions, please edit this justfile command." echo -e "\n${BOLD}${RED}NOTE:${NC} The goimports linter changes the array index symbol in the go-swagger parameters list from a ${BOLD}${RED}+${NC} to a - symbol, which will cause the ${BOLD}swagger generate ${NC}command to fail." echo -e "If your swagger updates involve adding a parameter list, please modify to the ${BOLD}swagger-linter-fix${NC} justfile command with your changes.\n" go install github.com/go-swagger/go-swagger/cmd/swagger@latest swagger generate spec -w {{invocation_directory()}}/pkg/edge/device-registrar/services -o {{invocation_directory()}}/docs/edge/components/device-registrar/spec.json -m # Define the TAGS JSON snippet TAGS='{ "tags": [ { "name": "core", "description": "Core device registration endpoints" }, { "name": "additional", "description": "Additional device registration endpoints" }, { "name": "legacy", "description": "Legacy device registration endpoints" } ] }' # Use jq to insert the TAGS after the "info" field jq --argjson tags "$TAGS" '. + $tags' {{invocation_directory()}}/docs/edge/components/device-registrar/spec.json > {{invocation_directory()}}/docs/edge/components/device-registrar/spec_with_tags.json # Replace the original spec file with the modified one mv {{invocation_directory()}}/docs/edge/components/device-registrar/spec_with_tags.json {{invocation_directory()}}/docs/edge/components/device-registrar/spec.json echo "🎉 Swagger spec generated at {{invocation_directory()}}/docs/edge/components/device-registrar/spec.json" gen-code-coverage: #!/usr/bin/env bash go test -coverprofile=coverage.out {{invocation_directory()}}/pkg/edge/device-registrar/services go tool cover -html=coverage.out -o coverage.html open coverage.html # This is a temporary fix for the linter issue where goimports changes the + symbol to a - symbol in the swagger spec. # The first command changes the - symbol to a + symbol, and the second command reverts the changes after the swagger spec is generated swagger-linter-fix: #!/usr/bin/env bash sed -i '' 's/- name: X-Client-DN/+ name: X-Client-DN/g' {{invocation_directory()}}/pkg/edge/device-registrar/services/device_discovery_service.go swagger-linter-revert: #!/usr/bin/env bash sed -i '' 's/+ name: X-Client-DN/- name: X-Client-DN/g' {{invocation_directory()}}/pkg/edge/device-registrar/services/device_discovery_service.go