terraspace 2.2.11 → 2.2.12

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: 2ba2f34469d8982d58556de81cc8c4b4c5219a3be341f06465c228750e809c1e
4
- data.tar.gz: eb5aebca521115c47593c9467f23ca33bf4043c2891e85de0c4cf3cda4c72dc8
3
+ metadata.gz: 8aaefa8e220ec2998a8483d12043c9aa998042d3ffa6b7eee76e186db7f11c26
4
+ data.tar.gz: 33b63a92782d8c52136f8a2f737318ee7ad2ab5bb6f778ce6a494216863a9041
5
5
  SHA512:
6
- metadata.gz: 5b540849e1756c1761b7e15e2edc9ff3c1e9ed023f01f0b74dd1a7b2a9d8e61a343f4b058fc46dce1bd5d31aa477e5238c37508afac7dc558c71a262f759e0a7
7
- data.tar.gz: 7d2a55510b99d65d076b3f5b657af10c4e21fce146cadce2c2732abf530d96ba049dfe3c20f5655ffb7775a8c90a0b1406f40bdbfb10f6ae21896188894b9eb3
6
+ metadata.gz: ad0378722bd9d64f8d3a91d9289d5b7aa9d29fa6773d5505846e1aa3e45e0ce666d51f81320afad95aa733cfb11cfa09e776ab49980a41d2e4f2c29a832de005
7
+ data.tar.gz: 359104b53497ab56d219bbb8dec1ac78e23d4c6b6a6b79811918479a5356c1073d831e9a2c4c2653471d3f6def70e7c2d861da836b270420ace2f420ea476abd
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [2.2.12] - 2023-08-23
7
+ - [#326](https://github.com/boltops-tools/terraspace/pull/326) terraspace check improvements
8
+ - hide deprecated check commands
9
+
6
10
  ## [2.2.11] - 2023-08-23
7
11
  - [#325](https://github.com/boltops-tools/terraspace/pull/325) terraspace check improvements
8
12
 
@@ -11,7 +11,7 @@ module Terraspace
11
11
  end
12
12
 
13
13
  # Used for the CLI
14
- def run
14
+ def run(cloud: false)
15
15
  puts "terraspace version: #{Terraspace::VERSION}"
16
16
  if terraform_bin
17
17
  puts "#{terraform_bin_name} bin: #{pretty_home(terraform_bin)}"
@@ -20,16 +20,7 @@ module Terraspace
20
20
  if allowed_terraform_version?
21
21
  puts "You're all set!".color(:green)
22
22
  else
23
- puts "terraspace requires terraform between v#{@min_terraform_version}.x and #{@max_terraform_version}".color(:red)
24
- puts <<~EOL
25
- This is because newer versions of terraform has a BSL license
26
- If your usage is allowed by the license, you can bypass this check with:
27
-
28
- export TS_VERSION_CHECK=0
29
-
30
- Note: If you're using Terraspace Cloud, you won't be able to bypass this check.
31
- See: https://terraspace.cloud/docs/terraform/license/
32
- EOL
23
+ error_message(cloud: cloud)
33
24
  exit 1
34
25
  end
35
26
  else
@@ -39,9 +30,27 @@ module Terraspace
39
30
  end
40
31
  alias ok! run
41
32
 
33
+ def error_message(cloud: false)
34
+ name = cloud ? "Terraspace Cloud" : "Terraspace"
35
+ cloud_note =<<~EOL
36
+
37
+ Note: If you're using Terraspace Cloud, you won't be able to bypass this check.
38
+ See: https://terraspace.cloud/docs/terraform/license/
39
+ EOL
40
+
41
+ puts "ERROR: #{name} requires Terraform between v#{@min_terraform_version}.x and #{@max_terraform_version}".color(:red)
42
+ puts <<~EOL
43
+ This is because newer versions of Terraform has a BSL license
44
+ If your usage is allowed by the license, you can bypass this check with:
45
+
46
+ export TS_VERSION_CHECK=0
47
+ #{cloud_note}
48
+ EOL
49
+ end
50
+
42
51
  # aliased with ok?
43
52
  def allowed_terraform_version?
44
- return true if ENV['TS_VERSION_CHECK'] == '0' && Terraspace.cloud?
53
+ return true if ENV['TS_VERSION_CHECK'] == '0' && !Terraspace.cloud?
45
54
  return false unless terraform_bin
46
55
  return true if !terraform_bin.include?("terraform") # IE: allow any version of terraform forks
47
56
 
@@ -111,9 +120,10 @@ module Terraspace
111
120
  # Note: The -json option is only available in v0.13+
112
121
  def terraform_version
113
122
  out = `#{terraform_bin} --version`
114
- regexp = /(\d+\.\d+\.\d+)/
115
- line = out.split("\n").find { |l| l =~ regexp }
116
- version = line.match(regexp)[1] if line
123
+ # 1st regexp is more strict to avoid false positives
124
+ # 2nd regexp is more lenient in include beta suffixes
125
+ line = out.split("\n").find { |l| l =~ /(\d+\.\d+\.\d+)/ }
126
+ version = line.match(/(\d+\.\d+\.\d+.*)/)[1] if line
117
127
  end
118
128
  memoize :terraform_version
119
129
 
@@ -0,0 +1,7 @@
1
+ ## Example
2
+
3
+ $ terraspace check
4
+ terraspace version: 2.2.11
5
+ terraform bin: ~/.tfenv/bin/terraform
6
+ terraform version: 1.5.5
7
+ You're all set!
@@ -1,6 +1,6 @@
1
1
  class Terraspace::CLI
2
2
  class Setup < Terraspace::Command
3
- desc "check", "Check setup is ok"
3
+ desc "check", "Check setup is ok", hide: true
4
4
  long_desc Help.text("check")
5
5
  def check
6
6
  puts <<~EOL
@@ -42,7 +42,7 @@ module Terraspace
42
42
  long_desc Help.text(:new)
43
43
  subcommand "new", New
44
44
 
45
- desc "setup SUBCOMMAND", "setup subcommands"
45
+ desc "setup SUBCOMMAND", "setup subcommands", hide: true
46
46
  long_desc Help.text(:setup)
47
47
  subcommand "setup", Setup
48
48
 
@@ -66,7 +66,7 @@ module Terraspace
66
66
  Bundle.new(options.merge(args: args)).run
67
67
  end
68
68
 
69
- desc "check", "Check setup.", hide: true
69
+ desc "check", "Check setup."
70
70
  long_desc Help.text(:check)
71
71
  def check
72
72
  Check.new(options).run
@@ -7,10 +7,7 @@ class Terraspace::Cloud::Api
7
7
  def request(klass, path, data={})
8
8
  exit_on_error = data.delete(:exit_on_error) # for cani logic
9
9
  url = url(path)
10
- unless check.ok?
11
- puts "ERROR: terraspace cloud requires terraform between v#{check.min_terraform_version}.x and #{check.max_terraform_version}".color(:red)
12
- exit 1
13
- end
10
+ check.ok!(cloud: true)
14
11
  data = data.merge(versions: check.versions)
15
12
  req = build_request(klass, url, data)
16
13
  retries = 0
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "2.2.11"
2
+ VERSION = "2.2.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.11
4
+ version: 2.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -562,6 +562,7 @@ files:
562
562
  - lib/terraspace/cli/help/all/validate.md
563
563
  - lib/terraspace/cli/help/build.md
564
564
  - lib/terraspace/cli/help/bundle.md
565
+ - lib/terraspace/cli/help/check.md
565
566
  - lib/terraspace/cli/help/clean/all.md
566
567
  - lib/terraspace/cli/help/clean/cache.md
567
568
  - lib/terraspace/cli/help/clean/logs.md