Skip to content

Commit

Permalink
Add schema for Yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Motok1 committed Jun 9, 2024
1 parent d2fed5e commit 8d9ab50
Show file tree
Hide file tree
Showing 4 changed files with 276 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"yaml.format.enable": true,
"yaml.completion": true,
"yaml.validate": true,
"yaml.hover": true,
"yaml.schemas": {
"./docs/schemas/polad_config.json": [
"polad*.yaml",
"polad*.yml"
],
"./cmd/pola/docs/schemas/policy.json": [
"*POLICY*.yaml",
"*POLICY*.yml",
"*policy*.yaml",
"*policy*.yml"
],
},
}
68 changes: 68 additions & 0 deletions cmd/pola/docs/schemas/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"srPolicy": {
"type": "object",
"properties": {
"pcepSessionAddr": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"srcAddr": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"dstAddr": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"name": {
"type": "string"
},
"color": {
"type": "integer"
},
"segmentList": {
"type": "array",
"items": {
"$ref": "segment.json"
}
}
},
"required": [
"pcepSessionAddr",
"srcAddr",
"dstAddr",
"name",
"color",
"segmentList"
]
}
},
"required": [
"srPolicy"
],
"additionalProperties": false
}
56 changes: 56 additions & 0 deletions cmd/pola/docs/schemas/segment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"type": "object",
"properties": {
"sid": {
"oneOf": [
{
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
],
"$comment": "SRv6 format"
},
{
"type": "integer",
"$comment": "SR-MPLS format"
}
]
},
"localAddr": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"remoteAddr": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"sidStructure": {
"type": "string",
"pattern": "^[0-9]+,[0-9]+,[0-9]+,[0-9]+$",
"$comment": "<locator-block>,<locator-node>,<function>,<argument>"
}
},
"required": [
"sid"
],
"additionalProperties": false
}
134 changes: 134 additions & 0 deletions docs/schemas/polad_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"global": {
"type": "object",
"properties": {
"pcep": {
"type": "object",
"properties": {
"address": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"port": {
"type": "integer"
}
},
"required": [
"address",
"port"
]
},
"grpc-server": {
"type": "object",
"properties": {
"address": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"port": {
"type": "integer"
}
},
"required": [
"address",
"port"
]
},
"log": {
"type": "object",
"properties": {
"path": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"path",
"name"
]
},
"ted": {
"type": "object",
"properties": {
"enable": {
"type": "boolean"
},
"source": {
"type": "string",
"enum": [
"gobgp"
]
}
},
"required": [
"enable"
]
},
"gobgp": {
"type": "object",
"properties": {
"grpc-client": {
"type": "object",
"properties": {
"address": {
"type": "string",
"oneOf": [
{
"format": "ipv4"
},
{
"format": "ipv6"
}
]
},
"port": {
"type": "integer"
}
},
"required": [
"address",
"port"
]
}
},
"required": [
"grpc-client"
]
},
"usid-mode": {
"type": "boolean",
"default": false
}
},
"required": [
"pcep",
"grpc-server",
"log",
"ted"
]
}
},
"required": [
"global"
],
"additionalProperties": false
}

0 comments on commit 8d9ab50

Please sign in to comment.