@@ -38,10 +38,6 @@ set -o xtrace
38
38
# doesn't allow you to create registry service accounts.
39
39
: ${VEN_API_KEY_PULL?}
40
40
41
- # The Venafi Cloud team which will be the owner of the generated Venafi service
42
- # accounts.
43
- : ${VEN_OWNING_TEAM?}
44
-
45
41
# The Venafi Cloud zone (application/issuing_template) which will be used by the
46
42
# issuer an policy.
47
43
: ${VEN_ZONE?}
@@ -87,12 +83,16 @@ if ! gcloud container clusters get-credentials "${CLUSTER_NAME}"; then
87
83
fi
88
84
kubectl create ns venafi || true
89
85
86
+ # Let's pick the first team as the owning team as it doesn't matter for this
87
+ # test.
88
+ owningTeamID=$( curl --fail-with-body -sS https://api.venafi.cloud/v1/teams -H " tppl-api-key: $VEN_API_KEY " | jq ' .teams[0].id' -r)
89
+
90
90
# Pull secret for Venafi OCI registry
91
91
if ! kubectl get secret venafi-image-pull-secret -n venafi; then
92
92
venctl iam service-accounts registry create \
93
93
--api-key " ${VEN_API_KEY_PULL} " \
94
94
--no-prompts \
95
- --owning-team " ${VEN_OWNING_TEAM } " \
95
+ --owning-team " ${owningTeamID } " \
96
96
--name " venafi-kubernetes-agent-e2e-registry-${RANDOM} " \
97
97
--scopes enterprise-cert-manager,enterprise-venafi-issuer,enterprise-approver-policy \
98
98
| jq ' {
@@ -129,12 +129,14 @@ venctl components kubernetes apply \
129
129
130
130
kubectl apply -n venafi -f venafi-components.yaml
131
131
132
+
132
133
subject=" system:serviceaccount:venafi:venafi-components"
133
134
audience=" https://${VEN_API_HOST} "
134
135
issuerURL=" $( kubectl create token -n venafi venafi-components | step crypto jwt inspect --insecure | jq -r ' .payload.iss' ) "
135
136
openidDiscoveryURL=" ${issuerURL} /.well-known/openid-configuration"
136
137
jwksURI=$( curl --fail-with-body -sSL ${openidDiscoveryURL} | jq -r ' .jwks_uri' )
137
138
139
+
138
140
# Create the Venafi agent service account if one does not already exist
139
141
while true ; do
140
142
tenantID=$( curl --fail-with-body -sSL -H " tppl-api-key: $VEN_API_KEY " https://${VEN_API_HOST} /v1/serviceaccounts \
@@ -155,15 +157,14 @@ while true; do
155
157
"issuerURL": $issuerURL,
156
158
"jwksURI": $jwksURI,
157
159
"applications": [$applications.applications[].id],
158
- "owner": $teams.teams[] | select(.name==$teamName) | .id
160
+ "owner": $owningTeamID
159
161
}' \
160
162
--arg random " ${RANDOM} " \
161
- --arg teamName " ${VEN_OWNING_TEAM} " \
162
163
--arg subject " ${subject} " \
163
164
--arg audience " ${audience} " \
164
165
--arg issuerURL " ${issuerURL} " \
165
166
--arg jwksURI " ${jwksURI} " \
166
- --argjson teams " $( curl https:// ${VEN_API_HOST} /v1/teams --fail-with-body -sSL -H tppl-api-key: \ ${VEN_API_KEY} ) " \
167
+ --arg owningTeamID " { $owningTeamID } " \
167
168
--argjson applications " $( curl https://${VEN_API_HOST} /outagedetection/v1/applications --fail-with-body -sSL -H tppl-api-key:\ ${VEN_API_KEY} ) " \
168
169
| curl https://${VEN_API_HOST} /v1/serviceaccounts \
169
170
-H " tppl-api-key: $VEN_API_KEY " \
0 commit comments