Skip to content

yonahd/ysd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python version

Yaml Schema Definition

Overview:

Helps keep yaml file schemas aligned

Running the validator:
python yaml-validator/main.py -v yamls/example-values.yaml -r yamls/example-rules.yaml 

Example rule file:

required: // field must exist and type must match
  env: str
  enabled: bool
  replicas: int
  db:
    name: str
    test1:
      user: str
optional: // if field exists type must match
  disk: str
  metrics: bool 

Example yaml file (helm values file):

network:
  service:
    port: 8060
enabled: true
image:
  app: my-app:build
replicas: 1
env: dev
disk: local
db:
  name: "my_db"
  app:
    user:
      vault:
        enabled: "true"
  test1:
    user: "user2"
    password: "abc"
resources:
  requests:
    memory: "300M"
  limits:
    memory: "400M"

Example output:

---Checking required fields---
SUCCESS: Field env exists and is correct type
SUCCESS: Field enabled exists and is correct type
SUCCESS: Field replicas exists and is correct type
SUCCESS: Field db.name exists and is correct type
SUCCESS: Field db.test1.user exists and is correct type
---Checking optional fields---
SUCCESS: Field disk exists and is correct type
Field metrics does not exist -- optional

Enforcing yaml structure - fields cannot exist if it doesn't have a rule:

# add enforce flag -e
python yaml-validator/main.py -v yamls/example-values.yaml -r yamls/example-rules.yaml -e

Example output:

---Checking fields exist---
FAILED: Rule for field network doesn't exist
SUCCESS: Rule for field enabled exists
FAILED: Rule for field image doesn't exist
SUCCESS: Rule for field replicas exists
SUCCESS: Rule for field env exists
SUCCESS: Rule for field disk exists
SUCCESS: Rule for field db.name exists
FAILED: Rule for field db.app doesn't exist
SUCCESS: Rule for field db.test1.user exists
FAILED: Rule for field db.test1.password doesn't exist
FAILED: Rule for field resources doesn't exist

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages