Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/bash env test #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "nexus-push"
version: "0.0.1"
version: "1.0.0"
usage: "Push chart or packaged chart to a specified repo"
description: |-
Pushes a chart directory or packaged chart tgz to a specified repo,
Expand Down
18 changes: 10 additions & 8 deletions push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ declare REPO=$1
declare REPO_URL="$(helm repo list | grep "^$REPO" | awk '{print $2}')/"
declare REPO_AUTH_FILE="$(helm home)/repository/auth.$REPO"

if [[ -z "$REPO_URL" ]]; then
if [[ -z "${REPO_URL:-}" ]]; then
echo "Invalid repo specified! Must specify one of these repos..."
helm repo list
echo "---"
Expand All @@ -84,10 +84,10 @@ declare CHART

case "$2" in
login)
if [[ -z "$USERNAME" ]]; then
if [[ -z "${USERNAME:-}" ]]; then
read -p "Username: " USERNAME
fi
if [[ -z "$PASSWORD" ]]; then
if [[ -z "${PASSWORD:-}" ]]; then
read -s -p "Password: " PASSWORD
echo
fi
Expand All @@ -100,23 +100,25 @@ case "$2" in
CMD=push
CHART=$2

if [[ -z "$USERNAME" ]] || [[ -z "$PASSWORD" ]]; then
if [[ -f "$REPO_AUTH_FILE" ]]; then
if [[ -z "${USERNAME:-}" ]] || [[ -z "${PASSWORD:-}" ]]; then
if [[ -f "${REPO_AUTH_FILE:-}" ]]; then
echo "Using cached login creds..."
AUTH="$(cat $REPO_AUTH_FILE)"
else
if [[ -z "$USERNAME" ]]; then
if [[ -z "${USERNAME:-}" ]]; then
read -p "Username: " USERNAME
fi
if [[ -z "$PASSWORD" ]]; then
if [[ -z "${PASSWORD:-}" ]]; then
read -s -p "Password: " PASSWORD
echo
fi
AUTH="$USERNAME:$PASSWORD"
fi
else
AUTH="$USERNAME:$PASSWORD"
fi

if [[ -d "$CHART" ]]; then
if [[ -d "${CHART:-}" ]]; then
CHART_PACKAGE="$(helm package "$CHART" | cut -d":" -f2 | tr -d '[:space:]')"
else
CHART_PACKAGE="$CHART"
Expand Down