fix(gpg): Check GPG env variables before exiting if gpgkeys directory is empty

This commit is contained in:
Carlos Álvaro
2022-11-10 21:07:29 +01:00
committed by Carlos D. Álvaro
parent d2f4f581bb
commit f133516e14
6 changed files with 17 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ The full log with the outputted error.
**Version report (please complete the following information):**
- Host OS: [e.g. `uname -a`]
- Docker: [e.g. `docker --version`]
- Image tag: [e.g. `3005.1-2`]
- Image tag: [e.g. `3005.1-2_1`]
**Additional context**
Add any other context about the problem here.

View File

@@ -4,6 +4,10 @@ This file only reflects the changes that are made in this image.
Please refer to the [Salt 3005.1 Release Notes](https://docs.saltstack.com/en/latest/topics/releases/3005.1.html)
for the list of changes in SaltStack.
**3005.1-2_1**
- Fix: check GPG env variables before exiting if `gpgkeys` directory is empty.
**3005.1-2**
- Upgrade `salt-master` to `3005.1-2` *Phosphorus*.

View File

@@ -5,7 +5,7 @@ ARG VCS_REF
# https://github.com/saltstack/salt/releases
ENV SALT_VERSION="3005.1-2"
ENV IMAGE_VERSION="${SALT_VERSION}"
ENV IMAGE_VERSION="${SALT_VERSION}_1"
ENV SALT_DOCKER_DIR="/etc/docker-salt" \
SALT_ROOT_DIR="/etc/salt" \

View File

@@ -18,7 +18,7 @@ build:
release: build
@docker tag cdalvaro/docker-salt-master:latest \
cdalvaro/docker-salt-master:$(shell cat VERSION)
cdalvaro/docker-salt-master:$(shell cat VERSION)_1
quickstart:
@echo "Starting docker-salt-master container..."

View File

@@ -24,7 +24,7 @@ Automated builds of the image are available on
the recommended method of installation.
```sh
docker pull ghcr.io/cdalvaro/docker-salt-master:3005.1-2
docker pull ghcr.io/cdalvaro/docker-salt-master:3005.1-2_1
```
You can also pull the latest tag which is built from the repository `HEAD`

View File

@@ -276,8 +276,11 @@ function _check_and_link_gpgkey() {
return 1
fi
mkdir -p "$(dirname "${TARGET_GPGKEY}")"
log_info "Linking '${SOURCE_GPGKEY}' to '${TARGET_GPGKEY}' ..."
ln -sfn "${SOURCE_GPGKEY}" "${TARGET_GPGKEY}"
chown "${SALT_USER}:${SALT_USER}" "${TARGET_GPGKEY}"
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
@@ -286,15 +289,19 @@ function _check_and_link_gpgkey() {
#----------------------------------------------------------------------------------------------------------------------
function _setup_gpgkeys()
{
[[ -d "${SALT_KEYS_GPGKEYS_DIR}" && -n "$(ls -A "${SALT_KEYS_GPGKEYS_DIR}")" ]] || return 0
log_info " ==> Setting up GPG keys ..."
local private_key="${SALT_KEYS_GPGKEYS_DIR}/private.key"
local public_key="${SALT_KEYS_GPGKEYS_DIR}/pubkey.gpg"
_check_and_link_gpgkey 'SALT_GPG_PRIVATE_KEY_FILE' "${private_key}"
_check_and_link_gpgkey 'SALT_GPG_PUBLIC_KEY_FILE' "${public_key}"
if [[ ! -d "${SALT_KEYS_GPGKEYS_DIR}" || -z "$(ls -A "${SALT_KEYS_GPGKEYS_DIR}")" ]]; then
log_info "Could not find GPG keys. GPG setup skipped."
return 0
fi
if [[ ! -f "${private_key}" || ! -f "${public_key}" ]]; then
log_error "GPG keys are not valid. Please, check the documentation for more information:"
log_error " - https://github.com/cdalvaro/docker-salt-master#gpg-keys-for-renderers"