Class: Gitlab::Kubernetes::Ingress

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/kubernetes/ingress.rb

Constant Summary collapse

ANNOTATION_KEY_CANARY =
'nginx.ingress.kubernetes.io/canary'
ANNOTATION_KEY_CANARY_WEIGHT =
'nginx.ingress.kubernetes.io/canary-weight'

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(attributes = {}) ⇒ Ingress

Returns a new instance of Ingress.


12
13
14
# File 'lib/gitlab/kubernetes/ingress.rb', line 12

def initialize(attributes = {})
  @attributes = attributes
end

Instance Method Details

#canary?Boolean

Returns:

  • (Boolean)

16
17
18
19
20
21
22
# File 'lib/gitlab/kubernetes/ingress.rb', line 16

def canary?
  strong_memoize(:is_canary) do
    annotations.any? do |key, value|
      key == ANNOTATION_KEY_CANARY && value == 'true'
    end
  end
end

#canary_weightObject


24
25
26
27
28
29
# File 'lib/gitlab/kubernetes/ingress.rb', line 24

def canary_weight
  return unless canary?
  return unless annotations.key?(ANNOTATION_KEY_CANARY_WEIGHT)

  annotations[ANNOTATION_KEY_CANARY_WEIGHT].to_i
end

#nameObject


31
32
33
# File 'lib/gitlab/kubernetes/ingress.rb', line 31

def name
  ['name']
end