Eliminates wild-app-fetch
This commit is contained in:
@@ -8,23 +8,23 @@ UPDATE=false
|
|||||||
# Parse arguments
|
# Parse arguments
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--update)
|
--force)
|
||||||
UPDATE=true
|
UPDATE=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
echo "Usage: $0 <app_name> [--force]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Configure an app by applying templates and merging configuration."
|
echo "Configure an app by applying templates and merging configuration."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --update Overwrite existing app files without confirmation"
|
echo " --force Overwrite existing app files without confirmation"
|
||||||
echo " -h, --help Show this help message"
|
echo " -h, --help Show this help message"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
echo "Unknown option $1"
|
echo "Unknown option $1"
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
echo "Usage: $0 <app_name> [--force]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -32,7 +32,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
APP_NAME="$1"
|
APP_NAME="$1"
|
||||||
else
|
else
|
||||||
echo "Too many arguments"
|
echo "Too many arguments"
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
echo "Usage: $0 <app_name> [--force]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
@@ -41,7 +41,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "${APP_NAME}" ]; then
|
if [ -z "${APP_NAME}" ]; then
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
echo "Usage: $0 <app_name> [--force]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -71,21 +71,14 @@ if [ ! -f "${SECRETS_FILE}" ]; then
|
|||||||
echo "" >> "${SECRETS_FILE}"
|
echo "" >> "${SECRETS_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if app is cached, if not fetch it first
|
# Check if app exists in repository
|
||||||
CACHE_APP_DIR="${WC_HOME}/.wildcloud/cache/apps/${APP_NAME}"
|
SOURCE_APP_DIR="${WC_ROOT}/apps/${APP_NAME}"
|
||||||
if [ ! -d "${CACHE_APP_DIR}" ]; then
|
if [ ! -d "${SOURCE_APP_DIR}" ]; then
|
||||||
echo "Cache directory for app '${APP_NAME}' not found at '${CACHE_APP_DIR}'."
|
echo "Error: App '${APP_NAME}' not found at ${SOURCE_APP_DIR}"
|
||||||
echo "Please fetch the app first using 'wild-app-fetch ${APP_NAME}'."
|
echo "Available apps:"
|
||||||
|
ls -1 "${WC_ROOT}/apps" | grep -v README.md | sed 's/^/ - /'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -d "${CACHE_APP_DIR}" ]; then
|
|
||||||
echo "App '${APP_NAME}' not found in cache, fetching..."
|
|
||||||
if [ "${UPDATE}" = true ]; then
|
|
||||||
./bin/wild-app-fetch "${APP_NAME}" --update
|
|
||||||
else
|
|
||||||
./bin/wild-app-fetch "${APP_NAME}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
APPS_DIR="${WC_HOME}/apps"
|
APPS_DIR="${WC_HOME}/apps"
|
||||||
if [ ! -d "${APPS_DIR}" ]; then
|
if [ ! -d "${APPS_DIR}" ]; then
|
||||||
@@ -113,12 +106,12 @@ else
|
|||||||
fi
|
fi
|
||||||
mkdir -p "${DEST_APP_DIR}"
|
mkdir -p "${DEST_APP_DIR}"
|
||||||
|
|
||||||
# Step 1: Copy only manifest.yaml from cache first
|
# Step 1: Copy manifest.yaml from repository first
|
||||||
MANIFEST_FILE="${CACHE_APP_DIR}/manifest.yaml"
|
MANIFEST_FILE="${SOURCE_APP_DIR}/manifest.yaml"
|
||||||
if [ -f "${MANIFEST_FILE}" ]; then
|
if [ -f "${MANIFEST_FILE}" ]; then
|
||||||
# manifest.yaml is allowed to have gomplate variables in the defaultConfig and requiredSecrets sections.
|
# manifest.yaml is allowed to have gomplate variables in the defaultConfig and requiredSecrets sections.
|
||||||
# We need to use gomplate to process these variables before using yq.
|
# We need to use gomplate to process these variables before using yq.
|
||||||
echo "Copying app manifest from cache."
|
echo "Processing app manifest."
|
||||||
DEST_MANIFEST="${DEST_APP_DIR}/manifest.yaml"
|
DEST_MANIFEST="${DEST_APP_DIR}/manifest.yaml"
|
||||||
if [ -f "${SECRETS_FILE}" ]; then
|
if [ -f "${SECRETS_FILE}" ]; then
|
||||||
gomplate_cmd="gomplate -c .=${CONFIG_FILE} -c secrets=${SECRETS_FILE} -f ${MANIFEST_FILE} -o ${DEST_MANIFEST}"
|
gomplate_cmd="gomplate -c .=${CONFIG_FILE} -c secrets=${SECRETS_FILE} -f ${MANIFEST_FILE} -o ${DEST_MANIFEST}"
|
||||||
@@ -130,7 +123,7 @@ if [ -f "${MANIFEST_FILE}" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Warning: App manifest not found in cache."
|
echo "Error: App manifest not found at ${MANIFEST_FILE}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -185,10 +178,10 @@ if yq eval '.requiredSecrets' "${DEST_MANIFEST}" | grep -q -v '^null$'; then
|
|||||||
echo "Required secrets declared in app manifest added to '${SECRETS_FILE}'."
|
echo "Required secrets declared in app manifest added to '${SECRETS_FILE}'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 3: Copy and compile all other files from cache to app directory
|
# Step 3: Copy and compile all files from repository to app directory
|
||||||
echo "Copying and compiling remaining files from cache."
|
echo "Copying and compiling app files."
|
||||||
|
|
||||||
cp -r "${CACHE_APP_DIR}/." "${DEST_APP_DIR}/"
|
cp -r "${SOURCE_APP_DIR}/." "${DEST_APP_DIR}/"
|
||||||
find "${DEST_APP_DIR}" -type f | while read -r dest_file; do
|
find "${DEST_APP_DIR}" -type f | while read -r dest_file; do
|
||||||
rel_path="${dest_file#${DEST_APP_DIR}/}"
|
rel_path="${dest_file#${DEST_APP_DIR}/}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
UPDATE=false
|
|
||||||
|
|
||||||
# Parse arguments
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--update)
|
|
||||||
UPDATE=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-h|--help)
|
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
|
||||||
echo ""
|
|
||||||
echo "Fetch an app template from the Wild Cloud repository to cache."
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --update Overwrite existing cached files without confirmation"
|
|
||||||
echo " -h, --help Show this help message"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
echo "Unknown option $1"
|
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -z "${APP_NAME}" ]; then
|
|
||||||
APP_NAME="$1"
|
|
||||||
else
|
|
||||||
echo "Too many arguments"
|
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "${APP_NAME}" ]; then
|
|
||||||
echo "Usage: $0 <app_name> [--update]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Initialize Wild Cloud environment
|
|
||||||
if [ -z "${WC_ROOT}" ]; then
|
|
||||||
echo "WC_ROOT is not set."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
source "${WC_ROOT}/scripts/common.sh"
|
|
||||||
init_wild_env
|
|
||||||
fi
|
|
||||||
|
|
||||||
SOURCE_APP_DIR="${WC_ROOT}/apps/${APP_NAME}"
|
|
||||||
if [ ! -d "${SOURCE_APP_DIR}" ]; then
|
|
||||||
echo "Error: App '${APP_NAME}' not found at ${SOURCE_APP_DIR}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
CACHE_APP_DIR=".wildcloud/cache/apps/${APP_NAME}"
|
|
||||||
mkdir -p ".wildcloud/cache/apps"
|
|
||||||
|
|
||||||
if [ -d "${CACHE_APP_DIR}" ]; then
|
|
||||||
if [ "${UPDATE}" = true ]; then
|
|
||||||
echo "Updating cached app '${APP_NAME}'"
|
|
||||||
rm -rf "${CACHE_APP_DIR}"
|
|
||||||
else
|
|
||||||
echo "Warning: Cache directory ${CACHE_APP_DIR} already exists"
|
|
||||||
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
echo "Fetch cancelled"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm -rf "${CACHE_APP_DIR}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Fetching app '${APP_NAME}' from ${SOURCE_APP_DIR} to ${CACHE_APP_DIR}"
|
|
||||||
|
|
||||||
# Create destination directory
|
|
||||||
mkdir -p "${CACHE_APP_DIR}"
|
|
||||||
|
|
||||||
# Copy directory structure and files (no template processing)
|
|
||||||
find "${SOURCE_APP_DIR}" -type d | while read -r src_dir; do
|
|
||||||
rel_path="${src_dir#${SOURCE_APP_DIR}}"
|
|
||||||
rel_path="${rel_path#/}" # Remove leading slash if present
|
|
||||||
if [ -n "${rel_path}" ]; then
|
|
||||||
mkdir -p "${CACHE_APP_DIR}/${rel_path}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
find "${SOURCE_APP_DIR}" -type f | while read -r src_file; do
|
|
||||||
rel_path="${src_file#${SOURCE_APP_DIR}}"
|
|
||||||
rel_path="${rel_path#/}" # Remove leading slash if present
|
|
||||||
dest_file="${CACHE_APP_DIR}/${rel_path}"
|
|
||||||
|
|
||||||
# Ensure destination directory exists
|
|
||||||
dest_dir=$(dirname "${dest_file}")
|
|
||||||
mkdir -p "${dest_dir}"
|
|
||||||
|
|
||||||
# Simple copy without template processing
|
|
||||||
cp "${src_file}" "${dest_file}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Successfully fetched app '${APP_NAME}' to cache"
|
|
||||||
@@ -186,8 +186,7 @@ elif [ "${OUTPUT_FORMAT}" = "table" ]; then
|
|||||||
echo "Total installable apps: ${app_count}"
|
echo "Total installable apps: ${app_count}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " wild-app-fetch <app> # Fetch app template to cache"
|
echo " wild-app-add <app> # Configure app with your settings"
|
||||||
echo " wild-app-config <app> # Configure app with your settings"
|
|
||||||
echo " wild-app-deploy <app> # Deploy app to Kubernetes"
|
echo " wild-app-deploy <app> # Deploy app to Kubernetes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user