cloudspin-stack-rake 0.1.14 → 0.1.15
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/stack/rake/stack_task.rb +104 -23
- data/lib/cloudspin/stack/rake/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb50ddbe7b944e4c063c276a1335bf0b219110bd0f4dfb51e71ece1d2668002
|
4
|
+
data.tar.gz: c00796dde1fb865b0cb8c2e382f01fd1a06a39c1b3c0582909d05941305c8123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f0adf65a6c4647acf85293f640e48172ce672fa985eb47b88182050b656e7403b7060891ef728e5234dbcea5c0e5b9cc4a7e442a74b0f3985617f16408bd88
|
7
|
+
data.tar.gz: fd79b3e9bac5863d4459e632eca893d96adcdda27308076c78617b8a901bd38005bcdd306cd6a6473b701458a9b3a2644dbac76f73ee120627d78c95c3f596f6
|
@@ -5,15 +5,16 @@ module Cloudspin
|
|
5
5
|
|
6
6
|
class StackTask < ::Rake::TaskLib
|
7
7
|
|
8
|
-
attr_reader :instance
|
9
8
|
attr_reader :environment
|
10
9
|
attr_reader :role
|
10
|
+
attr_reader :definition_folder
|
11
11
|
attr_reader :configuration_files
|
12
12
|
|
13
13
|
def initialize(
|
14
14
|
environment = nil,
|
15
15
|
role: 'instance',
|
16
|
-
definition_folder:
|
16
|
+
definition_folder: nil, # Should be deprecated
|
17
|
+
definition_location: nil,
|
17
18
|
base_folder: '.',
|
18
19
|
configuration_files: nil
|
19
20
|
)
|
@@ -22,15 +23,45 @@ module Cloudspin
|
|
22
23
|
@base_folder = base_folder
|
23
24
|
@configuration_files = configuration_files || the_usual_configuration_files
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
# TODO: Pick this up from the configuration files?
|
27
|
+
@definition_location = if definition_location
|
28
|
+
definition_location
|
29
|
+
elsif definition_folder
|
30
|
+
puts "'definition_folder': is deprecated for Cloudspin::Stack::Rake::StackTask - use 'definition_location' instead"
|
31
|
+
definition_folder
|
32
|
+
else
|
33
|
+
'./src'
|
34
|
+
end
|
35
|
+
|
36
|
+
# @remote_zipfile = remote_zipfile
|
31
37
|
define
|
32
38
|
end
|
33
39
|
|
40
|
+
def instance
|
41
|
+
@instance ||= begin
|
42
|
+
local_definition_folder = fetch_definition
|
43
|
+
puts "Will use local stack definition files in #{local_definition_folder}"
|
44
|
+
Cloudspin::Stack::Instance.from_folder(
|
45
|
+
@configuration_files,
|
46
|
+
definition_folder: local_definition_folder,
|
47
|
+
base_folder: @base_folder,
|
48
|
+
base_working_folder: "#{@base_folder}/work"
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def fetch_definition
|
54
|
+
if /^http.*\.zip$/.match @definition_location
|
55
|
+
puts "Downloading stack definition source from a remote zipfile"
|
56
|
+
fetch_definition_zipfile
|
57
|
+
elsif /^[\.\/]/.match @definition_location
|
58
|
+
puts "Using local stack definition source"
|
59
|
+
@definition_location
|
60
|
+
else
|
61
|
+
raise UnsupportedStackDefinitionLocationError, @definition_location
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
34
65
|
def the_usual_configuration_files
|
35
66
|
file_list = default_configuration_files
|
36
67
|
if @environment
|
@@ -60,36 +91,86 @@ module Cloudspin
|
|
60
91
|
|
61
92
|
def define
|
62
93
|
|
63
|
-
desc "Create or update stack
|
94
|
+
desc "Create or update stack instance"
|
64
95
|
task :up do
|
65
|
-
puts
|
66
|
-
puts
|
67
|
-
puts
|
96
|
+
puts instance.init_dry
|
97
|
+
puts instance.up_dry
|
98
|
+
puts instance.up
|
68
99
|
end
|
69
100
|
|
70
|
-
desc "Plan changes to stack
|
101
|
+
desc "Plan changes to stack instance"
|
71
102
|
task :plan do
|
72
|
-
puts
|
73
|
-
puts
|
74
|
-
puts
|
103
|
+
puts instance.init_dry
|
104
|
+
puts instance.plan_dry
|
105
|
+
puts instance.plan
|
75
106
|
end
|
76
107
|
|
77
|
-
desc "Show command line to be run for stack
|
108
|
+
desc "Show command line to be run for stack instance"
|
78
109
|
task :dry do
|
79
|
-
puts
|
80
|
-
puts
|
110
|
+
puts instance.init_dry
|
111
|
+
puts instance.up_dry
|
81
112
|
end
|
82
113
|
|
83
|
-
desc "Destroy stack
|
114
|
+
desc "Destroy stack instance"
|
84
115
|
task :down do
|
85
|
-
puts
|
86
|
-
puts
|
87
|
-
puts
|
116
|
+
puts instance.init_dry
|
117
|
+
puts instance.down_dry
|
118
|
+
puts instance.down
|
88
119
|
end
|
120
|
+
end
|
89
121
|
|
122
|
+
# TODO: This stuff belongs in a core class, so the CLI and other stuff can use it, too.
|
123
|
+
|
124
|
+
def fetch_definition_zipfile
|
125
|
+
unpack(download_artefact(@definition_location), '.cloudspin/definitions')
|
126
|
+
end
|
127
|
+
|
128
|
+
def download_artefact(artefact_url)
|
129
|
+
download_dir = Dir.mktmpdir(['cloudspin-', '-download'])
|
130
|
+
zipfile = "#{download_dir}/undetermined-spin-stack-artefact.zip"
|
131
|
+
puts "Downloading artefact from #{artefact_url} to #{zipfile}"
|
132
|
+
File.open(zipfile, 'wb') do |saved_file|
|
133
|
+
open(artefact_url, 'rb') do |read_file|
|
134
|
+
saved_file.write(read_file.read)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
zipfile
|
138
|
+
end
|
139
|
+
|
140
|
+
def unpack(zipfile, where_to_put_it)
|
141
|
+
folder_name = path_of_source_in(zipfile)
|
142
|
+
puts "Unzipping #{zipfile} to #{where_to_put_it}"
|
143
|
+
Zip::File.open(zipfile) { |zip_file|
|
144
|
+
zip_file.each { |f|
|
145
|
+
puts "-> #{f.name}"
|
146
|
+
f_path = File.join(where_to_put_it, f.name)
|
147
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
148
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
149
|
+
}
|
150
|
+
}
|
151
|
+
puts "Definition unpacked to #{where_to_put_it}/#{folder_name}"
|
152
|
+
"#{where_to_put_it}/#{folder_name}"
|
153
|
+
end
|
154
|
+
|
155
|
+
def path_of_source_in(zipfile_path)
|
156
|
+
File.dirname(path_of_configuration_file_in(zipfile_path))
|
157
|
+
end
|
158
|
+
|
159
|
+
def path_of_configuration_file_in(zipfile_path)
|
160
|
+
zipfile = Zip::File.open(zipfile_path)
|
161
|
+
begin
|
162
|
+
zipfile.entries.select { |entry|
|
163
|
+
/\/stack-definition.yaml$/.match entry.name
|
164
|
+
}.first.name
|
165
|
+
ensure
|
166
|
+
zipfile.close
|
167
|
+
end
|
90
168
|
end
|
91
169
|
|
92
170
|
end
|
171
|
+
|
172
|
+
class UnsupportedStackDefinitionLocationError < StandardError; end
|
173
|
+
|
93
174
|
end
|
94
175
|
end
|
95
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudspin-stack-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'kief '
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cloudspin-stack
|