cloudspin-stack 0.1.28 → 0.1.29

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: 88fb621c2f7c450bdc5ef3a7a5839be1b1527d0fc15002681eceea7fbd9cb13b
4
- data.tar.gz: 613787faf6aac87b43b211ada886b1bb2e3a70d381ca95270b77ddb01f55cdb3
3
+ metadata.gz: 8d3b0fe384748ee9c1a871ed53c8c0b3002dcc99c5f07ec6f997c1ff329ea982
4
+ data.tar.gz: 591b10684679c109886bdf67112eb7fb0f2d9e43ea2dcc4544eb93e5932e335a
5
5
  SHA512:
6
- metadata.gz: 6100cad6cc348bbd2d0e6e984de8ca3084315577c575492b0f728889351e5b30e5ebb2740a12232a045cad0d213602457b8e4fb7ca1e4311be23e1c4b14ba179
7
- data.tar.gz: 5f93ac2be468575471bd0edccaecb62e52b301d7be9fefc2439f88f5000af0308ab4868818f31f41560b90e6d5cf3ef8899017844444db17478c0c26aa368b51
6
+ metadata.gz: 55db31e3c2e88a859171e9ad06aaf3f7df0610b8ac3624107c3886cd98f31ae11a8d6f3105310e0ca5109ff6e8683d33823c7fe70abbbcceb06d27478787d57a
7
+ data.tar.gz: 15a3b50778ca03e62e41531bdbba7d04b15a8b2bdd3002075a015464e1e139459c88fd1d06da4e98fdb18161879c399d8d8edc8329e158ed86de9658a4504447
data/lib/cloudspin/cli.rb CHANGED
@@ -14,9 +14,9 @@ module Cloudspin
14
14
 
15
15
  class_option :source,
16
16
  :aliases => '-s',
17
- :banner => 'PATH',
17
+ :banner => 'PATH-OR-URL',
18
18
  :default => './src',
19
- :desc => 'Folder with the terraform project source files'
19
+ :desc => 'Path to terraform project source files'
20
20
 
21
21
  class_option :environment,
22
22
  :aliases => '-e',
@@ -72,16 +72,12 @@ module Cloudspin
72
72
  def instance
73
73
  Cloudspin::Stack::Instance.from_folder(
74
74
  instance_configuration_files,
75
- definition_location: './src',
75
+ definition_location: options[:source],
76
76
  base_folder: '.',
77
77
  base_working_folder: './work'
78
78
  )
79
79
  end
80
80
 
81
- def stack_definition
82
- Cloudspin::Stack::Definition.from_file(options[:source] + '/stack-definition.yaml')
83
- end
84
-
85
81
  def instance_configuration_files
86
82
  file_list = options[:file]
87
83
  if options[:environment]
@@ -26,14 +26,12 @@ module Cloudspin
26
26
 
27
27
  def self.from_folder(
28
28
  *instance_configuration_files,
29
- stack_name: nil,
30
29
  definition_location:,
31
30
  base_folder: '.',
32
31
  base_working_folder:
33
32
  )
34
33
  self.from_files(
35
34
  instance_configuration_files,
36
- stack_name: stack_name,
37
35
  stack_definition: Definition.from_location(definition_location),
38
36
  base_folder: base_folder,
39
37
  base_working_folder: base_working_folder
@@ -42,14 +40,12 @@ module Cloudspin
42
40
 
43
41
  def self.from_files(
44
42
  *instance_configuration_files,
45
- stack_name: nil,
46
43
  stack_definition:,
47
44
  base_folder: '.',
48
45
  base_working_folder:
49
46
  )
50
47
  instance_configuration = InstanceConfiguration.from_files(
51
48
  instance_configuration_files,
52
- stack_name: stack_name,
53
49
  stack_definition: stack_definition,
54
50
  base_folder: base_folder
55
51
  )
@@ -6,28 +6,39 @@ module Cloudspin
6
6
  class InstanceConfiguration
7
7
 
8
8
  attr_reader :stack_definition
9
- attr_reader :stack_name
10
9
  attr_reader :base_folder
11
10
 
12
11
  attr_reader :instance_values
13
12
  attr_reader :parameter_values
14
13
  attr_reader :resource_values
14
+ attr_reader :stack_values
15
15
 
16
+ attr_reader :stack_name
17
+ attr_reader :instance_identifier
16
18
  attr_reader :terraform_backend
17
19
 
18
20
  def initialize(
19
21
  configuration_values: {},
20
- stack_name: nil,
21
22
  stack_definition:,
22
23
  base_folder: '.'
23
24
  )
24
25
  @stack_definition = stack_definition
25
- @stack_name = stack_name || stack_definition.name
26
26
  @base_folder = base_folder
27
+
28
+ @stack_values = configuration_values['stack'] || {}
27
29
  @instance_values = configuration_values['instance'] || {}
28
30
  @parameter_values = configuration_values['parameters'] || {}
29
31
  @resource_values = configuration_values['resources'] || {}
30
32
 
33
+ @stack_name = @stack_values['name'] || stack_definition.name
34
+ @instance_identifier = if @instance_values['identifier']
35
+ instance_values['identifier']
36
+ elsif @instance_values['group']
37
+ stack_name + '-' + @instance_values['group']
38
+ else
39
+ stack_name
40
+ end
41
+
31
42
  @terraform_backend = configuration_values['terraform_backend'] || {}
32
43
  if @terraform_backend.empty?
33
44
  @terraform_backend['statefile_folder'] = default_state_folder
@@ -38,7 +49,6 @@ module Cloudspin
38
49
 
39
50
  def self.from_files(
40
51
  *configuration_files,
41
- stack_name: nil,
42
52
  stack_definition:,
43
53
  base_folder: '.'
44
54
  )
@@ -49,7 +59,6 @@ module Cloudspin
49
59
  }
50
60
  self.new(
51
61
  stack_definition: stack_definition,
52
- stack_name: stack_name,
53
62
  base_folder: base_folder,
54
63
  configuration_values: configuration_values
55
64
  )
@@ -85,15 +94,15 @@ module Cloudspin
85
94
  "#{instance_identifier}.tfstate"
86
95
  end
87
96
 
88
- def instance_identifier
89
- if instance_values['identifier']
90
- instance_values['identifier']
91
- elsif instance_values['group']
92
- stack_name + '-' + instance_values['group']
93
- else
94
- stack_name
95
- end
96
- end
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
97
106
 
98
107
  def to_s
99
108
  {
@@ -35,11 +35,11 @@ module Cloudspin
35
35
  request = Net::HTTP::Get.new(remote_file_uri)
36
36
  http.request(request) do |response|
37
37
  case response
38
- when Net::HTTPSuccess then write_local_file(response, local_file)
39
- when Net::HTTPRedirection then download_file(response['Location'], local_file, tries + 1)
40
- else
41
- raise "Request to '#{remote_file_uri}' failed: #{response.error} #{response.inspect}"
42
- end
38
+ when Net::HTTPSuccess then write_local_file(response, local_file)
39
+ when Net::HTTPRedirection then download_file(response['Location'], local_file, tries + 1)
40
+ else
41
+ raise "Request to '#{remote_file_uri}' failed: #{response.error} #{response.inspect}"
42
+ end
43
43
  end
44
44
  end
45
45
 
@@ -1,5 +1,5 @@
1
1
  module Cloudspin
2
2
  module Stack
3
- VERSION = '0.1.28'
3
+ VERSION = '0.1.29'
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.28
4
+ version: 0.1.29
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-08 00:00:00.000000000 Z
11
+ date: 2018-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-terraform