Class: Nvoi::Configuration::Override

Inherits:
Object
  • Object
show all
Defined in:
lib/nvoi/configuration/override.rb

Overview

Override allows CLI to override app name and subdomain for branch deployments

Constant Summary collapse

BRANCH_PATTERN =
/\A[a-z0-9-]+\z/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch:) ⇒ Override

Returns a new instance of Override.



11
12
13
14
# File 'lib/nvoi/configuration/override.rb', line 11

def initialize(branch:)
  validate!(branch)
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



9
10
11
# File 'lib/nvoi/configuration/override.rb', line 9

def branch
  @branch
end

Instance Method Details

#apply(config) ⇒ Object

Apply overrides to config



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nvoi/configuration/override.rb', line 17

def apply(config)
  # Prefix branch to application name
  config.deploy.application.name = "#{config.deploy.application.name}-#{@branch}"

  # Prefix branch to all service subdomains
  config.deploy.application.app.each_value do |svc|
    svc.subdomain = "#{@branch}-#{svc.subdomain}"
  end

  # Regenerate resource names with new app name
  regenerate_resource_names(config)

  config
end