A powerful Gauge plugin that enables dynamic resolution of placeholders in spec files from external sources like environment variables, JSON/YAML files, HTTP APIs, HashiCorp Vault, AWS Secrets Manager, and Kubernetes ConfigMaps/Secrets.
- π Multiple Data Sources: Environment variables, files, HTTP APIs, Vault, AWS Secrets Manager, Kubernetes
- π― Flexible Syntax:
<name:source#key|default>format with fallback support - β‘ Smart Caching: Configurable TTL and automatic cache invalidation
- π Source Precedence: env > file > vault/aws/k8s > http > default
- π‘οΈ Security: Automatic secret masking in logs and error messages
- π§ Preprocessor Mode: CLI tool for spec transformation in CI pipelines
- π Comprehensive Logging: Detailed error reporting and debugging support
gauge install gauge-external-params# Clone the repository
git clone https://github.com/your-org/gauge-external-params.git
cd gauge-external-params
# Install dependencies
npm install
# Build and package
npm pack
# Install the plugin
gauge install gauge-external-params --file gauge-external-params-1.0.0.tgz- Create Configuration File
Create gauge-external-params.json in your project root:
{
"cacheTimeout": 60,
"sources": {
"env": { "enabled": true },
"file": { "enabled": true, "basePath": "." },
"http": { "enabled": true, "timeout": 3000 }
}
}- Use Placeholders in Specs
# Login Feature
## Admin Login
* Login with user <admin_user:env#ADMIN_USER|admin@example.com> and password <admin_pass:file#secrets.json#admin_password>- Set Environment Variables
export ADMIN_USER="admin@mycompany.com"- Create Secrets File
{
"admin_password": "secure_password_123"
}- Run Tests
gauge run specs/<name:source#key|default>
- name: Descriptive identifier for the placeholder
- source: Data source type (env, file, http, vault, aws, k8s)
- key: Source-specific key or path
- default: Optional fallback value
<user:env#USERNAME>
<token:env#API_TOKEN|default-token>
<url:env#SERVICE_URL><user:file#secrets.json#admin_user>
<host:file#config.yaml#database.host>
<config:file#app-settings.json#api.endpoints.users><token:http#https://auth-service.com/token>
<config:http#https://config-api.com/settings#database.url>
<data:http#POST:https://api.com/auth:{"user":"admin"}#access_token><secret:vault#secret/myapp:password>
<token:vault#secret/tokens:api_key>
<config:vault#secret/config><secret:aws#prod/myapp/db:password>
<token:aws#prod/api-keys:github_token>
<config:aws#prod/config@AWSPENDING:database_url><secret:k8s#secret:my-secret:password>
<config:k8s#configmap:app-config:database.url>
<token:k8s#secret:prod-namespace/api-tokens:github>{
"cacheTimeout": 60,
"sources": {
"env": {
"enabled": true,
"prefix": "APP_",
"transformCase": "upper"
},
"file": {
"enabled": true,
"basePath": "./config",
"allowedExtensions": [".json", ".yaml", ".yml"],
"cacheFiles": true,
"maxFileSize": 1048576
},
"http": {
"enabled": true,
"timeout": 3000,
"retries": 2,
"baseURL": "https://api.example.com",
"headers": {
"User-Agent": "gauge-external-params/1.0.0"
},
"auth": {
"token": "bearer-token-here"
},
"cacheResponses": true,
"cacheTimeout": 300000
},
"vault": {
"enabled": true,
"url": "https://vault.example.com",
"token": "vault-token-here",
"namespace": "myapp",
"mount": "secret",
"version": "v2",
"timeout": 5000,
"retries": 2,
"cacheTimeout": 300000
},
"aws": {
"enabled": true,
"region": "us-west-2",
"profile": "production",
"roleArn": "arn:aws:iam::123456789012:role/gauge-secrets-role",
"timeout": 5000,
"retries": 2,
"cacheTimeout": 300000
},
"k8s": {
"enabled": true,
"kubeconfig": "~/.kube/config",
"namespace": "production",
"context": "prod-cluster",
"timeout": 5000,
"retries": 2,
"cacheTimeout": 120000
}
},
"logging": {
"level": "info",
"maskSecrets": true
}
}prefix: Add prefix to all environment variable namestransformCase: Transform case (upper,lower,none)
basePath: Base directory for relative file pathsallowedExtensions: Allowed file extensions for securitycacheFiles: Enable file content cachingmaxFileSize: Maximum file size in bytes
baseURL: Base URL for relative requeststimeout: Request timeout in millisecondsretries: Number of retry attemptsheaders: Default headers for all requestsauth: Authentication configuration
url: Vault server URLtoken: Vault authentication tokennamespace: Vault namespace (Vault Enterprise)mount: KV secret engine mount pathversion: KV engine version (v1orv2)
region: AWS regionprofile: AWS CLI profile nameroleArn: IAM role to assumeaccessKeyId,secretAccessKey: Direct credentials
kubeconfig: Path to kubeconfig filenamespace: Default namespacecontext: Kubernetes context to use
The plugin automatically resolves placeholders during test execution:
gauge run specs/For CI/CD pipelines or when plugin mode isn't available:
# Process specs and output resolved versions
npx gauge-external-params preprocess --spec-dir specs/ --out-dir specs_resolved/
# Run tests with resolved specs
gauge run specs_resolved/# Start plugin server
npx gauge-external-params start
# Preprocess specs
npx gauge-external-params preprocess --spec-dir specs/ --out-dir resolved/
# Validate placeholders
npx gauge-external-params validate --spec-dir specs/
# Show usage statistics
npx gauge-external-params stats --spec-dir specs/name: Gauge Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Gauge
run: |
curl -SsL https://downloads.gauge.org/stable | sh
gauge install java
- name: Install dependencies
run: npm install
- name: Install Gauge External Params
run: gauge install gauge-external-params
- name: Set environment variables
env:
ADMIN_USER: ${{ secrets.ADMIN_USER }}
API_TOKEN: ${{ secrets.API_TOKEN }}
run: |
echo "ADMIN_USER=$ADMIN_USER" >> $GITHUB_ENV
echo "API_TOKEN=$API_TOKEN" >> $GITHUB_ENV
- name: Run tests
run: gauge run specs/pipeline {
agent any
environment {
ADMIN_USER = credentials('admin-user')
API_TOKEN = credentials('api-token')
}
stages {
stage('Setup') {
steps {
sh 'npm install'
sh 'gauge install gauge-external-params'
}
}
stage('Test') {
steps {
sh 'gauge run specs/'
}
}
}
post {
always {
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'reports/html-report',
reportFiles: 'index.html',
reportName: 'Gauge Test Report'
])
}
}
}stages:
- test
test:
stage: test
image: node:16
before_script:
- curl -SsL https://downloads.gauge.org/stable | sh
- gauge install java
- npm install
- gauge install gauge-external-params
script:
- gauge run specs/
variables:
ADMIN_USER: $ADMIN_USER
API_TOKEN: $API_TOKEN
artifacts:
reports:
junit: reports/xml-report/result.xml
paths:
- reports/# Use secure variable storage in CI/CD
export VAULT_TOKEN="hvs.secret_token_here"
export AWS_SECRET_ACCESS_KEY="secret_key_here"# Restrict access to sensitive files
chmod 600 secrets.json
chmod 600 ~/.kube/config# Use short-lived tokens
vault write -field=token auth/aws/login role=gauge-runner{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret"
],
"Resource": "arn:aws:secretsmanager:us-west-2:123456789012:secret:prod/myapp/*"
}
]
}apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: gauge-external-params
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: gauge-external-params
subjects:
- kind: ServiceAccount
name: gauge-runner
roleRef:
kind: Role
name: gauge-external-params
apiGroup: rbac.authorization.k8s.io# Check Gauge plugin directory
gauge --version
ls ~/.gauge/plugins/
# Reinstall plugin
gauge uninstall gauge-external-params
gauge install gauge-external-params# Verify config file location
ls -la gauge-external-params.json
# Use absolute path
export GAUGE_EXTERNAL_PARAMS_CONFIG=/absolute/path/to/config.json# Check environment variables
env | grep -E "(VAULT_|AWS_|KUBE)"
# Test source connectivity
npx gauge-external-params test-sources# Enable verbose logging
export GAUGE_EXTERNAL_PARAMS_VERBOSE=true
# Validate placeholders
npx gauge-external-params validate --spec-dir specs/Enable debug logging:
{
"logging": {
"level": "debug",
"maskSecrets": false
}
}- Plugin logs:
~/.gauge/logs/ - Application logs:
./logs/gauge-external-params.log
git clone https://github.com/your-org/gauge-external-params.git
cd gauge-external-params
npm install# Unit tests
npm test
# Integration tests
npm run test:integration
# Test with coverage
npm run test:coverage# Build the plugin
npm run build
# Create package
npm pack
# Install locally for testing
gauge install gauge-external-params --file gauge-external-params-1.0.0.tgzconst ParamResolver = require('gauge-external-params/src/resolver/ParamResolver');
const resolver = new ParamResolver('./config.json');
await resolver.initialize();
// Resolve text with placeholders
const resolved = await resolver.resolveText('Hello <user:env#USERNAME>!');
// Parse placeholder syntax
const parsed = ParamResolver.parsePlaceholder('<user:env#USERNAME|admin>');
await resolver.cleanup();All sources implement the same interface:
class SourceInterface {
async initialize() { /* Setup source */ }
async resolve(key) { /* Resolve value for key */ }
async cleanup() { /* Cleanup resources */ }
async refreshCache() { /* Clear cached data */ }
}- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Use ESLint configuration
- Follow conventional commit messages
- Add tests for new features
- Update documentation
MIT License - see LICENSE file for details.
- π Documentation
- π Issue Tracker
- π¬ Discussions
- π§ Email Support
- Initial release
- Support for 6 data sources
- Plugin and preprocessor modes
- Comprehensive configuration options
- Full test coverage