Class: CF::App::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/cf-app-utils/cf/app/credentials.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Credentials

Returns a new instance of Credentials.



38
39
40
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 38

def initialize(env)
  @locator = Service.new(env)
end

Class Method Details

.credentialsObject



32
33
34
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 32

def credentials
  Credentials.new(ENV)
end

.find_all_by_all_service_tags(tags) ⇒ Object

Returns credentials for the service instances with all the given tags.



13
14
15
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 13

def find_all_by_all_service_tags(tags)
  credentials.find_all_by_all_service_tags(tags)
end

.find_all_by_service_label(label) ⇒ Object

Returns credentials for all service instances with the given label.



28
29
30
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 28

def find_all_by_service_label(label)
  credentials.find_all_by_service_label(label)
end

.find_all_by_service_tag(tag) ⇒ Object



8
9
10
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 8

def find_all_by_service_tag(tag)
  credentials.find_all_by_service_tag(tag)
end

.find_by_service_label(label) ⇒ Object

Returns credentials for the first service instance with the given label.



23
24
25
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 23

def find_by_service_label(label)
  credentials.find_by_service_label(label)
end

.find_by_service_name(name) ⇒ Object



4
5
6
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 4

def find_by_service_name(name)
  credentials.find_by_service_name(name)
end

.find_by_service_tag(tag) ⇒ Object

Returns credentials for the first service instance with the given tag.



18
19
20
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 18

def find_by_service_tag(tag)
  credentials.find_by_service_tag(tag)
end

Instance Method Details

#find_all_by_all_service_tags(tags) ⇒ Object

Returns credentials for the service instances with all the given tags.



62
63
64
65
66
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 62

def find_all_by_all_service_tags(tags)
  return [] if tags.empty?

  locator.find_all_by_tags(tags).map { |service| service['credentials'] }
end

#find_all_by_service_label(label) ⇒ Object

Returns credentials for all service instances with the given label.



75
76
77
78
79
80
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 75

def find_all_by_service_label(label)
  services = locator.find_all_by_label(label)
  services.map do |service|
    service['credentials']
  end
end

#find_all_by_service_tag(tag) ⇒ Object



54
55
56
57
58
59
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 54

def find_all_by_service_tag(tag)
  services = locator.find_all_by_tag(tag)
  services.map do |service|
    service['credentials']
  end
end

#find_by_service_label(label) ⇒ Object

Returns credentials for the first service instance with the given label.



69
70
71
72
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 69

def find_by_service_label(label)
  service = locator.find_by_label(label)
  service['credentials'] if service
end

#find_by_service_name(name) ⇒ Object

Returns credentials for the service instance with the given name.



43
44
45
46
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 43

def find_by_service_name(name)
  service = locator.find_by_name(name)
  service['credentials'] if service
end

#find_by_service_tag(tag) ⇒ Object

Returns credentials for the first service instance with the given tag.



49
50
51
52
# File 'lib/cf-app-utils/cf/app/credentials.rb', line 49

def find_by_service_tag(tag)
  service = locator.find_by_tag(tag)
  service['credentials'] if service
end