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 +4 -4
- data/lib/cloudspin/cli.rb +3 -4
- data/lib/cloudspin/stack/instance.rb +18 -19
- data/lib/cloudspin/stack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f17e30aca34b64f7cae5cbf8b4bfac77a3e17bd
|
4
|
+
data.tar.gz: 4fe590866118fdd68cc47525426136b864b58bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
73
|
-
|
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[:
|
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 =
|
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
|
-
|
37
|
-
|
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
|
-
|
44
|
-
|
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
|
-
|
53
|
-
|
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
|
-
|
61
|
-
|
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,
|