Class: Krane::MutatingWebhookConfiguration::Webhook
- Inherits:
-
Object
- Object
- Krane::MutatingWebhookConfiguration::Webhook
- Defined in:
- lib/krane/kubernetes_resource/mutating_webhook_configuration.rb
Defined Under Namespace
Classes: Rule
Constant Summary collapse
- EQUIVALENT =
'Equivalent'
- EXACT =
'Exact'
Instance Method Summary collapse
- #has_side_effects? ⇒ Boolean
-
#initialize(definition) ⇒ Webhook
constructor
A new instance of Webhook.
- #match_policy ⇒ Object
- #matches_resource?(resource, skip_rule_if_side_effect_none: true) ⇒ Boolean
- #rules ⇒ Object
- #side_effects ⇒ Object
Constructor Details
#initialize(definition) ⇒ Webhook
Returns a new instance of Webhook.
42 43 44 |
# File 'lib/krane/kubernetes_resource/mutating_webhook_configuration.rb', line 42 def initialize(definition) @definition = definition end |
Instance Method Details
#has_side_effects? ⇒ Boolean
50 51 52 |
# File 'lib/krane/kubernetes_resource/mutating_webhook_configuration.rb', line 50 def has_side_effects? !%w(None NoneOnDryRun).include?(side_effects) end |
#match_policy ⇒ Object
54 55 56 |
# File 'lib/krane/kubernetes_resource/mutating_webhook_configuration.rb', line 54 def match_policy @definition.dig('matchPolicy') end |
#matches_resource?(resource, skip_rule_if_side_effect_none: true) ⇒ Boolean
58 59 60 61 62 63 |
# File 'lib/krane/kubernetes_resource/mutating_webhook_configuration.rb', line 58 def matches_resource?(resource, skip_rule_if_side_effect_none: true) return false if skip_rule_if_side_effect_none && !has_side_effects? rules.any? do |rule| rule.matches_resource?(resource, accept_equivalent: match_policy == EQUIVALENT) end end |
#rules ⇒ Object
65 66 67 |
# File 'lib/krane/kubernetes_resource/mutating_webhook_configuration.rb', line 65 def rules @definition.fetch('rules', []).map { |rule| Rule.new(rule) } end |
#side_effects ⇒ Object
46 47 48 |
# File 'lib/krane/kubernetes_resource/mutating_webhook_configuration.rb', line 46 def side_effects @definition.dig('sideEffects') end |