Class: Deployment

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

Constant Summary collapse

@@paas_domain =
'mtnsatcloud.com'

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.



455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/conan/manifest_builder.rb', line 455

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)
end

Instance Attribute Details

#additional_mappingsObject

Returns the value of attribute additional_mappings.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def additional_mappings
  @additional_mappings
end

#app_idsObject

Returns the value of attribute app_ids.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def app_ids
  @app_ids
end

#environmentObject

Returns the value of attribute environment.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def environment
  @environment
end

#facility_idObject

Returns the value of attribute facility_id.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def facility_id
  @facility_id
end

#orgObject

Returns the value of attribute org.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def org
  @org
end

#shipObject

Returns the value of attribute ship.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def ship
  @ship
end

#shipcloudObject

Returns the value of attribute shipcloud.



453
454
455
# File 'lib/conan/manifest_builder.rb', line 453

def shipcloud
  @shipcloud
end

Instance Method Details

#active_healthcheck_url(app) ⇒ Object



520
521
522
# File 'lib/conan/manifest_builder.rb', line 520

def active_healthcheck_url(app)
  "http://#{dns_name(app)}/status/healthcheck"
end

#active_urls(app) ⇒ Object



508
509
510
# File 'lib/conan/manifest_builder.rb', line 508

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

#agnostic_dns_name(app) ⇒ Object



504
505
506
# File 'lib/conan/manifest_builder.rb', line 504

def agnostic_dns_name(app)
  "#{@environment.id}.#{app.url_segment}.#{@@paas_domain}"
end

#apps(*app_ids) ⇒ Object



470
471
472
# File 'lib/conan/manifest_builder.rb', line 470

def apps(*app_ids)
  @app_ids = app_ids
end

#dns_name(app) ⇒ Object



500
501
502
# File 'lib/conan/manifest_builder.rb', line 500

def dns_name(app)
  "#{@environment.id}.#{app.url_segment}.#{@ship}.#{@org}.#{@@paas_domain}"
end

#enabled(b) ⇒ Object



484
485
486
# File 'lib/conan/manifest_builder.rb', line 484

def enabled(b)
  @enabled = b
end

#enabled?Boolean

Returns:

  • (Boolean)


488
489
490
# File 'lib/conan/manifest_builder.rb', line 488

def enabled?
  @enabled
end

#facility(facility_id) ⇒ Object



474
475
476
# File 'lib/conan/manifest_builder.rb', line 474

def facility(facility_id)
  @facility_id = facility_id
end

#hostnames(*hostnames) ⇒ Object



478
479
480
481
482
# File 'lib/conan/manifest_builder.rb', line 478

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

#inactive_healthcheck_url(app) ⇒ Object



524
525
526
# File 'lib/conan/manifest_builder.rb', line 524

def inactive_healthcheck_url(app)
  "http://inactive.#{dns_name(app)}/status/healthcheck"
end

#inactive_urls(app) ⇒ Object



512
513
514
# File 'lib/conan/manifest_builder.rb', line 512

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

#manifest_url(app) ⇒ Object



516
517
518
# File 'lib/conan/manifest_builder.rb', line 516

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

#name(app) ⇒ Object



492
493
494
# File 'lib/conan/manifest_builder.rb', line 492

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

#paas_targetObject



528
529
530
# File 'lib/conan/manifest_builder.rb', line 528

def paas_target
  "https://api.paas.#{@ship}.#{@org}.#{@@paas_domain}"
end

#to_sObject



532
533
534
# File 'lib/conan/manifest_builder.rb', line 532

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

#unique_name(app) ⇒ Object



496
497
498
# File 'lib/conan/manifest_builder.rb', line 496

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