Created
June 3, 2022 09:43
-
-
Save Duologic/e8c425ace2e33cf9e8344100deab3ee0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "v1alpha1", | |
"schema": { | |
"openAPIV3Schema": { | |
"properties": { | |
"apiVersion": { | |
"default": "tanka.dev/v1alpha1", | |
"type": "string" | |
}, | |
"data": { | |
"type": "object" | |
}, | |
"kind": { | |
"default": "Environment", | |
"type": "string" | |
}, | |
"metadata": { | |
"properties": { | |
"labels": { | |
"additionalProperties": { | |
"type": "string" | |
}, | |
"type": "object" | |
}, | |
"name": { | |
"type": "string" | |
}, | |
"namespace": { | |
"type": "string" | |
} | |
}, | |
"required": [], | |
"type": "object" | |
}, | |
"spec": { | |
"properties": { | |
"apiServer": { | |
"type": "string" | |
}, | |
"applyStrategy": { | |
"type": "string" | |
}, | |
"contextNames": { | |
"additionalProperties": { | |
"type": "string" | |
}, | |
"type": "array" | |
}, | |
"diffStrategy": { | |
"type": "string" | |
}, | |
"expectVersions": { | |
"properties": { | |
"tanka": { | |
"type": "string" | |
} | |
}, | |
"required": [], | |
"type": "object" | |
}, | |
"injectLabels": { | |
"type": "bool" | |
}, | |
"namespace": { | |
"default": "default", | |
"type": "string" | |
}, | |
"resourceDefaults": { | |
"properties": { | |
"annotations": { | |
"additionalProperties": { | |
"type": "string" | |
}, | |
"type": "object" | |
}, | |
"labels": { | |
"additionalProperties": { | |
"type": "string" | |
}, | |
"type": "object" | |
} | |
}, | |
"required": [], | |
"type": "object" | |
} | |
}, | |
"required": [ | |
"namespace" | |
], | |
"type": "object" | |
} | |
}, | |
"required": [ | |
"apiVersion", | |
"kind", | |
"metadata", | |
"spec" | |
], | |
"type": "object" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local version = { | |
new(version): { | |
name: version, | |
schema: { | |
openAPIV3Schema: { | |
type: 'object', | |
properties: {}, | |
}, | |
}, | |
}, | |
withPropertiesMixin(properties): { | |
schema+: { | |
openAPIV3Schema+: { | |
properties+: properties, | |
}, | |
}, | |
}, | |
addProperty(property, required=false): { | |
schema+: { | |
openAPIV3Schema+: { | |
properties+: { | |
[property.name]: property, | |
}, | |
required+: | |
if required | |
then [property.name] | |
else [], | |
}, | |
}, | |
}, | |
}; | |
local property = { | |
new(name, type='string', default='', description=''): { | |
name:: name, | |
type: type, | |
[if default != '' then 'default']: default, | |
[if description != '' then 'description']: description, | |
}, | |
newArrayString(name, type='array', default='', description=''): | |
self.new(name, type, default, description) | |
+ self.additionalProperties('string'), | |
newObjectString(name, type='object', default='', description=''): | |
self.new(name, type, default, description) | |
+ self.additionalProperties('string'), | |
additionalProperties(type): { | |
additionalProperties+: { type: type }, | |
}, | |
addProperty(property, required=false): { | |
properties+: { | |
[property.name]: property, | |
}, | |
required+: | |
if required | |
then [property.name] | |
else [], | |
}, | |
}; | |
local metadata = | |
property.new( | |
'metadata', | |
'object', | |
) | |
+ property.addProperty( | |
property.new('name') | |
) | |
+ property.addProperty( | |
property.new('namespace') | |
) | |
+ property.addProperty( | |
property.newObjectString('labels') | |
) | |
; | |
local spec = | |
property.new( | |
'spec', | |
'object', | |
) | |
+ property.addProperty(property.new('apiServer')) | |
+ property.addProperty( | |
property.newArrayString('contextNames') | |
) | |
+ property.addProperty( | |
property.new('namespace', default='default'), | |
required=true, | |
) | |
+ property.addProperty(property.new('diffStrategy')) | |
+ property.addProperty(property.new('applyStrategy')) | |
+ property.addProperty(property.new('injectLabels', 'bool')) | |
+ property.addProperty( | |
property.new('resourceDefaults', 'object') | |
+ property.addProperty( | |
property.newObjectString('annotations') | |
) | |
+ property.addProperty( | |
property.newObjectString('labels') | |
) | |
) | |
+ property.addProperty( | |
property.new('expectVersions', 'object') | |
+ property.addProperty( | |
property.new('tanka') | |
) | |
) | |
; | |
version.new('v1alpha1') | |
+ version.addProperty( | |
property.new( | |
'apiVersion', | |
default='tanka.dev/v1alpha1', | |
), | |
required=true, | |
) | |
+ version.addProperty( | |
property.new( | |
'kind', | |
default='Environment', | |
), | |
required=true, | |
) | |
+ version.addProperty( | |
metadata, | |
required=true, | |
) | |
+ version.addProperty( | |
spec, | |
required=true, | |
) | |
+ version.addProperty( | |
property.new('data', 'object'), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment