Class: Kustomize::TargetSpec
- Inherits:
-
Object
- Object
- Kustomize::TargetSpec
- Defined in:
- lib/kustomize/target_spec.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_name(rc) ⇒ Object
- #get_namespace(rc) ⇒ Object
-
#initialize(api_group: nil, api_version: nil, kind: nil, name: nil, namespace: nil) ⇒ TargetSpec
constructor
A new instance of TargetSpec.
- #match?(rc) ⇒ Boolean
Constructor Details
#initialize(api_group: nil, api_version: nil, kind: nil, name: nil, namespace: nil) ⇒ TargetSpec
Returns a new instance of TargetSpec.
16 17 18 19 20 21 22 |
# File 'lib/kustomize/target_spec.rb', line 16 def initialize(api_group: nil, api_version: nil, kind: nil, name: nil, namespace: nil) @match_api_group = api_group @match_api_version = api_version @match_kind = kind @match_namespace = namespace @match_name = name end |
Class Method Details
.create(target_spec) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/kustomize/target_spec.rb', line 4 def self.create(target_spec) self.new( api_group: target_spec['group'], api_version: target_spec['version'], kind: target_spec['kind'], namespace: target_spec['namespace'], name: target_spec['name'] ) end |
Instance Method Details
#get_name(rc) ⇒ Object
24 25 26 |
# File 'lib/kustomize/target_spec.rb', line 24 def get_name(rc) rc.dig('metadata', 'name') end |
#get_namespace(rc) ⇒ Object
28 29 30 |
# File 'lib/kustomize/target_spec.rb', line 28 def get_namespace(rc) rc.dig('metadata', 'namespace') || 'default' end |
#match?(rc) ⇒ Boolean
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kustomize/target_spec.rb', line 32 def match?(rc) if @match_api_group or @match_api_version api_group, api_version = (rc['apiVersion'] || '/').split('/', 2) return false if @match_api_group and api_group != @match_api_group return false if @match_api_version and api_version != @match_api_version end return false if @match_kind and (rc['kind'] != @match_kind) return false if @match_name and get_name(rc) != @match_name return false if @match_namespace and get_namespace(rc) != @match_namespace true end |