Class: Nvoi::Configuration::Root

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

Overview

Root holds the complete configuration including deployment config and runtime settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deploy_config) ⇒ Root

Returns a new instance of Root.



10
11
12
13
# File 'lib/nvoi/configuration/root.rb', line 10

def initialize(deploy_config)
  @deploy = deploy_config
  @namer = nil
end

Instance Attribute Details

#container_prefixObject

Returns the value of attribute container_prefix.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def container_prefix
  @container_prefix
end

#deployObject

Returns the value of attribute deploy.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def deploy
  @deploy
end

#docker_network_nameObject

Returns the value of attribute docker_network_name.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def docker_network_name
  @docker_network_name
end

#firewall_nameObject

Returns the value of attribute firewall_name.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def firewall_name
  @firewall_name
end

#namerObject

Returns the value of attribute namer.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def namer
  @namer
end

#network_nameObject

Returns the value of attribute network_name.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def network_name
  @network_name
end

#server_nameObject

Returns the value of attribute server_name.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def server_name
  @server_name
end

#ssh_key_pathObject

Returns the value of attribute ssh_key_path.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def ssh_key_path
  @ssh_key_path
end

#ssh_public_keyObject

Returns the value of attribute ssh_public_key.



7
8
9
# File 'lib/nvoi/configuration/root.rb', line 7

def ssh_public_key
  @ssh_public_key
end

Instance Method Details

#architectureObject



56
57
58
59
60
61
62
# File 'lib/nvoi/configuration/root.rb', line 56

def architecture
  case provider_name
  when "hetzner" then hetzner&.architecture
  when "aws" then aws&.architecture
  when "scaleway" then scaleway&.architecture
  end
end

#awsObject



44
45
46
# File 'lib/nvoi/configuration/root.rb', line 44

def aws
  @deploy.application.compute_provider.aws
end

#cloudflareObject



52
53
54
# File 'lib/nvoi/configuration/root.rb', line 52

def cloudflare
  @deploy.application.domain_provider.cloudflare
end

#docker_platformObject



64
65
66
67
68
69
# File 'lib/nvoi/configuration/root.rb', line 64

def docker_platform
  case architecture
  when "arm", "arm64" then "linux/arm64"
  else "linux/amd64"
  end
end

#env_for_service(service_name) ⇒ Object



19
20
21
# File 'lib/nvoi/configuration/root.rb', line 19

def env_for_service(service_name)
  Utils::EnvResolver.new(self).env_for_service(service_name)
end

#hetznerObject



40
41
42
# File 'lib/nvoi/configuration/root.rb', line 40

def hetzner
  @deploy.application.compute_provider.hetzner
end

#keep_count_valueObject



71
72
73
74
# File 'lib/nvoi/configuration/root.rb', line 71

def keep_count_value
  count = @deploy.application.keep_count
  count && count.positive? ? count : 2
end

#provider_nameObject



32
33
34
35
36
37
38
# File 'lib/nvoi/configuration/root.rb', line 32

def provider_name
  return "hetzner" if @deploy.application.compute_provider.hetzner
  return "aws" if @deploy.application.compute_provider.aws
  return "scaleway" if @deploy.application.compute_provider.scaleway

  ""
end

#scalewayObject



48
49
50
# File 'lib/nvoi/configuration/root.rb', line 48

def scaleway
  @deploy.application.compute_provider.scaleway
end

#validate_configObject



23
24
25
26
27
28
29
30
# File 'lib/nvoi/configuration/root.rb', line 23

def validate_config
  app = @deploy.application
  validate_providers_config
  validate_database_secrets(app.database) if app.database
  inject_database_env_vars
  validate_service_server_bindings
  validate_domain_uniqueness
end