#!/bin/bash # Fission Configuration Analyzer # Analyzes and displays fission configuration from .fission directory set -euo pipefail usage() { echo "Usage: $0 " echo " project-path: Path to the fission project directory (should contain .fission/ subdirectory)" exit 1 } if [[ $# -ne 1 ]]; then usage fi PROJECT_PATH="$1" # Validate project path if [[ ! -d "$PROJECT_PATH" ]]; then echo "Error: Project path '$PROJECT_PATH' does not exist" exit 1 fi FISSION_DIR="$PROJECT_PATH/.fission" if [[ ! -d "$FISSION_DIR" ]]; then echo "Error: .fission directory not found in '$PROJECT_PATH'" exit 1 fi echo "🔍 Analyzing Fission configuration in '$PROJECT_PATH'" echo "==================================================" # Analyze deployment.json (main configuration) if [[ -f "$FISSION_DIR/deployment.json" ]]; then echo "" echo "📋 DEPLOYMENT CONFIGURATION" echo "--------------------------" # Extract namespaces namespace=$(jq -r '.namespace // "default"' "$FISSION_DIR/deployment.json") echo "Namespace: $namespace" # Analyze environments echo "" echo "🌐 ENVIRONMENTS:" if jq -e '.environments' "$FISSION_DIR/deployment.json" >/dev/null; then jq -r '.environments | to_entries[] | " \(.key):" + "\n Image: \(.value.image // "N/A")" + "\n Builder: \(.value.builder // "N/A")" + "\n CPU: \(.value.mincpu // 0)m-\(.value.maxcpu // 0)m" + "\n Memory: \(.value.minmemory // 0)Mi-\(.value.maxmemory // 0)Mi" + "\n Pool Size: \(.value.poolsize // 1)"' "$FISSION_DIR/deployment.json" else echo " No environments defined" fi # Analyze packages echo "" echo "📦 PACKAGES:" if jq -e '.packages' "$FISSION_DIR/deployment.json" >/dev/null; then jq -r '.packages | to_entries[] | " \(.key):" + "\n Build Command: \(.value.buildcmd // "N/A")" + "\n Source Archive: \(.value.sourcearchive // "N/A")" + "\n Environment: \(.value.env // "N/A")"' "$FISSION_DIR/deployment.json" else echo " No packages defined" fi # Analyze functions (from function_common and individual functions) echo "" echo "⚙️ FUNCTIONS:" if jq -e '.function_common' "$FISSION_DIR/deployment.json" >/dev/null; then echo " Common Configuration:" jq -r '.function_common | " Package: \(.pkg // "N/A")" + "\n Executor Type: \(.executor.select // "N/A")" + "\n CPU: \(.mincpu // 0)m-\(.maxcpu // 0)m" + "\n Memory: \(.minmemory // 0)Mi-\(.maxmemory // 0)Mi"' "$FISSION_DIR/deployment.json" fi # Look for individual function definitions if jq -e '.functions' "$FISSION_DIR/deployment.json" >/dev/null; then echo "" echo " Individual Functions:" jq -r '.functions | to_entries[] | " \(.key):" + "\n Executor: \(.value.executor // "N/A")"' "$FISSION_DIR/deployment.json" else echo " No individual functions defined (using function_common)" fi # Analyze secrets echo "" echo "🔐 SECRETS:" if jq -e '.secrets' "$FISSION_DIR/deployment.json" >/dev/null; then jq -r '.secrets | to_entries[] | " \(.key):" + "\n Type: \(.value.kind // "literal")" + "\n Literal Count: \(.value.literals | length // 0)"' "$FISSION_DIR/deployment.json" else echo " No secrets defined" fi # Analyze configmaps echo "" echo "⚙️ CONFIGMAPS:" if jq -e '.configmaps' "$FISSION_DIR/deployment.json" >/dev/null; then jq -r '.configmaps | to_entries[] | " \(.key):" + "\n Literal Count: \(.value.literals | length // 0)"' "$FISSION_DIR/deployment.json" else echo " No configmaps defined" fi # Analyze archives echo "" echo "📦 ARCHIVES:" if jq -e '.archives' "$FISSION_DIR/deployment.json" >/dev/null; then jq -r '.archives | to_entries[] | " \(.key):" + "\n Source Path: \(.value.sourcepath // "N/A")"' "$FISSION_DIR/deployment.json" else echo " No archives defined" fi else echo "" echo "⚠️ deployment.json not found in .fission directory" fi # Check for other fission files echo "" echo "📄 OTHER FISSION FILES:" shopt -s nullglob fission_files=("$FISSION_DIR"/*.json) if [[ ${#fission_files[@]} -gt 0 ]]; then for file in "${fission_files[@]}"; do filename=$(basename "$file") if [[ "$filename" != "deployment.json" ]]; then echo " $filename" # Show brief content if [[ -s "$file" ]]; then line_count=$(wc -l < "$file") echo " ($line_count lines)" fi fi done else echo " No other .json files found" fi echo "" echo "✅ Analysis complete"