simplygenius-atmos 0.11.8 → 0.11.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b36463da6285364bd4cedc5c58fca1dfe1a3be224e7ab5130782cfac077c6b9b
4
- data.tar.gz: 0303dd6ea2937a4f2d2c301dc817f76845fdaedb164766ed1888e8ec09fb1210
3
+ metadata.gz: 685baebb62604a3094114ff1616e1e044c0560ed9285c27686a4b8c3e635f964
4
+ data.tar.gz: 2eadc8adc7ca8574de3d9f44d1af4d7668c17de8d9b6bee7f38c5f3234f47f63
5
5
  SHA512:
6
- metadata.gz: e8aeef7da3b8bdb24619d57c2ef13426956e064168b86182d3293bff860c6c67d3c4ac744baf6b09c126fa6e51850dbd18360fa007adfc6cbffc305c8f0acc9d
7
- data.tar.gz: c13e39a367dd9ed322106ee213816552adb1c9387f26eef72d7e96b61453cfab851fd369cda7f67eecb81d89edae07edda786980b35201982bbae3e318420c95
6
+ metadata.gz: 96249401ac017e427d0a5131f8ee441d51da30b91ae5da13a42bbddc258b1f7402c30411d5d304f2680c79e88d6e62eed8bfa26f0f70bd1b85eaf5ced69fd985
7
+ data.tar.gz: 2025652bff07e78886a228f75e87183eb8b70ec0ec294223008f6abc4203ad9bf3cd617a39c06a521320812454c61e28d2a8c541eb9d5beb7c35b86bad4a3e3f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.11.9 (02/13/2020)
2
+ -------------------
3
+
4
+ * Automatically run init when needed for current environment [f902232](https://github.com/simplygenius/atmos/commit/f902232)
5
+
6
+
1
7
  0.11.8 (02/04/2020)
2
8
  -------------------
3
9
 
@@ -14,6 +14,9 @@ module SimplyGenius
14
14
  args = ["apply"]
15
15
  args << "--get-modules" unless Atmos.config["atmos.terraform.disable_auto_modules"].to_s == "true"
16
16
  @terraform_arguments.insert(0, *args)
17
+
18
+ self.auto_init = true
19
+
17
20
  super
18
21
  end
19
22
 
@@ -7,7 +7,6 @@ module SimplyGenius
7
7
  module Commands
8
8
 
9
9
  class Init < Terraform
10
- include FileUtils
11
10
 
12
11
  def self.description
13
12
  "Runs terraform init"
@@ -17,17 +16,7 @@ module SimplyGenius
17
16
  @terraform_arguments.insert(0, "init")
18
17
  super
19
18
 
20
- if ! Atmos.config["atmos.terraform.disable_shared_plugins"]
21
- home_dir = OS.windows? ? File.join("~", "Application Data") : "~"
22
- shared_plugins_dir = File.expand_path(File.join(home_dir,".terraform.d", "plugins"))
23
- logger.debug("Updating shared terraform plugins dir: #{shared_plugins_dir}")
24
- mkdir_p(shared_plugins_dir)
25
- terraform_plugins_dir = File.join(Atmos.config.tf_working_dir,'recipes', '.terraform', 'plugins')
26
- if File.exist?(terraform_plugins_dir)
27
- cp_r("#{terraform_plugins_dir}/.", shared_plugins_dir)
28
- end
29
- end
30
-
19
+ init_shared_plugins
31
20
  end
32
21
 
33
22
  end
@@ -14,6 +14,9 @@ module SimplyGenius
14
14
  args = ["plan"]
15
15
  args << "--get-modules" unless Atmos.config["atmos.terraform.disable_auto_modules"].to_s == "true"
16
16
  @terraform_arguments.insert(0, *args)
17
+
18
+ self.auto_init = true
19
+
17
20
  super
18
21
  end
19
22
 
@@ -6,6 +6,9 @@ module SimplyGenius
6
6
  module Commands
7
7
 
8
8
  class Terraform < BaseCommand
9
+ include FileUtils
10
+
11
+ attr_accessor :auto_init
9
12
 
10
13
  def self.description
11
14
  "Runs terraform"
@@ -17,6 +20,31 @@ module SimplyGenius
17
20
  @terraform_arguments = arguments
18
21
  end
19
22
 
23
+ def init_automatically(auth_env, get_modules)
24
+ tf_init_dir = File.join(Atmos.config.tf_working_dir, '.terraform')
25
+ backend_initialized = File.exist?(File.join(tf_init_dir, 'terraform.tfstate'))
26
+ auto_init_enabled = Atmos.config["atmos.terraform.auto_init"].to_s == "true"
27
+
28
+ if auto_init && auto_init_enabled && ! backend_initialized
29
+ exe = TerraformExecutor.new(process_env: auth_env)
30
+ exe.run("init", get_modules: get_modules.present?)
31
+ init_shared_plugins
32
+ end
33
+ end
34
+
35
+ def init_shared_plugins
36
+ if ! Atmos.config["atmos.terraform.disable_shared_plugins"]
37
+ home_dir = OS.windows? ? File.join("~", "Application Data") : "~"
38
+ shared_plugins_dir = File.expand_path(File.join(home_dir,".terraform.d", "plugins"))
39
+ logger.debug("Updating shared terraform plugins dir: #{shared_plugins_dir}")
40
+ mkdir_p(shared_plugins_dir)
41
+ terraform_plugins_dir = File.join(Atmos.config.tf_working_dir,'recipes', '.terraform', 'plugins')
42
+ if File.exist?(terraform_plugins_dir)
43
+ cp_r("#{terraform_plugins_dir}/.", shared_plugins_dir)
44
+ end
45
+ end
46
+ end
47
+
20
48
  def execute
21
49
 
22
50
  unless Atmos.config.is_atmos_repo?
@@ -28,8 +56,11 @@ module SimplyGenius
28
56
 
29
57
  Atmos.config.provider.auth_manager.authenticate(ENV) do |auth_env|
30
58
  begin
31
- exe = TerraformExecutor.new(process_env: auth_env)
32
59
  get_modules = @terraform_arguments.delete("--get-modules")
60
+
61
+ init_automatically(auth_env, get_modules)
62
+
63
+ exe = TerraformExecutor.new(process_env: auth_env)
33
64
  exe.run(*@terraform_arguments, get_modules: get_modules.present?)
34
65
  rescue TerraformExecutor::ProcessFailed => e
35
66
  logger.error(e.message)
@@ -1,5 +1,5 @@
1
1
  module SimplyGenius
2
2
  module Atmos
3
- VERSION = "0.11.8"
3
+ VERSION = "0.11.9"
4
4
  end
5
5
  end
@@ -125,3 +125,5 @@ atmos:
125
125
  working_dir_links: ['modules', 'templates', 'bin', '.terraform-version']
126
126
  # Set true if running terraform version < 0.11.x
127
127
  compat11: false
128
+ # Automatically run "init" if needed when using "atmos plan|apply"
129
+ auto_init: true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplygenius-atmos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.8
4
+ version: 0.11.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler