Class: Kube::Cluster::Standard::CustomResourceDefinition
- Inherits:
-
Object
- Object
- Kube::Cluster::Standard::CustomResourceDefinition
- Defined in:
- lib/kube/cluster/standard/custom_resource_definition.rb
Instance Method Summary collapse
-
#initialize(kind:, group:, version: 'v1', scope: 'Namespaced', short_names: [], categories: [], schema: nil, &block) ⇒ CustomResourceDefinition
constructor
A new instance of CustomResourceDefinition.
Constructor Details
#initialize(kind:, group:, version: 'v1', scope: 'Namespaced', short_names: [], categories: [], schema: nil, &block) ⇒ CustomResourceDefinition
Returns a new instance of CustomResourceDefinition.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/kube/cluster/standard/custom_resource_definition.rb', line 10 def initialize( kind:, group:, version: 'v1', scope: 'Namespaced', short_names: [], categories: [], schema: nil, &block ) plural = kind.downcase.pluralize singular = kind.downcase schema ||= { type: 'object', 'x-kubernetes-preserve-unknown-fields': true } super() { .name = "#{plural}.#{group}" spec.group = group spec.names.kind = kind spec.names.listKind = "#{kind}List" spec.names.plural = plural spec.names.singular = singular spec.names.shortNames = short_names unless short_names.empty? spec.names.categories = categories unless categories.empty? spec.scope = scope spec.versions = [{ name: version, served: true, storage: true, subresources: { status: {} }, schema: { openAPIV3Schema: schema } }] instance_exec(&block) if block } api_version = "#{group}/#{version}" Kube::Schema.register( kind, schema: { 'type' => 'object', 'properties' => { 'apiVersion' => { 'type' => 'string' }, 'kind' => { 'type' => 'string' }, 'metadata' => { 'type' => 'object' }, 'spec' => { 'type' => 'object', 'x-kubernetes-preserve-unknown-fields' => true }, 'status' => { 'type' => 'object', 'x-kubernetes-preserve-unknown-fields' => true } }, 'x-kubernetes-preserve-unknown-fields' => true }, api_version: api_version ) end |