Skip to content

Commit

Permalink
fix shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Jan 25, 2024
1 parent 4c70529 commit 208b606
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions test/infrastructure/vcsim/scripts/vcsim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

check_command() {
eval "$1 &> /dev/null"
if [ $? -eq 0 ]; then
return 0
else
return 1
fi
}

# Validate params
if [ -z "$1" ]
then
Expand All @@ -37,9 +28,7 @@ then
fi

# Check VCenter exists or create it

check_command "kubectl get vcenter $1"
if [ $? -eq 0 ]; then
if eval "kubectl get vcenter $1 &> /dev/null"; then
echo "using existing VCenter $1"
else
kubectl apply -f - &> /dev/null <<EOF
Expand All @@ -52,9 +41,7 @@ EOF
fi

# Check FakeAPIServerEndpoint exists or create it

check_command "kubectl get controlplaneendpoint $2"
if [ $? -eq 0 ]; then
if eval "kubectl get controlplaneendpoint $2 &> /dev/null"; then
echo "using existing ControlPlaneEndpoint $2"
else
kubectl apply -f - &> /dev/null <<EOF
Expand All @@ -68,9 +55,7 @@ EOF
fi

# Check EnvSubst exists or create it

check_command "kubectl get envsubst $2"
if [ $? -eq 0 ]; then
if eval "kubectl get envsubst $2 &> /dev/null"; then
echo "using existing EnvSubst $2"
else
kubectl apply -f - &> /dev/null <<EOF
Expand All @@ -89,8 +74,8 @@ fi
i=0
maxRetry=10
while true; do
status=$(kubectl get envsubst $2 -o json | jq ".status")
if [ ! -z "$status" ] && [ "$status" != "null" ]; then
status=$(kubectl get envsubst "$2" -o json | jq ".status")
if [ -n "$status" ] && [ "$status" != "null" ]; then
break
fi
sleep 1
Expand All @@ -99,12 +84,12 @@ while true; do
echo "ERROR: EnvSubst $2 is not being reconciled; check vcsim-server logs"
exit 1
fi
let i++
(( i++ ))
done

# Get all the variables from EnvSubst

kubectl get envsubst $2 -o json | jq ".status.variables | to_entries | map(\"export \\(.key)=\\\"\\(.value|tostring)\\\"\") | .[]" -r > vcsim.env
kubectl get envsubst "$2" -o json | jq ".status.variables | to_entries | map(\"export \\(.key)=\\\"\\(.value|tostring)\\\"\") | .[]" -r > vcsim.env

echo "done!"
echo "GOVC_URL=$(kubectl get envsubst cluster1 -o json | jq -r ".status.variables.GOVC_URL")"
Expand Down

0 comments on commit 208b606

Please sign in to comment.