cloudspin-stack 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloudspin/cli.rb +13 -12
- data/lib/cloudspin/stack/instance.rb +13 -3
- data/lib/cloudspin/stack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4170afe9007ab5cebf6f4e58af38922acc5fce87
|
4
|
+
data.tar.gz: 8c5c4ce80a36b5466f00a6b12c6128a9d39876a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da540b6e8568124062af22ac849116136ab90bce97ad40ef05a9f3b8dd4689315af237503e4ee4b1453d4d64bc0f593c87c3b2f0245b868a007b0a5334c45ef4
|
7
|
+
data.tar.gz: d31bf8166024b87d4637d5b3519a69e9b95a3a853931bccd0eab9583ca7fd902fb8397c9099a536e2b12cace39eab1759034a93e84ebaca6053f89d4defffe33
|
data/lib/cloudspin/cli.rb
CHANGED
@@ -33,33 +33,33 @@ module Cloudspin
|
|
33
33
|
:default => Util.full_path_from_local('./state'),
|
34
34
|
:desc => 'Folder to create and store local state'
|
35
35
|
|
36
|
-
desc 'up', 'Create or update the stack instance'
|
36
|
+
desc 'up INSTANCE_ID', 'Create or update the stack instance'
|
37
37
|
option :dry, :type => :boolean, :default => false
|
38
38
|
option :plan, :type => :boolean, :default => false
|
39
|
-
def up
|
39
|
+
def up(id)
|
40
40
|
if options[:plan] && options[:dry]
|
41
|
-
puts instance.plan_dry
|
41
|
+
puts instance(id).plan_dry
|
42
42
|
elsif options[:plan] && ! options[:dry]
|
43
|
-
puts instance.plan
|
43
|
+
puts instance(id).plan
|
44
44
|
elsif ! options[:plan] && options[:dry]
|
45
|
-
puts instance.up_dry
|
45
|
+
puts instance(id).up_dry
|
46
46
|
else
|
47
|
-
instance.up
|
47
|
+
instance(id).up
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
desc 'down', 'Destroy the stack instance'
|
52
52
|
option :dry, :type => :boolean, :default => false
|
53
53
|
option :plan, :type => :boolean, :default => false
|
54
|
-
def down
|
54
|
+
def down(id)
|
55
55
|
if options[:plan] && options[:dry]
|
56
|
-
puts instance.plan_dry(plan_destroy: true)
|
56
|
+
puts instance(id).plan_dry(plan_destroy: true)
|
57
57
|
elsif options[:plan] && ! options[:dry]
|
58
|
-
puts instance.plan(plan_destroy: true)
|
58
|
+
puts instance(id).plan(plan_destroy: true)
|
59
59
|
elsif ! options[:plan] && options[:dry]
|
60
|
-
puts instance.down_dry
|
60
|
+
puts instance(id).down_dry
|
61
61
|
else
|
62
|
-
instance.down
|
62
|
+
instance(id).down
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -75,8 +75,9 @@ module Cloudspin
|
|
75
75
|
|
76
76
|
no_commands do
|
77
77
|
|
78
|
-
def instance
|
78
|
+
def instance(id)
|
79
79
|
stack = Cloudspin::Stack::Instance.new(
|
80
|
+
id: id,
|
80
81
|
stack_definition: stack_definition,
|
81
82
|
backend_config: {},
|
82
83
|
working_folder: options[:work],
|
@@ -7,17 +7,21 @@ module Cloudspin
|
|
7
7
|
|
8
8
|
include FileUtils
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :id,
|
11
|
+
:working_folder,
|
11
12
|
:backend_config,
|
12
13
|
:statefile_folder,
|
13
14
|
:parameter_values,
|
14
15
|
:resource_values
|
15
16
|
|
16
|
-
def initialize(
|
17
|
+
def initialize(id:,
|
18
|
+
stack_definition:,
|
17
19
|
backend_config:,
|
18
20
|
working_folder:,
|
19
21
|
statefile_folder:
|
20
22
|
)
|
23
|
+
validate_id(id)
|
24
|
+
@id = id
|
21
25
|
@stack_definition = stack_definition
|
22
26
|
@backend_config = backend_config
|
23
27
|
@working_folder = working_folder
|
@@ -26,6 +30,12 @@ module Cloudspin
|
|
26
30
|
@resource_values = {}
|
27
31
|
end
|
28
32
|
|
33
|
+
def validate_id(raw_id)
|
34
|
+
raise "Stack instance ID '#{raw_id}' won't work. It needs to work as a filename." if /[^0-9A-Za-z.\-\_]/ =~ raw_id
|
35
|
+
raise "Stack instance ID '#{raw_id}' won't work. No double dots allowed." if /\.\./ =~ raw_id
|
36
|
+
raise "Stack instance ID '#{raw_id}' won't work. First character should be a letter." if /^[^A-Za-z]/ =~ raw_id
|
37
|
+
end
|
38
|
+
|
29
39
|
def add_parameter_values(new_parameter_values)
|
30
40
|
@parameter_values.merge!(new_parameter_values)
|
31
41
|
end
|
@@ -123,7 +133,7 @@ module Cloudspin
|
|
123
133
|
end
|
124
134
|
|
125
135
|
def terraform_statefile
|
126
|
-
statefile_folder + "/
|
136
|
+
statefile_folder + "/stack-#{id}.tfstate"
|
127
137
|
end
|
128
138
|
|
129
139
|
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.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'kief '
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-terraform
|