mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
Refactor helper script to create a Capsule user (#454)
* 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 <massimiliano.giovagnoli.1992@gmail.com> * refactor(hack/create-user.sh): add helper function to apply dry add helper function to check commands existence. Signed-off-by: maxgio92 <massimiliano.giovagnoli.1992@gmail.com>
This commit is contained in:
@@ -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.
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user