Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

Feature/add repo username password #47

Closed
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
28 changes: 14 additions & 14 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: PUSH
# name: PUSH

on: [push]
# on: [push]

jobs:
push-container:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Publish to Docker Hub
uses: elgohr/[email protected]
with:
name: stefanprodan/hrval
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tag_names: true
# jobs:
# push-container:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - name: Publish to Docker Hub
# uses: elgohr/[email protected]
# with:
# name: stefanprodan/hrval
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# tag_names: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# hrval-action

![CI](https://github.com/stefanprodan/hrval-action/workflows/CI/badge.svg)
![CI](https://github.com/tenna-llc/hrval-action/workflows/CI/badge.svg)
[![Docker](https://img.shields.io/badge/Docker%20Hub-stefanprodan%2Fhrval-blue)](https://hub.docker.com/r/stefanprodan/hrval)
[![GitHub Super-Linter](https://github.com/stefanprodan/hrval-action/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
[![GitHub Super-Linter](https://github.com/tenna-llc/hrval-action/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)

This GitHub action validates a Flux
[Helm Release](https://docs.fluxcd.io/projects/helm-operator/en/latest/references/helmrelease-custom-resource.html)
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ inputs:
awsS3Plugin:
description: '(Optional) AWS S3 Plugin to be used in the helm plugin install command'
default: ''
chartRepoUserName:
description: '(Optional) The user name for the chart repo'
default: ''
chartRepoPassword:
descriptiono: '(Optional) The password for the chart repo'
default: ''
helmSourcesCacheEnabled:
description: '(Optional) Enabled Helm source caching, so same release or ref will not be downloaded twice.'
default: 'false'
Expand All @@ -44,4 +50,6 @@ runs:
- ${{ inputs.awsS3Repo }}
- ${{ inputs.awsS3RepoName }}
- ${{ inputs.awsS3RepoPlugin }}
- ${{ inputs.chartRepoUserName }}
- ${{ inputs.chartRepoPassword }}
- ${{ inputs.helmSourcesCacheEnabled }}
6 changes: 4 additions & 2 deletions src/hrval-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ HRVAL="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/hrval.s
AWS_S3_REPO=${5-false}
AWS_S3_REPO_NAME=${6-""}
AWS_S3_PLUGIN="${7-""}"
HELM_SOURCES_CACHE_ENABLED=${8-""}
CHART_REPO_USERNAME=${8-""}
CHART_REPO_PASSWORD=${9-""}
HELM_SOURCES_CACHE_ENABLED=${10-""}

if [ "${HELM_SOURCES_CACHE_ENABLED}" == "true" ]; then
CACHEDIR=$(mktemp -d)
Expand Down Expand Up @@ -58,7 +60,7 @@ done < <(find "${DIR}" -type f -name '*.yaml' -o -name '*.yml')

for f in "${FOUND_FILES[@]}"; do
if [[ $(isHelmRelease "${f}") == "true" ]]; then
${HRVAL} "${f}" "${IGNORE_VALUES}" "${KUBE_VER}" "${HELM_VER}" "${CACHEDIR}"
${HRVAL} "${f}" "${IGNORE_VALUES}" "${KUBE_VER}" "${HELM_VER}" "${CACHEDIR}" "${CHART_REPO_USERNAME}" "${CHART_REPO_PASSWORD}"
FILES_TESTED=$(( FILES_TESTED+1 ))
else
echo "Ignoring ${f} not a HelmRelease"
Expand Down
16 changes: 14 additions & 2 deletions src/hrval.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ IGNORE_VALUES="${2}"
KUBE_VER="${3-master}"
HELM_VER="${4-v2}"
CACHEDIR="${5-""}"
CHART_REPO_USERNAME="${6-""}"
CHART_REPO_PASSWORD="${7-""}"

if test ! -f "${HELM_RELEASE}"; then
echo "\"${HELM_RELEASE}\" Helm release file not found!"
Expand Down Expand Up @@ -34,11 +36,21 @@ function download {
CHART_REPO_MD5=$(/bin/echo "${CHART_REPO}" | /usr/bin/md5sum | cut -f1 -d" ")

if [[ "${HELM_VER}" == "v3" ]]; then
helmv3 repo add "${CHART_REPO_MD5}" "${CHART_REPO}"
if [[ -z ${CHART_REPO_USERNAME} ]];
then
helmv3 repo add "${CHART_REPO_MD5}" "${CHART_REPO}"
else
helmv3 repo add "${CHART_REPO_MD5}" "${CHART_REPO}" --username "${CHART_REPO_USERNAME}" --password "${CHART_REPO_PASSWORD}"
fi
helmv3 repo update
helmv3 fetch --version "${CHART_VERSION}" --untar "${CHART_REPO_MD5}/${CHART_NAME}" --untardir "${2}"
else
helm repo add "${CHART_REPO_MD5}" "${CHART_REPO}"
if [[ -z ${CHART_REPO_USERNAME} ]];
then
helm repo add "${CHART_REPO_MD5}" "${CHART_REPO}"
else
helm repo add "${CHART_REPO_MD5}" "${CHART_REPO}" --username "${CHART_REPO_USERNAME}" --password "${CHART_REPO_PASSWORD}"
fi
helm repo update
helm fetch --version "${CHART_VERSION}" --untar "${CHART_REPO_MD5}/${CHART_NAME}" --untardir "${2}"
fi
Expand Down