Skip to content

Commit

Permalink
annotate projectid instead of calling API (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreat authored Nov 9, 2023
1 parent 00ab90d commit 8a6e75b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ then
echo "-- Query Rancher for cluster info"
cluster=$(curl --retry 5 -sSLf -H "${auth_header}" "${INPUT_RANCHER_URL}/v3/clusters/?name=${INPUT_RANCHER_CLUSTER}")

namespaces_url=$(echo "${cluster}" | jq -r .data[0].links.namespaces)
projects_url=$(echo "${cluster}" | jq -r .data[0].links.projects)

# Get Default project id
Expand All @@ -420,12 +419,9 @@ then
default_project_id=$(echo "${default_project}" | jq -r .data[0].id)

# Add namespace to Default project
echo "-- Add ${INPUT_NAMESPACE} to Default project ${default_project_id}"
curl --retry 5 -sSLf -H "${auth_header}" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-X POST "${namespaces_url}/${INPUT_NAMESPACE}?action=move" \
-d "{\"projectId\":\"${default_project_id}\"}"
echo "-- Annotate ${INPUT_NAMESPACE} to Default project ${default_project_id}"

k annotate ns ${INPUT_NAMESPACE} field.cattle.io/projectId="${default_project_id}"
;;

pod-restart)
Expand Down

0 comments on commit 8a6e75b

Please sign in to comment.