-
Notifications
You must be signed in to change notification settings - Fork 6
Explode Command
The explode command breaks down a Gateway configuration bundle into multiple individual files organized by entity type and folder structure. This is useful for version control, code review, and managing large configurations.
graphman explode --input <input-file> --output <output-dir>
[--options.<name> <value>,...]| Parameter | Description |
|---|---|
--input |
Input bundle file containing Gateway configuration |
--output |
Output directory where files will be created |
| Parameter | Description | Default |
|---|---|---|
--options.level |
Level of explosion (0, 1, or 2) | 0 |
The level option controls how deeply the bundle is exploded:
| Level | Description | What Gets Exploded |
|---|---|---|
| 0 | Basic | Individual entities into separate JSON files |
| 1 | Intermediate | Level 0 + WSDL resources, certificates (PEM/P12), certificate chains |
| 2 | Complete | Level 1 + Policy code (XML, JSON, YAML) into separate files |
output-dir/
├── services/
│ ├── Service1.service.json
│ └── Service2.service.json
├── policies/
│ ├── Policy1.policy.json
│ └── Policy2.policy.json
├── folders/
│ └── MyFolder.folder.json
├── keys/
│ └── MyKey.key.json
└── bundle-properties.json
output-dir/
├── services/
│ ├── Service1.service.json
│ ├── Service1.wsdl
│ ├── Service1-wsdl-resource-1.xml
│ └── Service1-wsdl-resource-2.xml
├── keys/
│ ├── MyKey.key.json
│ ├── MyKey.p12 # Binary key file
│ └── MyKey.certchain.pem # Certificate chain
└── trustedCerts/
├── TrustedCert1.cert.json
└── TrustedCert1.pem
output-dir/
├── services/
│ ├── Service1.service.json
│ ├── Service1.xml # Policy XML
│ └── Service1-revision-1.xml
├── policies/
│ ├── Policy1.policy.json
│ └── Policy1.cjson # Policy code JSON
└── policyFragments/
├── Fragment1.fragment.json
└── Fragment1.yaml # Policy YAML
Entities with folder paths are organized hierarchically:
output-dir/
└── tree/
└── APIs/
└── External/
├── CustomerAPI.service.json
└── CustomerAPI.xml
Explode bundle into individual entity files:
graphman explode --input bundle.json --output exploded/Include certificates and WSDL resources:
graphman explode --input bundle.json --output exploded/ --options.level 1Explode everything including policy code:
graphman explode --input bundle.json --output exploded/ --options.level 2Explode bundle for Git repository:
graphman explode --input prod-config.json --output repo/gateway-config/ --options.level 2
cd repo
git add gateway-config/
git commit -m "Updated gateway configuration"Store Gateway configuration in Git with readable diffs:
graphman export --gateway prod --output temp-bundle.json
graphman explode --input temp-bundle.json --output repo/config/ --options.level 2
rm temp-bundle.json
git add repo/config/
git commit -m "Production configuration snapshot"Make configuration changes reviewable:
# Before changes
graphman export --gateway dev --output before.json
graphman explode --input before.json --output review/before/ --options.level 2
# After changes
graphman export --gateway dev --output after.json
graphman explode --input after.json --output review/after/ --options.level 2
# Review differences
diff -r review/before/ review/after/Edit specific entities manually:
graphman explode --input bundle.json --output work/ --options.level 2
# Edit work/services/MyService.service.json
# Edit work/services/MyService.xml
graphman implode --input work/ --output modified-bundle.jsonGenerate human-readable configuration documentation:
graphman explode --input prod-config.json --output docs/prod-config/ --options.level 2
# Review individual files for documentationOrganize backups in a readable format:
DATE=$(date +%Y%m%d)
graphman export --gateway prod --output temp.json
graphman explode --input temp.json --output backups/$DATE/ --options.level 1
rm temp.jsonExtract policies for development:
graphman export --using policies --gateway dev --output policies.json
graphman explode --input policies.json --output policy-dev/ --options.level 2
# Develop policies in policy-dev/- Services:
<name>.service.json - Policies:
<name>.policy.json - Policy Fragments:
<name>.fragment.json - Folders:
<name>.folder.json - Keys:
<name>.key.json - Trusted Certificates:
<name>.cert.json
- WSDL:
<name>.wsdl - WSDL Resources:
<name>-wsdl-resource-<n>.xml - Policy XML:
<name>.xml - Policy JSON:
<name>.cjson - Policy YAML:
<name>.yaml - Policy Revisions:
<name>-revision-<n>.xml - Certificate PEM:
<name>.pem - Key P12:
<name>.p12 - Certificate Chain:
<name>.certchain.pem
When duplicate entities are found (same name), they are differentiated:
services/
├── MyService.service.json
└── MyService-1234567890-123.service.json # Duplicate with timestamp
Entity names are converted to safe file names:
- Special characters are replaced with underscores
- Spaces are preserved or replaced based on OS
- Path separators are handled appropriately
Bundle-level properties are saved separately:
// bundle-properties.json
{
"meta": {
"summary": true,
"gateway": "production"
}
}- The output directory is created if it doesn't exist
- Existing files in the output directory may be overwritten
- Entity names must be unique within their type (or timestamps are added)
- Binary files (P12, JAR) are written in binary format
- Text files use UTF-8 encoding with CRLF line endings
- The
treedirectory contains entities with folder paths - Level 2 explosion is recommended for version control
- Large bundles may create thousands of files
Exploded files use a special reference format in JSON:
{
"name": "MyService",
"policy": {
"xml": "{{MyService.xml}}"
},
"wsdl": "{{MyService.wsdl}}"
}The {{filename}} format indicates the content is in a separate file.
- P12 format preferred over PEM if both exist
- Certificate chains extracted to separate PEM file
- Binary P12 files are base64 decoded
- Certificate data extracted to PEM format
- PEM headers added automatically
- Certificate data extracted to PEM format
- SSH public keys extracted to
.pubfiles
When multiple policy formats exist, the following priority is used:
- XML (if present)
- JSON (if present)
- Code (if present)
- YAML (if present)
Only the highest priority format is exploded; others are removed.
- implode: Reverse operation - combine files back into bundle
- export: Export configuration before exploding
- slice: Extract specific sections before exploding
- Use Level 2 for version control - provides maximum readability
- Use Level 1 for backups - balances readability and file count
- Use Level 0 for quick inspection - minimal file creation
- Clean output directory before exploding to avoid stale files
- Use with implode to round-trip test configurations
- Commit to version control after exploding for tracking
- Document folder structure in repository README
Complete workflow for version-controlled configuration:
#!/bin/bash
# Export from gateway
graphman export --gateway prod --output temp.json
# Explode for version control
graphman explode --input temp.json --output config/ --options.level 2
# Clean up
rm temp.json
# Commit to Git
git add config/
git commit -m "Configuration update $(date +%Y-%m-%d)"
git push