Skip to content

Commit

Permalink
Add safebox schema (#3049)
Browse files Browse the repository at this point in the history
* add safebox schema

* add safebox schema

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
adikari and pre-commit-ci[bot] authored Jul 7, 2023
1 parent 4611681 commit 3ee949c
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/api/json/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -4896,6 +4896,12 @@
],
"url": "https://json.schemastore.org/jfrog-pipelines.json"
},
{
"name": "Safebox Config Schema",
"description": "Schema for https://github.com/monebag/safebox",
"fileMatch": ["*safebox*.yaml"],
"url": "https://json.schemastore.org/safebox-schema-v1.0.0.json"
},
{
"name": "StrmPrivacy batch job configuration file",
"description": "StrmPrivacy batch job\nhttps://docs.strmprivacy.io/docs/latest/concepts/data-processing/batch-jobs/",
Expand Down
76 changes: 76 additions & 0 deletions src/schemas/json/safebox-schema-v1.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"description": "Configuration for safebox to deploy parameters to various parameter stores",
"properties": {
"service": {
"type": "string",
"description": "Name of the service. parameters will be prefixed by the value provided"
},
"provider": {
"type": "string",
"enum": ["ssm", "secrets-manager"],
"description": "Deploy parameters to the given provider. Eg. ssm, secrets-manager"
},
"prefix": {
"type": "string",
"description": "Prefix to apply to all parameters. Does not apply for shared",
"default": "/<stage>/<service>/"
},
"generate": {
"type": "array",
"description": "Generate different files based on the parameter name and values",
"items": {
"type": "object",
"required": ["type", "path"],
"properties": {
"type": {
"enum": ["json", "yaml", "dotenv", "types-node"],
"description": "Type of file to generate"
},
"path": {
"type": "string",
"description": "Full path with filename for writing the output"
}
}
}
},
"cloudformation-stacks": {
"type": "array",
"items": {
"type": "string"
},
"description": "Cloudformation stack names. Any output values from the stacks can be interpolated. Eg. DB_NAME: \"{{.myDbName}}\"\nmyDbName is the output of one of the cloudformation stacks"
},
"config": {
"type": "object",
"description": "Parameters to deploy as non secret. You can also specify stage specific key value pairs. Same key in the defaults will be ignored and stage specific value will be used.",
"properties": {
"defaults": {
"type": "object",
"description": "parameter name and value. Output is /<stage>/<service>/<param name>"
},
"shared": {
"type": "object",
"description": "Params that are to be shared between multiple services. The parameter name wont be prefixed by service name. Output is /<stage>/shared/<param name>"
}
}
},
"secret": {
"type": "object",
"description": "Parameters to deploy as secret. You cannot specify stage specific key value pairs. Value is the description. You will need to run safebox deploy in prompt mode to provide the actual value.",
"properties": {
"defaults": {
"type": "object",
"description": "parameter name and value. Output is /<stage>/<service>/<param name>"
},
"shared": {
"type": "object",
"description": "Params that are to be shared between multiple services. The parameter name wont be prefixed by service name. Output is /<stage>/shared/<param name>"
}
}
}
},
"required": ["service", "provider"],
"type": "object"
}
42 changes: 42 additions & 0 deletions src/test/safebox-schema-v1.0.0/safebox-full-valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
service: safebox
provider: ssm
prefix: '/test/'

generate:
- type: types-node
path: env.d.ts
- type: dotenv
path: .env

cloudformation-stacks:
- '{{.stage}}-shared-infra-SharedInfraServerless'
- '{{.stage}}-user-debug-stack'

config:
defaults:
DB_NAME: 'database name updated'
CF_OUTPUT_API_ENDPOINT: '{{.internalDomainName}}'
NEW: 'endpoint-{{.stage}}'
NEW2: 'endpoint updated'
NEW3: 'endpoint updated'
AWS_REGION: '{{.region}}'
AWS_ACCOUNT: '{{.account}}'
CF_OUTPUT_BUCKET_ARN: '{{.BucketArn}}'
CF_OUTPUT_ENDPOINT: '{{.Endpoint}}'

prod:
DB_NAME: 'production db name'

dev:
DB_NAME: 'dev db name'

shared:
SHARED_KEY: 'shared key'

secret:
defaults:
API_KEY: 'key of the api endpoint'
DB_SECRET: 'database secret'

shared:
APOLLO_KEY: 'apollo key'
19 changes: 19 additions & 0 deletions src/test/safebox-schema-v1.0.0/safebox-short-valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
service: safebox
provider: ssm

config:
defaults:
DB_NAME: 'database name updated'
CF_OUTPUT_API_ENDPOINT: '{{.internalDomainName}}'
NEW: 'endpoint-{{.stage}}'

shared:
SHARED_KEY: 'shared key'

secret:
defaults:
API_KEY: 'key of the api endpoint'
DB_SECRET: 'database secret'

shared:
APOLLO_KEY: 'apollo key'

0 comments on commit 3ee949c

Please sign in to comment.