Class: SecretConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/apollo_commons_ruby/SecretConfig.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ SecretConfig

Returns a new instance of SecretConfig.


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/apollo_commons_ruby/SecretConfig.rb', line 9

def initialize(environment)
  if file_exists?("./.apollo/#{environment}.json")
    conf_file = File.read(File.expand_path("./.apollo/#{environment}.json"))
    conf = JSON.parse conf_file
    
    if (conf["tenantAuthToken"] == nil)
      puts "Auth configurations are missing"
      return nil
    end
    @authToken = conf["tenantAuthToken"]

  elsif (File.exist? ("/var/jenkins_home/template_config/config.json"))
    conf_file = File.read(File.expand_path("/var/jenkins_home/template_config/config.json"));
    conf = JSON.parse conf_file
    conf = conf[environment.downcase]
    if (conf["authToken"] == nil || conf["heraAuthToken"] == nil)
      puts "Security configurations are missing"
      return nil
    end
    @authToken = conf["authToken"]
    @userId = conf["userId"]
    @domainId = conf["domainId"]
    @heraAuthToken = conf["heraAuthToken"]
    @templateDirectory = conf["templateDirectory"]
  end
end

Instance Attribute Details

#authTokenObject (readonly)

Returns the value of attribute authToken.


3
4
5
# File 'lib/apollo_commons_ruby/SecretConfig.rb', line 3

def authToken
  @authToken
end

#domainIdObject (readonly)

Returns the value of attribute domainId.


5
6
7
# File 'lib/apollo_commons_ruby/SecretConfig.rb', line 5

def domainId
  @domainId
end

#heraAuthTokenObject (readonly)

Returns the value of attribute heraAuthToken.


6
7
8
# File 'lib/apollo_commons_ruby/SecretConfig.rb', line 6

def heraAuthToken
  @heraAuthToken
end

#templateDirectoryObject (readonly)

Returns the value of attribute templateDirectory.


7
8
9
# File 'lib/apollo_commons_ruby/SecretConfig.rb', line 7

def templateDirectory
  @templateDirectory
end

#userIdObject (readonly)

Returns the value of attribute userId.


4
5
6
# File 'lib/apollo_commons_ruby/SecretConfig.rb', line 4

def userId
  @userId
end