class Kustomize::TargetSpec

Public Class Methods

create(target_spec) click to toggle source
# 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
new(api_group: nil, api_version: nil, kind: nil, name: nil, namespace: nil) click to toggle source
# 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

Public Instance Methods

get_name(rc) click to toggle source
# File lib/kustomize/target_spec.rb, line 24
def get_name(rc)
  rc.dig('metadata', 'name')
end
get_namespace(rc) click to toggle source
# File lib/kustomize/target_spec.rb, line 28
def get_namespace(rc)
  rc.dig('metadata', 'namespace') || 'default'
end
match?(rc) click to toggle source
# 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