cloudspin-stack 0.1.5 → 0.1.6

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: 1065b79854aadadb2e8a3c67d384a1e0eb25937a
4
- data.tar.gz: 67ee179bff193c718593eaaf1dd38f62895aafd5
3
+ metadata.gz: c885e8c2a9014973458e691e79b350769043e562
4
+ data.tar.gz: d008d0062896585c367f314110768f02ab6325b5
5
5
  SHA512:
6
- metadata.gz: 5eb673c43a94c97398cbf62ef3bb32158a20d30ab9ad720d1f80d54891166d88f1a406a36eed8929e72f7d69be5dc99b48501f3fbfb90abe04eece1ee76d58dd
7
- data.tar.gz: b1781e0d8c1d5c82d04711b096dd18e0d8d0dbc7d2cc90cebdaff2d6227ba17ebde9f3d1b743e029945c522882b375401a234542a536e4d7f8249b391465f256
6
+ metadata.gz: 8f1cea03a705b02c92e805dcbb9de31a698e93f9f1865bd8fc9bdb60f84d8a6dd4e0e14ed9f8a4901d358c5a629f1ac6adb75cee03029e8f1313e83748557247
7
+ data.tar.gz: 06c98e0cdaec56f173cdb2c90401cb10a05964c76ada6226c6ccf3d9835ecc13503827cde70abb1f09c67fa2a6181d6c629ea93dc18596d1ff6b9078f8090544
data/lib/cloudspin/cli.rb CHANGED
@@ -2,36 +2,60 @@ require 'thor'
2
2
  require 'cloudspin/stack'
3
3
 
4
4
  module Cloudspin
5
+
5
6
  class CLI < Thor
6
7
 
7
8
  class_option :file,
8
9
  :aliases => '-f',
9
10
  :banner => 'YAML-CONFIG-FILE',
10
11
  :type => :array,
11
- :default => [ 'spin-default.yaml', 'spin-local.yaml' ],
12
+ :default => [
13
+ Util.full_path_to('spin-default.yaml'),
14
+ Util.full_path_to('spin-local.yaml')
15
+ ],
12
16
  :desc => 'A list of configuration files to load for the stack instance. Values in files listed later override those from earlier files.'
13
17
 
14
18
  class_option :terraform_source,
15
19
  :aliases => '-t',
16
20
  :banner => 'PATH',
17
- :default => './src',
21
+ :default => Util.full_path_to('./src'),
18
22
  :desc => 'Folder with the terraform project source files'
19
23
 
20
24
  class_option :work,
21
25
  :aliases => '-w',
22
26
  :banner => 'PATH',
23
- :default => './work',
27
+ :default => Util.full_path_to('./work'),
24
28
  :desc => 'Folder to create and copy working files into'
25
29
 
26
30
  class_option :state,
27
31
  :aliases => '-s',
28
32
  :banner => 'PATH',
29
- :default => './state',
33
+ :default => Util.full_path_to('./state'),
30
34
  :desc => 'Folder to create and store local state'
31
35
 
32
- desc 'plan', 'Print the changes that will by applied when the \'stack up\' command is run'
36
+ desc 'plan', 'Print the changes that will by applied when the \'up\' command is run'
37
+ option :dry, :type => :boolean, :default => false
33
38
  def plan
34
- instance.plan
39
+ if options[:dry]
40
+ puts instance.plan_dry
41
+ else
42
+ instance.plan
43
+ end
44
+ end
45
+
46
+ desc 'up', 'Create or update the stack instance'
47
+ option :dry, :type => :boolean, :default => false
48
+ def up
49
+ if options[:dry]
50
+ puts instance.up_dry
51
+ else
52
+ instance.up
53
+ end
54
+ end
55
+
56
+ desc 'down', 'Destroy the stack instance'
57
+ def down
58
+ instance.down
35
59
  end
36
60
 
37
61
  desc 'version', 'Print the version number'
@@ -70,4 +94,6 @@ module Cloudspin
70
94
  end
71
95
 
72
96
  end
97
+
73
98
  end
99
+
@@ -53,14 +53,13 @@ module Cloudspin
53
53
  end
54
54
  end
55
55
 
56
- def plan_command
57
- options = {
58
- :state => terraform_statefile,
59
- :vars => terraform_variables
60
- }
56
+ def plan_dry
61
57
  plan_command = RubyTerraform::Commands::Plan.new
62
58
  command_line_builder = plan_command.instantiate_builder
63
- configured_command = plan_command.configure_command(command_line_builder, options)
59
+ configured_command = plan_command.configure_command(command_line_builder, {
60
+ :state => terraform_statefile,
61
+ :vars => terraform_variables
62
+ })
64
63
  built_command = configured_command.build
65
64
  built_command.to_s
66
65
  end
@@ -79,6 +78,17 @@ module Cloudspin
79
78
  end
80
79
  end
81
80
 
81
+ def up_dry
82
+ up_command = RubyTerraform::Commands::Apply.new
83
+ command_line_builder = up_command.instantiate_builder
84
+ configured_command = up_command.configure_command(command_line_builder, {
85
+ :state => terraform_statefile,
86
+ :vars => terraform_variables
87
+ })
88
+ built_command = configured_command.build
89
+ built_command.to_s
90
+ end
91
+
82
92
  def down
83
93
  RubyTerraform.clean(directory: working_folder)
84
94
  mkdir_p File.dirname(working_folder)
@@ -1,5 +1,5 @@
1
1
  module Cloudspin
2
2
  module Stack
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require 'cloudspin/stack/version'
2
+ require 'cloudspin/util'
2
3
  require 'cloudspin/stack/definition'
3
4
  require 'cloudspin/stack/instance'
4
5
 
@@ -0,0 +1,8 @@
1
+ module Cloudspin
2
+ class Util
3
+ def self.full_path_to(relative_path)
4
+ Pathname.new(Dir.pwd + '/' + relative_path).realpath.to_s
5
+ end
6
+ end
7
+ end
8
+
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'kief '
@@ -105,6 +105,7 @@ files:
105
105
  - lib/cloudspin/stack/definition.rb
106
106
  - lib/cloudspin/stack/instance.rb
107
107
  - lib/cloudspin/stack/version.rb
108
+ - lib/cloudspin/util.rb
108
109
  homepage: https://github.com/cloudspinners
109
110
  licenses:
110
111
  - MIT