Skip to content

Instantly share code, notes, and snippets.

@ankitrgadiya
Last active May 9, 2022 03:41
Show Gist options
  • Save ankitrgadiya/8e263da287add23c6f75584b0c269ade to your computer and use it in GitHub Desktop.
Save ankitrgadiya/8e263da287add23c6f75584b0c269ade to your computer and use it in GitHub Desktop.
Secret JSON Schema
apiVersion: "apiextensions.rapyuta.io/v1"
kind: "Secret"
metadata:
name: "docker-secret"
spec:
type: Docker
username: ankit
password: password
registry: index.docker.io
email: example@example.com
---
apiVersion: "apiextensions.rapyuta.io/v1"
kind: "Secret"
metadata:
name: "git-basic-secret"
spec:
type: Git
username: ankit
password: password
# caCert: # Optional
---
apiVersion: "apiextensions.rapyuta.io/v1"
kind: "Secret"
metadata:
name: "git-token-secret"
spec:
type: Git
token: token
# caCert: # Optional
---
apiVersion: "apiextensions.rapyuta.io/v1"
kind: "Secret"
metadata:
name: "git-ssh-secret"
spec:
type: Git
privateKey: ssh-private-key
{
"$schema": "https://json-schema.org/draft-07/schema",
"title": "Secret",
"$ref": "#/definitions/secret",
"definitions": {
"secret": {
"type": "object",
"properties": {
"apiVersion": {
"const": "apiextensions.rapyuta.io/v1"
},
"kind": {
"const": "Secret"
},
"metadata": {
"$ref": "#/definitions/metadata"
},
"spec": {
"$ref": "#/definitions/secretSpec"
}
},
"required": ["apiVersion", "kind", "metadata", "spec"]
},
"secretSpec": {
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/secretType"
},
"gitAuthMethod": {
"$ref": "#/definitions/gitAuthMethod"
}
},
"required": ["type"],
"allOf": [
{
"if": {
"properties": {
"type": { "const": "Docker" }
}
},
"then": {
"properties": {
"registry": {
"type": "string"
},
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": ["registry", "username", "password", "email"]
}
},
{
"if": {
"properties": {
"type": { "const": "Git" },
"gitAuthMethod": { "const": "Basic" }
}
},
"then": {
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"caCert": {
"type": "string"
}
},
"required": ["username", "password"]
}
},
{
"if": {
"properties": {
"type": { "const": "Git" },
"gitAuthMethod": { "const": "Token" }
}
},
"then": {
"properties": {
"token": {
"type": "string"
},
"caCert": {
"type": "string"
}
},
"required": ["token"]
}
},
{
"if": {
"properties": {
"type": { "const": "Git" },
"gitAuthMethod": { "const": "SSH" }
}
},
"then": {
"properties": {
"privateKey": {
"type": "string"
}
},
"required": ["privateKey"]
}
}
]
},
"gitAuthMethod": {
"enum": ["Basic", "Token", "SSH"]
},
"secretType": {
"enum": ["Docker", "Git"]
},
"metadata": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"guid": {
"$ref": "#/definitions/secretGUID"
},
"creator": {
"$ref": "#/definitions/uuid"
},
"project": {
"$ref": "#/definitions/projectGUID"
},
"labels": {
"$ref": "#/definitions/stringMap",
"uniqueItems": true
}
},
"required": ["name"]
},
"projectGUID": {
"type": "string",
"pattern": "^project-[a-z]{24}$"
},
"secretGUID": {
"type": "string",
"pattern": "^secret-[a-z]{24}$"
},
"stringMap": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"uuid": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment