Add wild-app-fetch, wild-app-config, and wild-app-deploy scripts; update README with app workflow
This commit is contained in:
@@ -21,17 +21,12 @@ if [ ! -f ".wildcloud/config.yaml" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WILDCLOUD_REPO=$(yq eval '.wildcloud.repository' .wildcloud/config.yaml)
|
CACHE_APP_DIR=".wildcloud/cache/apps/${APP_NAME}"
|
||||||
|
|
||||||
if [ -z "${WILDCLOUD_REPO}" ] || [ "${WILDCLOUD_REPO}" = "null" ]; then
|
# Check if app is cached, if not fetch it first
|
||||||
echo "Error: wildcloud.config not found in .wildcloud/config.yaml"
|
if [ ! -d "${CACHE_APP_DIR}" ]; then
|
||||||
exit 1
|
echo "App '${APP_NAME}' not found in cache, fetching..."
|
||||||
fi
|
./bin/wild-app-fetch "${APP_NAME}"
|
||||||
|
|
||||||
SOURCE_APP_DIR="${WILDCLOUD_REPO}/apps/${APP_NAME}"
|
|
||||||
if [ ! -d "${SOURCE_APP_DIR}" ]; then
|
|
||||||
echo "Error: App '${APP_NAME}' not found at ${SOURCE_APP_DIR}"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEST_APP_DIR="apps/${APP_NAME}"
|
DEST_APP_DIR="apps/${APP_NAME}"
|
||||||
@@ -42,13 +37,13 @@ if [ -d "${DEST_APP_DIR}" ]; then
|
|||||||
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
|
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
|
||||||
echo
|
echo
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
echo "Installation cancelled"
|
echo "Pull cancelled"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -rf "${DEST_APP_DIR}"
|
rm -rf "${DEST_APP_DIR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Copying app '${APP_NAME}' from ${SOURCE_APP_DIR} to ${DEST_APP_DIR}"
|
echo "Pulling app '${APP_NAME}' from cache to ${DEST_APP_DIR}"
|
||||||
|
|
||||||
# Function to process a file with gomplate if it's a YAML file
|
# Function to process a file with gomplate if it's a YAML file
|
||||||
process_file() {
|
process_file() {
|
||||||
@@ -67,16 +62,16 @@ process_file() {
|
|||||||
mkdir -p "${DEST_APP_DIR}"
|
mkdir -p "${DEST_APP_DIR}"
|
||||||
|
|
||||||
# Copy directory structure and process files
|
# Copy directory structure and process files
|
||||||
find "${SOURCE_APP_DIR}" -type d | while read -r src_dir; do
|
find "${CACHE_APP_DIR}" -type d | while read -r src_dir; do
|
||||||
rel_path="${src_dir#${SOURCE_APP_DIR}}"
|
rel_path="${src_dir#${CACHE_APP_DIR}}"
|
||||||
rel_path="${rel_path#/}" # Remove leading slash if present
|
rel_path="${rel_path#/}" # Remove leading slash if present
|
||||||
if [ -n "${rel_path}" ]; then
|
if [ -n "${rel_path}" ]; then
|
||||||
mkdir -p "${DEST_APP_DIR}/${rel_path}"
|
mkdir -p "${DEST_APP_DIR}/${rel_path}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
find "${SOURCE_APP_DIR}" -type f | while read -r src_file; do
|
find "${CACHE_APP_DIR}" -type f | while read -r src_file; do
|
||||||
rel_path="${src_file#${SOURCE_APP_DIR}}"
|
rel_path="${src_file#${CACHE_APP_DIR}}"
|
||||||
rel_path="${rel_path#/}" # Remove leading slash if present
|
rel_path="${rel_path#/}" # Remove leading slash if present
|
||||||
dest_file="${DEST_APP_DIR}/${rel_path}"
|
dest_file="${DEST_APP_DIR}/${rel_path}"
|
||||||
|
|
||||||
@@ -87,4 +82,4 @@ find "${SOURCE_APP_DIR}" -type f | while read -r src_file; do
|
|||||||
process_file "${src_file}" "${dest_file}"
|
process_file "${src_file}" "${dest_file}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Successfully installed app '${APP_NAME}' with template processing"
|
echo "Successfully pulled app '${APP_NAME}' with template processing"
|
52
bin/wild-app-deploy
Executable file
52
bin/wild-app-deploy
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
FORCE=false
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--force)
|
||||||
|
FORCE=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--dry-run)
|
||||||
|
DRY_RUN="--dry-run=client"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo "Unknown option $1"
|
||||||
|
echo "Usage: $0 <app_name> [--force] [--dry-run]"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ -z "${APP_NAME}" ]; then
|
||||||
|
APP_NAME="$1"
|
||||||
|
else
|
||||||
|
echo "Too many arguments"
|
||||||
|
echo "Usage: $0 <app_name> [--force] [--dry-run]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "${APP_NAME}" ]; then
|
||||||
|
echo "Usage: $0 <app_name> [--force] [--dry-run]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "apps/${APP_NAME}" ]; then
|
||||||
|
echo "Error: App directory 'apps/${APP_NAME}' not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${FORCE}" = true ]; then
|
||||||
|
echo "Force deploying app '${APP_NAME}'"
|
||||||
|
kubectl replace --force -k "apps/${APP_NAME}" ${DRY_RUN:-}
|
||||||
|
else
|
||||||
|
echo "Deploying app '${APP_NAME}'"
|
||||||
|
kubectl apply -k "apps/${APP_NAME}" ${DRY_RUN:-}
|
||||||
|
fi
|
78
bin/wild-app-fetch
Executable file
78
bin/wild-app-fetch
Executable file
@@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <app_name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
APP_NAME="$1"
|
||||||
|
|
||||||
|
if [ ! -d ".wildcloud" ]; then
|
||||||
|
echo "Error: .wildcloud directory not found in current directory"
|
||||||
|
echo "This script must be run from a directory that contains a .wildcloud directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f ".wildcloud/config.yaml" ]; then
|
||||||
|
echo "Error: .wildcloud/config.yaml not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
WILDCLOUD_REPO=$(yq eval '.wildcloud.repository' .wildcloud/config.yaml)
|
||||||
|
|
||||||
|
if [ -z "${WILDCLOUD_REPO}" ] || [ "${WILDCLOUD_REPO}" = "null" ]; then
|
||||||
|
echo "Error: wildcloud.config not found in .wildcloud/config.yaml"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOURCE_APP_DIR="${WILDCLOUD_REPO}/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
|
||||||
|
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
|
||||||
|
|
||||||
|
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"
|
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ $# -ne 1 ]; then
|
|
||||||
echo "Usage: $0 <app_name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
APP_NAME="$1"
|
|
||||||
|
|
||||||
kubectl apply -k "apps/${APP_NAME}"
|
|
@@ -10,20 +10,39 @@ To list all available apps:
|
|||||||
wild-cloud-app-list
|
wild-cloud-app-list
|
||||||
```
|
```
|
||||||
|
|
||||||
To add a new app:
|
### App Workflow
|
||||||
|
|
||||||
|
The Wild-cloud app workflow consists of three steps:
|
||||||
|
|
||||||
|
1. **Fetch** - Download raw app templates to cache
|
||||||
|
2. **Config** - Apply your local configuration to templates
|
||||||
|
3. **Deploy** - Deploy configured app to Kubernetes
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
To fetch an app template to cache:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wild-cloud-add <app>
|
wild-app-fetch <app>
|
||||||
```
|
```
|
||||||
|
|
||||||
To install the app:
|
To apply your configuration to a cached app (automatically fetches if not cached):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wild-cloud-install <app>
|
wild-app-config <app>
|
||||||
```
|
```
|
||||||
|
|
||||||
To update the app:
|
To deploy a configured app to Kubernetes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
TBD
|
wild-app-deploy <app>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Quick Setup
|
||||||
|
|
||||||
|
For a complete app setup and deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wild-app-config <app> # Fetches if needed, then configures
|
||||||
|
wild-app-deploy <app> # Deploys to Kubernetes
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user