cloudspin-stack 0.1.26 → 0.1.27

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
  SHA256:
3
- metadata.gz: 3b334f2e638d35e7d95cf7442d61e945b75397daa27aeed2c146af701c9ba412
4
- data.tar.gz: 036ed173c2ab38c115e0df2646851cd01036b2e397b96c462a86ff5b8a171c18
3
+ metadata.gz: 5858e78ebe918f85653b0db6dceee1a28c74142b3625704a44e6b6fc07ef04bb
4
+ data.tar.gz: 984e44f2e3772398bc6eefd56291862168875df0a2b1d5240ea356fd4aa41bdb
5
5
  SHA512:
6
- metadata.gz: 60c63aaecf8c0dfd82fcdb610ae55bd813d064e59389378e3ed4fb5acaefa92c23db9c05816d3960b60f67824472a92a10023537833d76dc76c732bf0e5fb9cd
7
- data.tar.gz: 125c065e33ab6231bed9bf4192519e95707dc21e483ba343aefe2969bbc3cfa2daabd5f9e7376379dfb198c6977c86f95844df639c7ce9954ef9d99d6481f1a3
6
+ metadata.gz: 928106d326fbedf40089d05086f7e5c5aa6dc258a6e0f404709f0ae80284466ac2bd414c9fe3a2b0cf407655d70d1dbfca77af60107e68d3ce8ae13ddf55c0b2
7
+ data.tar.gz: '08d12578d7ff0b466a9d8e1022e32cec7d15e3ba6956f06eedd99ca8ee4e1b017d062239bfe7dc560c6993f016e3311b251363ed9eceefbcd5ea16e2dfa72999'
@@ -8,33 +8,39 @@ module Cloudspin
8
8
  attr_reader :version
9
9
  attr_reader :source_path
10
10
 
11
- def initialize(source_path:, stack_name:, stack_version: '0')
11
+ def initialize(source_path:, stack_name:, stack_version: '0', from_remote: false)
12
12
  @source_path = source_path
13
13
  @name = stack_name
14
14
  @version = stack_version
15
+ @from_remote = from_remote
15
16
  end
16
17
 
17
- def self.from_file(specfile)
18
+ def self.from_file(specfile, from_remote: false)
18
19
  raise NoStackDefinitionConfigurationFileError, "Did not find file '#{specfile}'" unless File.exists?(specfile)
19
20
  source_path = File.dirname(specfile)
20
21
  spec_hash = YAML.load_file(specfile)
21
22
  self.new(
22
23
  source_path: source_path,
23
24
  stack_name: spec_hash.dig('stack', 'name'),
24
- stack_version: spec_hash.dig('stack', 'version')
25
+ stack_version: spec_hash.dig('stack', 'version'),
26
+ from_remote: from_remote
25
27
  )
26
28
  end
27
29
 
28
30
  def self.from_location(definition_location, definition_cache_folder: '.cloudspin/definitions')
29
31
  if RemoteDefinition.is_remote?(definition_location)
30
32
  # puts "INFO: Downloading remote stack definition"
31
- from_file(RemoteDefinition.new(definition_location).fetch(definition_cache_folder))
33
+ from_file(RemoteDefinition.new(definition_location).fetch(definition_cache_folder), from_remote: true)
32
34
  else
33
35
  # puts "INFO: Using local stack definition source"
34
36
  from_file(definition_location)
35
37
  end
36
38
  end
37
39
 
40
+ def is_from_remote?
41
+ @from_remote
42
+ end
43
+
38
44
  end
39
45
 
40
46
  class NoStackDefinitionConfigurationFileError < StandardError; end
@@ -53,6 +53,11 @@ module Cloudspin
53
53
  stack_definition: stack_definition,
54
54
  base_folder: base_folder
55
55
  )
56
+
57
+ if instance_configuration.has_remote_state_configuration? && stack_definition.is_from_remote?
58
+ add_terraform_backend_source(stack_definition.source_path)
59
+ end
60
+
56
61
  self.new(
57
62
  id: instance_configuration.instance_identifier,
58
63
  stack_definition: stack_definition,
@@ -66,6 +71,18 @@ module Cloudspin
66
71
  Pathname.new(folder).realdirpath.to_s
67
72
  end
68
73
 
74
+ def self.add_terraform_backend_source(terraform_source_folder)
75
+ puts "DEBUG: Creating file #{terraform_source_folder}/_cloudspin_created_backend.tf"
76
+ File.open("#{terraform_source_folder}/_cloudspin_created_backend.tf", 'w') { |backend_file|
77
+ backend_file.write(<<~TF_BACKEND_SOURCE
78
+ terraform {
79
+ backend "s3" {}
80
+ }
81
+ TF_BACKEND_SOURCE
82
+ )
83
+ }
84
+ end
85
+
69
86
  def validate_id(raw_id)
70
87
  raise "Stack instance ID '#{raw_id}' won't work. It needs to work as a filename." if /[^0-9A-Za-z.\-\_]/ =~ raw_id
71
88
  raise "Stack instance ID '#{raw_id}' won't work. No double dots allowed." if /\.\./ =~ raw_id
@@ -1,5 +1,5 @@
1
1
  module Cloudspin
2
2
  module Stack
3
- VERSION = '0.1.26'
3
+ VERSION = '0.1.27'
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.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'kief '