Skip to content

Commit

Permalink
Refactor helper script to create a Capsule user (#454)
Browse files Browse the repository at this point in the history
* chore(hack/create-user.sh): let pick bash interpreter from path

bash interpreter binary could be put at different paths than /bin/bash.

Signed-off-by: maxgio92 <[email protected]>

* refactor(hack/create-user.sh): add helper function to apply dry

add helper function to check commands existence.

Signed-off-by: maxgio92 <[email protected]>
  • Loading branch information
maxgio92 authored Oct 22, 2021
1 parent 0784dc7 commit e0d5e6f
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions hack/create-user.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script uses Kubernetes CertificateSigningRequest (CSR) to generate a
# certificate signed by the Kubernetes CA itself.
Expand All @@ -10,23 +10,18 @@
# Exit immediately if a command exits with a non-zero status.
set -e

# Check if OpenSSL is installed
if [[ ! -x "$(command -v openssl)" ]]; then
echo "Error: openssl not found"
exit 1
fi
function check_command() {
local command=$1

# Check if kubectl is installed
if [[ ! -x "$(command -v kubectl)" ]]; then
echo "Error: kubectl not found"
exit 1
fi
if ! command -v $command &> /dev/null; then
echo "Error: ${command} not found"
exit 1
fi
}

# Check if jq is installed
if [[ ! -x "$(command -v jq)" ]]; then
echo "Error: jq not found"
exit 1
fi
check_command openssl
check_command kubectl
check_command jq

USER=$1
TENANT=$2
Expand Down

0 comments on commit e0d5e6f

Please sign in to comment.