Skip to content

Commit

Permalink
make prepare-supervisor-on-kind.sh work with older versions of bash
Browse files Browse the repository at this point in the history
  • Loading branch information
cfryanr committed Sep 12, 2023
1 parent 84498d5 commit c52ed93
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions hack/prepare-supervisor-on-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,23 @@ fi
kubectl create secret tls -n "$PINNIPED_TEST_SUPERVISOR_NAMESPACE" my-federation-domain-tls --cert "$tls_crt_path" --key "$tls_key_path" \
--dry-run=client --output yaml | kubectl apply -f -

# Variable that will be used to build up the "identityProviders" yaml for the FederationDomain.
fd_idps=""
# Make a FederationDomain using the TLS Secret and identity providers from above in a temp file.
fd_file="/tmp/federationdomain.yaml"
cat << EOF > $fd_file
apiVersion: config.supervisor.pinniped.dev/v1alpha1
kind: FederationDomain
metadata:
name: my-federation-domain
spec:
issuer: $issuer
tls:
secretName: my-federation-domain-tls
identityProviders:
EOF

if [[ "$use_oidc_upstream" == "yes" ]]; then
# Indenting the heredoc by 4 spaces to make it indented the correct amount in the FederationDomain below.
fd_idps="${fd_idps}$(
cat <<EOF
cat << EOF >> $fd_file
- displayName: "My OIDC IDP 🚀"
objectRef:
Expand All @@ -264,13 +274,11 @@ if [[ "$use_oidc_upstream" == "yes" ]]; then
username: oidc:[email protected]
groups: [ oidc:a, oidc:b ]
EOF
)"
fi

if [[ "$use_ldap_upstream" == "yes" ]]; then
# Indenting the heredoc by 4 spaces to make it indented the correct amount in the FederationDomain below.
fd_idps="${fd_idps}$(
cat <<EOF
cat << EOF >> $fd_file
- displayName: "My LDAP IDP 🚀"
objectRef:
Expand Down Expand Up @@ -320,35 +328,22 @@ if [[ "$use_ldap_upstream" == "yes" ]]; then
rejected: true
message: "Only users in certain kube groups are allowed to authenticate"
EOF
)"
fi

if [[ "$use_ad_upstream" == "yes" ]]; then
# Indenting the heredoc by 4 spaces to make it indented the correct amount in the FederationDomain below.
fd_idps="${fd_idps}$(
cat <<EOF
cat << EOF >> $fd_file
- displayName: "My AD IDP"
objectRef:
apiGroup: idp.supervisor.pinniped.dev
kind: ActiveDirectoryIdentityProvider
name: my-ad-provider
EOF
)"
fi

# Make a FederationDomain using the TLS Secret and identity providers from above.
cat <<EOF | kubectl apply --namespace "$PINNIPED_TEST_SUPERVISOR_NAMESPACE" -f -
apiVersion: config.supervisor.pinniped.dev/v1alpha1
kind: FederationDomain
metadata:
name: my-federation-domain
spec:
issuer: $issuer
tls:
secretName: my-federation-domain-tls
identityProviders:${fd_idps}
EOF
# Apply the FederationDomain from the file created above.
kubectl apply --namespace "$PINNIPED_TEST_SUPERVISOR_NAMESPACE" -f "$fd_file"

echo "Waiting for FederationDomain to initialize or update..."
kubectl wait --for=condition=Ready FederationDomain/my-federation-domain -n "$PINNIPED_TEST_SUPERVISOR_NAMESPACE"
Expand Down

0 comments on commit c52ed93

Please sign in to comment.