Class: Kubes::Compiler::Dsl::Syntax::Resource
- Inherits:
-
Core::Base
- Object
- Core::Base
- Kubes::Compiler::Dsl::Syntax::Resource
- Includes:
- Util::Normalize
- Defined in:
- lib/kubes/compiler/dsl/syntax/resource.rb
Direct Known Subclasses
BackendConfig, ConfigMap, DaemonSet, Deployment, Endpoint, Ingress, Job, ManagedCertificate, Namespace, NetworkPolicy, Pod, Role, RoleBinding, Secret, Service, ServiceAccount
Instance Attribute Summary collapse
-
#kind_from_block ⇒ Object
Returns the value of attribute kind_from_block.
Instance Method Summary collapse
- #default_apiVersion ⇒ Object
- #default_kind ⇒ Object (also: #resource_kind)
- #default_metadata ⇒ Object
-
#default_result ⇒ Object
top-level of resource is quite common.
-
#default_result_append ⇒ Object
can be overridden by subclasses.
- #default_top ⇒ Object
-
#field(name, data) ⇒ Object
For generic kind.
-
#top ⇒ Object
Where to set fields for generic kind.
Methods included from Util::Normalize
#extract_type, #normalize_kind
Instance Attribute Details
#kind_from_block ⇒ Object
Returns the value of attribute kind_from_block.
16 17 18 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 16 def kind_from_block @kind_from_block end |
Instance Method Details
#default_apiVersion ⇒ Object
45 46 47 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 45 def default_apiVersion "v1" end |
#default_kind ⇒ Object Also known as: resource_kind
58 59 60 61 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 58 def default_kind return @kind_from_block if @kind_from_block normalize_kind(@path) end |
#default_metadata ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 49 def { annotations: annotations, name: name, labels: labels, namespace: namespace, } end |
#default_result ⇒ Object
top-level of resource is quite common
19 20 21 22 23 24 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 19 def default_result data = top.merge(default_top) Kubes.deep_merge!(data, default_result_append) data.deep_stringify_keys! HashSqueezer.squeeze(data) end |
#default_result_append ⇒ Object
can be overridden by subclasses. IE: secret
41 42 43 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 41 def default_result_append {} end |
#default_top ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 31 def default_top { apiVersion: apiVersion, kind: kind, metadata: , spec: spec, } end |
#field(name, data) ⇒ Object
For generic kind
65 66 67 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 65 def field(name, data) Kubes.deep_merge!(top, {name => data}) end |
#top ⇒ Object
Where to set fields for generic kind
27 28 29 |
# File 'lib/kubes/compiler/dsl/syntax/resource.rb', line 27 def top @top ||= {} end |