Class: Deployment

Inherits:
HasOptions show all
Defined in:
lib/conan/deployment.rb

Instance Attribute Summary collapse

Attributes inherited from HasOptions

#options

Instance Method Summary collapse

Methods inherited from HasOptions

#option

Constructor Details

#initialize(environment, org, ship) ⇒ Deployment

Returns a new instance of Deployment.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/conan/deployment.rb', line 6

def initialize(environment, org, ship)
  # inherit options from the environment
  #super(environment.options)  # TODO:  copy?!
  super({})
  @environment = environment
  @org = org
  @ship = ship
  @shipcloud = "#{org}-#{ship}"
  @app_ids = []
  @additional_mappings = []
  @facility_id = nil
  @enabled = true
  @randomid = SecureRandom.hex(3)
  @custom_smoke_test_path = nil
end

Instance Attribute Details

#additional_mappingsObject

Returns the value of attribute additional_mappings.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def additional_mappings
  @additional_mappings
end

#app_idsObject

Returns the value of attribute app_ids.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def app_ids
  @app_ids
end

#custom_smoke_test_pathObject

Returns the value of attribute custom_smoke_test_path.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def custom_smoke_test_path
  @custom_smoke_test_path
end

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def environment
  @environment
end

#facility_idObject

Returns the value of attribute facility_id.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def facility_id
  @facility_id
end

#orgObject

Returns the value of attribute org.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def org
  @org
end

#shipObject

Returns the value of attribute ship.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def ship
  @ship
end

#shipcloudObject

Returns the value of attribute shipcloud.



4
5
6
# File 'lib/conan/deployment.rb', line 4

def shipcloud
  @shipcloud
end

Instance Method Details

#active_smoke_test_url(app) ⇒ Object



80
81
82
# File 'lib/conan/deployment.rb', line 80

def active_smoke_test_url(app)
  "http://#{dns_name(app)}/#{@custom_smoke_test_path || 'status/healthcheck'}"
end

#active_urls(app) ⇒ Object



68
69
70
# File 'lib/conan/deployment.rb', line 68

def active_urls(app)
  [ dns_name(app), agnostic_dns_name(app) ] + @additional_mappings
end

#agnostic_dns_name(app) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/conan/deployment.rb', line 60

def agnostic_dns_name(app)
  if @ship == "central"
    "#{@environment.id}-#{app.url_segment}.mtnsat.io"
  else
    "#{app.url_segment}.mtnsat.io"
  end
end

#apps(*app_ids) ⇒ Object



22
23
24
# File 'lib/conan/deployment.rb', line 22

def apps(*app_ids)
  @app_ids = app_ids
end

#dns_name(app) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/conan/deployment.rb', line 52

def dns_name(app)
  if @ship == "central"
    "#{@environment.id}-#{app.url_segment}.paasv2.#{@ship}.#{@org}.mtnsatcloud.com"
  else
    "#{app.url_segment}.#{@ship}.#{@org}.mtnsatcloud.com"
  end
end

#enabled(b) ⇒ Object



36
37
38
# File 'lib/conan/deployment.rb', line 36

def enabled(b)
  @enabled = b
end

#enabled?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/conan/deployment.rb', line 40

def enabled?
  @enabled
end

#facility(facility_id) ⇒ Object



26
27
28
# File 'lib/conan/deployment.rb', line 26

def facility(facility_id)
  @facility_id = facility_id
end

#hostnames(*hostnames) ⇒ Object



30
31
32
33
34
# File 'lib/conan/deployment.rb', line 30

def hostnames(*hostnames)
  hostnames.each do |hostname|
    @additional_mappings.push(hostname) unless hostname.empty?
  end
end

#inactive_smoke_test_url(app) ⇒ Object



84
85
86
# File 'lib/conan/deployment.rb', line 84

def inactive_smoke_test_url(app)
  "http://x.#{dns_name(app)}/#{@custom_smoke_test_path || 'status/healthcheck'}"
end

#inactive_urls(app) ⇒ Object



72
73
74
# File 'lib/conan/deployment.rb', line 72

def inactive_urls(app)
  active_urls(app).map{ |url| "x-#{url}" }
end

#manifest_url(app) ⇒ Object



76
77
78
# File 'lib/conan/deployment.rb', line 76

def manifest_url(app)
  "http://#{dns_name(app)}/status/manifest"
end

#name(app) ⇒ Object



44
45
46
# File 'lib/conan/deployment.rb', line 44

def name(app)
  "#{app.id}-#{@environment.id}-#{@ship}"
end

#paas_targetObject



88
89
90
# File 'lib/conan/deployment.rb', line 88

def paas_target
  "https://api.paasv2.#{@ship}.#{@org}.mtnsatcloud.com"
end

#smoke_test_path(path = nil) ⇒ Object



96
97
98
# File 'lib/conan/deployment.rb', line 96

def smoke_test_path(path=nil)
  @custom_smoke_test_path = path
end

#to_sObject



92
93
94
# File 'lib/conan/deployment.rb', line 92

def to_s
  "#{org}-#{ship}"
end

#unique_name(app) ⇒ Object



48
49
50
# File 'lib/conan/deployment.rb', line 48

def unique_name(app)
  "#{name(app)}-#{@randomid}"
end