Class: Gitlab::Serverless::Service

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

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(attributes) ⇒ Service

Returns a new instance of Service.


6
7
8
# File 'lib/gitlab/serverless/service.rb', line 6

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#clusterObject


51
52
53
# File 'lib/gitlab/serverless/service.rb', line 51

def cluster
  @attributes.dig('cluster')
end

#created_atObject


30
31
32
33
34
35
# File 'lib/gitlab/serverless/service.rb', line 30

def created_at
  strong_memoize(:created_at) do
    timestamp = @attributes.dig('metadata', 'creationTimestamp')
    DateTime.parse(timestamp) if timestamp
  end
end

#descriptionObject


47
48
49
# File 'lib/gitlab/serverless/service.rb', line 47

def description
  knative_07_description || knative_05_06_description
end

#environmentObject


22
23
24
# File 'lib/gitlab/serverless/service.rb', line 22

def environment
  @attributes.dig('environment')
end

#environment_scopeObject


18
19
20
# File 'lib/gitlab/serverless/service.rb', line 18

def environment_scope
  @attributes.dig('environment_scope')
end

#imageObject


37
38
39
40
41
42
43
44
45
# File 'lib/gitlab/serverless/service.rb', line 37

def image
  @attributes.dig(
    'spec',
    'runLatest',
    'configuration',
    'build',
    'template',
    'name')
end

#nameObject


10
11
12
# File 'lib/gitlab/serverless/service.rb', line 10

def name
  @attributes.dig('metadata', 'name')
end

#namespaceObject


14
15
16
# File 'lib/gitlab/serverless/service.rb', line 14

def namespace
  @attributes.dig('metadata', 'namespace')
end

#podcountObject


26
27
28
# File 'lib/gitlab/serverless/service.rb', line 26

def podcount
  @attributes.dig('podcount')
end

#urlObject


55
56
57
# File 'lib/gitlab/serverless/service.rb', line 55

def url
  proxy_url || knative_06_07_url || knative_05_url
end