Compare commits
3 Commits
28cf195719
...
19fd9f4d83
| Author | SHA1 | Date | |
|---|---|---|---|
|
19fd9f4d83
|
|||
|
489b3dcf62
|
|||
|
1e72c98f9c
|
@@ -2,7 +2,22 @@
|
||||
set -e
|
||||
|
||||
main() {
|
||||
docker compose run --rm --workdir "${PWD}" --volume "${PWD}:${PWD}" -t cli infisical "${@}"
|
||||
declare -a args=("--rm" "--workdir" "${PWD}" "--volume" "${PWD}:${PWD}" "-t")
|
||||
|
||||
if [ -n "${INFISICAL_TOKEN}" ]; then
|
||||
args+=("--env" "INFISICAL_TOKEN=${INFISICAL_TOKEN}")
|
||||
fi
|
||||
|
||||
if [ -n "${INFISICAL_API_URL:-}" ]; then
|
||||
args+=("--env" "INFISICAL_API_URL=${INFISICAL_API_URL}")
|
||||
fi
|
||||
|
||||
if [ -n "${INFISICAL_CLI_DOCKER_INSTALL_DIR:-}" ]; then
|
||||
docker compose --project-directory="${INFISICAL_CLI_DOCKER_INSTALL_DIR}" run "${args[@]}" cli infisical "${@}"
|
||||
return
|
||||
fi
|
||||
|
||||
docker compose run "${args[@]}" cli infisical "${@}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
||||
19
dist/scripts/src/fetch-secrets.sh
vendored
19
dist/scripts/src/fetch-secrets.sh
vendored
@@ -5,9 +5,14 @@ fetch_secret() {
|
||||
local env="${2:?Environment is required}"
|
||||
local output_file="${3:?}"
|
||||
|
||||
script -q /dev/null \
|
||||
-c "docker compose run --rm -t cli infisical secrets --plain get ""${target_secret}"" --env ""${env}""" \
|
||||
>"${output_file}"
|
||||
if command -v infisical &>/dev/null; then
|
||||
# If infisical CLI command is available, use it directly
|
||||
infisical secrets --plain get "${target_secret}" --env "${env}" >"${output_file}"
|
||||
else
|
||||
script -q /dev/null \
|
||||
-c "docker compose run --rm -t cli infisical secrets --plain get ""${target_secret}"" --env ""${env}""" \
|
||||
>"${output_file}"
|
||||
fi
|
||||
|
||||
# Check if file is empty
|
||||
if [[ ! -s ${output_file} ]]; then
|
||||
@@ -19,12 +24,12 @@ main() {
|
||||
local config_file="${1:-./secrets.json}"
|
||||
local secrets_dir="${2:-./secrets}"
|
||||
|
||||
if ! command -v jq &> /dev/null; then
|
||||
if ! command -v jq &>/dev/null; then
|
||||
printf "Error: jq is required but not installed\n" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${config_file}" ]]; then
|
||||
if [[ ! -f ${config_file} ]]; then
|
||||
printf "Error: Config file %s not found\n" "${config_file}" >&2
|
||||
return 1
|
||||
fi
|
||||
@@ -45,11 +50,11 @@ main() {
|
||||
output_file="${secrets_dir}/${output_file}"
|
||||
|
||||
# If filename is specified in json, use it; otherwise, use the local_secret as the filename
|
||||
if [[ -n "${filename}" && "${filename}" != "null" ]]; then
|
||||
if [[ -n ${filename} && ${filename} != "null" ]]; then
|
||||
output_file="${secrets_dir}/${filename}"
|
||||
fi
|
||||
|
||||
if [[ -z "${env}" ]]; then
|
||||
if [[ -z ${env} ]]; then
|
||||
printf "Warning: Environment not specified for secret %s, assuming 'prod'\n" "${local_secret}" >&2
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user