cloudspin-stack 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e42299e2c0243036553c2f748348f9ab2d459a5
4
- data.tar.gz: c07378a6cf093be520bc4b969dd4d566f03f313b
3
+ metadata.gz: 0f17e30aca34b64f7cae5cbf8b4bfac77a3e17bd
4
+ data.tar.gz: 4fe590866118fdd68cc47525426136b864b58bb3
5
5
  SHA512:
6
- metadata.gz: 2051d8c1761565413f4a1ea9e689cf544e25e388ddd9abf30c817c5b4aa4bcf012e8cabcd3ff0d5f1d81b745374bfefcbc7b12f425cf3b33602126fc2ac10d95
7
- data.tar.gz: b6e89ba95bbecd7a94248fdcce690c21379fce7b11e57b8a574ad97ea274340c2219b33af8cb580694251cef33c907f872828566da0f626f5ba4e1b49a50f01c
6
+ metadata.gz: 47d253e1baa96567a40d540e24998c8ff24c1854fb8eaca8ada3c5705e07859846e5e87b7509e26ea8dcaa8690301ca9f6ed7b47bbfe29071a996c8b38d199e5
7
+ data.tar.gz: 875ff23b5272d3dabcb9ea22b5c8d8851efa51c6b5577c46bfb8f55e5fc108be045e34443ba0c87ae99a44f3ee619fdd9d18f243617caf69d257fa74e2b2ff8e
data/lib/cloudspin/cli.rb CHANGED
@@ -69,14 +69,13 @@ module Cloudspin
69
69
  Cloudspin::Stack::Instance.from_files(
70
70
  instance_configuration_files,
71
71
  stack_definition: stack_definition,
72
- backend_config: {},
73
- working_folder: options[:work],
74
- statefile_folder: options[:state]
72
+ base_working_folder: './work',
73
+ base_statefile_folder: './state'
75
74
  )
76
75
  end
77
76
 
78
77
  def stack_definition
79
- Cloudspin::Stack::Definition.from_file(options[:terraform_source] + '/stack-definition.yaml')
78
+ Cloudspin::Stack::Definition.from_file(options[:source] + '/stack-definition.yaml')
80
79
  end
81
80
 
82
81
  def instance_configuration_files
@@ -9,14 +9,12 @@ module Cloudspin
9
9
 
10
10
  attr_reader :id,
11
11
  :working_folder,
12
- :backend_config,
13
12
  :statefile_folder,
14
13
  :configuration
15
14
 
16
15
  def initialize(
17
16
  id:,
18
17
  stack_definition:,
19
- backend_config:,
20
18
  working_folder:,
21
19
  statefile_folder:,
22
20
  configuration:
@@ -24,46 +22,47 @@ module Cloudspin
24
22
  validate_id(id)
25
23
  @id = id
26
24
  @stack_definition = stack_definition
27
- @backend_config = backend_config
28
25
  @working_folder = working_folder
29
- @statefile_folder = Pathname.new(statefile_folder).realdirpath.to_s
26
+ @statefile_folder = statefile_folder
30
27
  @configuration = configuration
28
+ @backend_config = {}
31
29
  end
32
30
 
33
31
  def self.from_folder(
34
32
  *instance_configuration_files,
35
33
  definition_folder:,
36
- backend_config:,
37
- working_folder:,
38
- statefile_folder:
34
+ base_working_folder:,
35
+ base_statefile_folder:
39
36
  )
40
37
  self.from_files(
41
38
  instance_configuration_files,
42
39
  stack_definition: Definition.from_folder(definition_folder),
43
- backend_config: backend_config,
44
- working_folder: working_folder,
45
- statefile_folder: statefile_folder
40
+ base_working_folder: base_working_folder,
41
+ base_statefile_folder: base_statefile_folder
46
42
  )
47
43
  end
48
44
 
49
45
  def self.from_files(
50
46
  *instance_configuration_files,
51
47
  stack_definition:,
52
- backend_config:,
53
- working_folder:,
54
- statefile_folder:
48
+ base_working_folder:,
49
+ base_statefile_folder:
55
50
  )
56
51
  instance_configuration = InstanceConfiguration.from_files(stack_definition, instance_configuration_files)
57
52
  self.new(
58
53
  id: instance_configuration.instance_identifier,
59
54
  stack_definition: stack_definition,
60
- backend_config: backend_config,
61
- working_folder: working_folder,
62
- statefile_folder: statefile_folder,
55
+ working_folder: ensure_folder("#{base_working_folder}/#{instance_configuration.instance_identifier}"),
56
+ statefile_folder: ensure_folder("#{base_statefile_folder}/#{instance_configuration.instance_identifier}"),
63
57
  configuration: instance_configuration
64
58
  )
65
59
  end
66
60
 
61
+ def self.ensure_folder(folder)
62
+ FileUtils.mkdir_p folder
63
+ Pathname.new(folder).realdirpath.to_s
64
+ end
65
+
67
66
  def validate_id(raw_id)
68
67
  raise "Stack instance ID '#{raw_id}' won't work. It needs to work as a filename." if /[^0-9A-Za-z.\-\_]/ =~ raw_id
69
68
  raise "Stack instance ID '#{raw_id}' won't work. No double dots allowed." if /\.\./ =~ raw_id
@@ -83,7 +82,7 @@ module Cloudspin
83
82
  mkdir_p File.dirname(working_folder)
84
83
  cp_r @stack_definition.source_path, working_folder
85
84
  Dir.chdir(working_folder) do
86
- RubyTerraform.init(backend_config: backend_config)
85
+ RubyTerraform.init(backend_config: @backend_config)
87
86
  RubyTerraform.plan(
88
87
  destroy: plan_destroy,
89
88
  state: terraform_statefile,
@@ -109,7 +108,7 @@ module Cloudspin
109
108
  mkdir_p File.dirname(working_folder)
110
109
  cp_r @stack_definition.source_path, working_folder
111
110
  Dir.chdir(working_folder) do
112
- RubyTerraform.init(backend_config: backend_config)
111
+ RubyTerraform.init(backend_config: @backend_config)
113
112
  RubyTerraform.apply(
114
113
  auto_approve: true,
115
114
  state: terraform_statefile,
@@ -134,7 +133,7 @@ module Cloudspin
134
133
  mkdir_p File.dirname(working_folder)
135
134
  cp_r @stack_definition.source_path, working_folder
136
135
  Dir.chdir(working_folder) do
137
- RubyTerraform.init(backend_config: backend_config)
136
+ RubyTerraform.init(backend_config: @backend_config)
138
137
  RubyTerraform.destroy(
139
138
  force: true,
140
139
  state: terraform_statefile,
@@ -1,5 +1,5 @@
1
1
  module Cloudspin
2
2
  module Stack
3
- VERSION = '0.1.17'
3
+ VERSION = '0.1.18'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudspin-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'kief '