Skip to content

Commit 40a8d9e

Browse files
chore: remove ggscout schemas from this repo and update flow to use mise bundle-schemas
1 parent c82e9a6 commit 40a8d9e

File tree

9 files changed

+76
-1395
lines changed

9 files changed

+76
-1395
lines changed

.github/workflows/release-with-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ jobs:
6666
echo "Installing Helm plugins..."
6767
mise run install-helm-plugins
6868
69-
- name: Fetch and bundle schemas
69+
- name: Bundle schemas
7070
run: |
71-
echo "Fetching schemas for GGScout version: ${{ github.event.inputs.ggscout_version }}"
71+
echo "Bundling schemas for GGScout version: ${{ github.event.inputs.ggscout_version }}"
7272
mise run bundle-schemas "${{ github.event.inputs.ggscout_version }}"
7373
7474
- name: Update Chart.yaml appVersion

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
*.DS_Store
44
*.egg-info/
55

6-
# Schema cache directory (populated by scripts/fetch-schemas.js)
6+
# Schema cache directory (populated by bundle-schemas)
77
.cache/

.mise-tasks/bundle-schemas

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,62 @@ echo "==================================="
1212
echo "GGScout Version: ${GGSCOUT_VERSION}"
1313
echo ""
1414

15-
# Fetch schemas for the specified version
15+
# Fetch schemas for the specified version (integrated logic)
1616
echo "Step 1: Fetching schemas..."
1717
echo "-----------------------------------"
18-
if ! node scripts/fetch-schemas.js "${GGSCOUT_VERSION}"; then
18+
19+
fetch_schemas() {
20+
local version="$1"
21+
local SCHEMA_BASE_URL="https://ggscout-repository.gitguardian.com/ggscout"
22+
local REMOTE_SCHEMA_FILES=("inventory-config.schema.json" "inventory-log-level.schema.json")
23+
local LOCAL_SCHEMA_FILES=("jobs.schema.json")
24+
local CACHE_DIR=".cache/schemas"
25+
local version_cache_dir="${CACHE_DIR}/${version}"
26+
27+
echo "Fetching schemas for GGScout version: ${version}"
28+
29+
# Create version-specific cache directory
30+
mkdir -p "${version_cache_dir}"
31+
32+
# Download remote schemas
33+
for schema_file in "${REMOTE_SCHEMA_FILES[@]}"; do
34+
local url="${SCHEMA_BASE_URL}/${version}/schemas/${schema_file}"
35+
local output_path="${version_cache_dir}/${schema_file}"
36+
37+
echo "Downloading: ${url}"
38+
if curl -fsSL "${url}" -o "${output_path}"; then
39+
echo "✓ Downloaded: ${schema_file}"
40+
else
41+
echo "✗ Failed to download: ${schema_file}"
42+
return 1
43+
fi
44+
done
45+
46+
# Copy local schemas
47+
for schema_file in "${LOCAL_SCHEMA_FILES[@]}"; do
48+
local local_path="schemas/${schema_file}"
49+
local output_path="${version_cache_dir}/${schema_file}"
50+
51+
if [[ -f "${local_path}" ]]; then
52+
cp "${local_path}" "${output_path}"
53+
echo "✓ Copied local schema: ${schema_file}"
54+
else
55+
echo "✗ Local schema not found: ${local_path}"
56+
return 1
57+
fi
58+
done
59+
60+
echo "✓ All schemas ready in: ${version_cache_dir}"
61+
return 0
62+
}
63+
64+
if ! fetch_schemas "${GGSCOUT_VERSION}"; then
1965
echo "Error: Failed to fetch schemas for version ${GGSCOUT_VERSION}"
2066
exit 1
2167
fi
2268

2369
# Determine schema source directory
2470
SCHEMA_SOURCE_DIR=".cache/schemas/${GGSCOUT_VERSION}"
25-
if [[ ! -d "${SCHEMA_SOURCE_DIR}" ]]; then
26-
echo "Error: Schema cache directory not found: ${SCHEMA_SOURCE_DIR}"
27-
exit 1
28-
fi
2971

3072
echo ""
3173
echo "Step 2: Bundling schemas..."

.mise-tasks/generate-docs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22
set -euo pipefail
33
IFS=$'\n\t'
44

5+
#USAGE arg "ggscout_version" help="GGScout version to use for schema documentation" default="latest"
6+
7+
GGSCOUT_VERSION="${1:-latest}"
8+
SCHEMA_CACHE_DIR=".cache/schemas/${GGSCOUT_VERSION}"
9+
10+
echo "Generating documentation for GGScout version: ${GGSCOUT_VERSION}"
11+
12+
# Ensure schemas are available by running bundle-schemas first
13+
if [[ ! -d "${SCHEMA_CACHE_DIR}" ]]; then
14+
echo "Schemas not found in cache. Running bundle-schemas first..."
15+
mise run bundle-schemas "${GGSCOUT_VERSION}"
16+
fi
17+
18+
# Check if the required schema file exists
19+
SCHEMA_FILE="${SCHEMA_CACHE_DIR}/inventory-config.schema.json"
20+
if [[ ! -f "${SCHEMA_FILE}" ]]; then
21+
echo "Error: Schema file not found: ${SCHEMA_FILE}"
22+
exit 1
23+
fi
24+
25+
echo "Using schema file: ${SCHEMA_FILE}"
26+
527
cd docs
6-
generate-schema-doc ../schemas/inventory-config.schema.json --config-file config_schema.yaml --deprecated-from-description
28+
generate-schema-doc "../${SCHEMA_FILE}" --config-file config_schema.yaml --deprecated-from-description
729
mv schema_doc.html index.html
830
cd ..

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ repos:
1414
language: system
1515
name: schema-bundle
1616
pass_filenames: false
17+
files: ^(charts/.*/values-base-schema\.schema\.json|schemas/jobs\.schema\.json|\.mise-tasks/bundle-schemas)$
18+
stages: [pre-commit]
1719
- entry: mise run test
1820
id: helm-unittest
1921
language: system

charts/ggscout/values.schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,6 @@
20742074
"title": "LogLevel",
20752075
"type": "string",
20762076
"enum": [
2077-
"trace",
20782077
"debug",
20792078
"info",
20802079
"warn",

0 commit comments

Comments
 (0)