cloudspin-stack 0.1.29 → 0.1.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d3b0fe384748ee9c1a871ed53c8c0b3002dcc99c5f07ec6f997c1ff329ea982
4
- data.tar.gz: 591b10684679c109886bdf67112eb7fb0f2d9e43ea2dcc4544eb93e5932e335a
3
+ metadata.gz: 1a0cac1862741e42e43595507f3013533717bbfd7927c449fd3dd61428008040
4
+ data.tar.gz: b3bcc54327a0a33d64185d4c9441f96a995fc7ca16bd735c7b3501e8f4abf0a1
5
5
  SHA512:
6
- metadata.gz: 55db31e3c2e88a859171e9ad06aaf3f7df0610b8ac3624107c3886cd98f31ae11a8d6f3105310e0ca5109ff6e8683d33823c7fe70abbbcceb06d27478787d57a
7
- data.tar.gz: 15a3b50778ca03e62e41531bdbba7d04b15a8b2bdd3002075a015464e1e139459c88fd1d06da4e98fdb18161879c399d8d8edc8329e158ed86de9658a4504447
6
+ metadata.gz: f5d3fd779e9faf9c3a7e05023147006974a41b28978c792dc24fb831b9890e344cddbec786e2a06b7f16b724b70dcb10ac72a06e20abb902a311c309da8a1250
7
+ data.tar.gz: 9eb450340c002f38f675542952359bfbe8611c7cd53b78623c5f0e60bc5af3e7677d6c780cca667162fd6214d59f59d3c1ccd107cdb228818efb09a2ecd7712b
data/lib/cloudspin/cli.rb CHANGED
@@ -15,8 +15,7 @@ module Cloudspin
15
15
  class_option :source,
16
16
  :aliases => '-s',
17
17
  :banner => 'PATH-OR-URL',
18
- :default => './src',
19
- :desc => 'Path to terraform project source files'
18
+ :desc => 'Path to terraform project source files. Defaults to ./src'
20
19
 
21
20
  class_option :environment,
22
21
  :aliases => '-e',
@@ -27,15 +27,28 @@ module Cloudspin
27
27
  )
28
28
  end
29
29
 
30
- def self.from_location(definition_location, definition_cache_folder: '.cloudspin/definitions')
31
- # puts "DEBUG: get definition from location #{definition_location}"
32
- if RemoteDefinition.is_remote?(definition_location)
30
+ def self.from_location(definition_location = nil,
31
+ definition_cache_folder: '.cloudspin/definitions',
32
+ stack_configuration: nil
33
+ )
34
+ resolved_definition_location = if ! definition_location.nil?
35
+ # puts "DEBUG: definition_location has been explicitly set to #{definition_location}"
36
+ definition_location
37
+ elsif ! stack_configuration.nil? && stack_configuration['definition_location']
38
+ # puts "DEBUG: definition_location comes from the stack configuration (#{stack_configuration})"
39
+ stack_configuration['definition_location']
40
+ else
41
+ './src'
42
+ end
43
+
44
+ # puts "DEBUG: get definition from location #{resolved_definition_location}"
45
+ if RemoteDefinition.is_remote?(resolved_definition_location)
33
46
  # puts "DEBUG: Downloading remote stack definition"
34
- local_definition_folder = RemoteDefinition.new(definition_location).fetch(definition_cache_folder)
47
+ local_definition_folder = RemoteDefinition.new(resolved_definition_location).fetch(definition_cache_folder)
35
48
  from_file("#{local_definition_folder}/stack-definition.yaml", from_remote: true)
36
49
  else
37
- # puts "DEBUG: Using local stack definition source: #{definition_location}/stack-definition.yaml"
38
- from_file("#{definition_location}/stack-definition.yaml")
50
+ # puts "DEBUG: Using local stack definition source: #{resolved_definition_location}/stack-definition.yaml"
51
+ from_file("#{resolved_definition_location}/stack-definition.yaml")
39
52
  end
40
53
  end
41
54
 
@@ -32,7 +32,11 @@ module Cloudspin
32
32
  )
33
33
  self.from_files(
34
34
  instance_configuration_files,
35
- stack_definition: Definition.from_location(definition_location),
35
+ stack_definition: Definition.from_location(
36
+ definition_location,
37
+ definition_cache_folder: "#{base_folder}/.cloudspin/definitions",
38
+ stack_configuration: InstanceConfiguration.load_configuration_values(instance_configuration_files)['stack']
39
+ ),
36
40
  base_folder: base_folder,
37
41
  base_working_folder: base_working_folder
38
42
  )
@@ -68,7 +72,7 @@ module Cloudspin
68
72
  end
69
73
 
70
74
  def self.add_terraform_backend_source(terraform_source_folder)
71
- puts "DEBUG: Creating file #{terraform_source_folder}/_cloudspin_created_backend.tf"
75
+ # puts "DEBUG: Creating file #{terraform_source_folder}/_cloudspin_created_backend.tf"
72
76
  File.open("#{terraform_source_folder}/_cloudspin_created_backend.tf", 'w') { |backend_file|
73
77
  backend_file.write(<<~TF_BACKEND_SOURCE
74
78
  terraform {
@@ -52,11 +52,7 @@ module Cloudspin
52
52
  stack_definition:,
53
53
  base_folder: '.'
54
54
  )
55
- configuration_values = {}
56
- configuration_files.flatten.each { |config_file|
57
- # puts "DEBUG: Reading configuration file: #{config_file}"
58
- configuration_values = configuration_values.deep_merge(yaml_file_to_hash(config_file))
59
- }
55
+ configuration_values = load_configuration_values(configuration_files)
60
56
  self.new(
61
57
  stack_definition: stack_definition,
62
58
  base_folder: base_folder,
@@ -64,6 +60,15 @@ module Cloudspin
64
60
  )
65
61
  end
66
62
 
63
+ def self.load_configuration_values(configuration_files)
64
+ configuration_values = {}
65
+ configuration_files.flatten.each { |config_file|
66
+ # puts "DEBUG: Reading configuration file: #{config_file}"
67
+ configuration_values = configuration_values.deep_merge(yaml_file_to_hash(config_file))
68
+ }
69
+ configuration_values
70
+ end
71
+
67
72
  def self.yaml_file_to_hash(yaml_file)
68
73
  if File.exists?(yaml_file)
69
74
  YAML.load_file(yaml_file) || {}
@@ -94,16 +99,6 @@ module Cloudspin
94
99
  "#{instance_identifier}.tfstate"
95
100
  end
96
101
 
97
- # def instance_identifier
98
- # if instance_values['identifier']
99
- # instance_values['identifier']
100
- # elsif instance_values['group']
101
- # stack_name + '-' + instance_values['group']
102
- # else
103
- # stack_name
104
- # end
105
- # end
106
-
107
102
  def to_s
108
103
  {
109
104
  'instance_identifier' => instance_identifier,
@@ -72,7 +72,7 @@ module Cloudspin
72
72
  end
73
73
 
74
74
  def clear_folder(folder_to_clear)
75
- FileUtils.remove_entry_secure(folder_to_clear)
75
+ FileUtils.remove_entry_secure(folder_to_clear) if File.exists?(folder_to_clear)
76
76
  end
77
77
 
78
78
  def path_of_source_in(zipfile_path)
@@ -1,5 +1,5 @@
1
1
  module Cloudspin
2
2
  module Stack
3
- VERSION = '0.1.29'
3
+ VERSION = '0.1.30'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudspin-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.29
4
+ version: 0.1.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'kief '
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-09 00:00:00.000000000 Z
11
+ date: 2018-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-terraform