terraspace 2.1.1 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -0
- data/lib/templates/base/project/Gemfile.tt +2 -2
- data/lib/terraspace/app.rb +3 -3
- data/lib/terraspace/cloud/vcs/local_git/azure.rb +62 -0
- data/lib/terraspace/cloud/vcs/local_git/base.rb +3 -2
- data/lib/terraspace/cloud/vcs/local_git.rb +5 -4
- data/lib/terraspace/mod.rb +21 -0
- data/lib/terraspace/shell/error.rb +7 -0
- data/lib/terraspace/terraform/runner.rb +12 -0
- data/lib/terraspace/version.rb +1 -1
- data/lib/terraspace.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2409bdde16554e4640220d326b2905ebef223d15b06a9ee92e679b8e4da5d228
|
4
|
+
data.tar.gz: 2aac87334644fdb9c7d0d1de547796a8d4719b0c090d9be506fc99494de2ab87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3579aef360d7557f69eb4f5db1c3e548b9f8fe788f8bb4a2b13b3e473f3ab0ae6e1d9c0737b7f1e46732b0b81f1b20f7a487baf3d08d936644fc6abb4307448
|
7
|
+
data.tar.gz: cedfeb838b20c0c5e4dbf5cc8d9140013c1f8309c43c1e665a85fd375e65310d20e25f837cfa77748c2ccb1a7edc8483427b3ffd3b850cfa1e596d5a4c7d157e
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
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.1.4] - 2022-07-16
|
7
|
+
- [#252](https://github.com/boltops-tools/terraspace/pull/252) puts friendlier user message with terraspace force_unlock suggestion
|
8
|
+
- [#253](https://github.com/boltops-tools/terraspace/pull/253) azure repo local git support
|
9
|
+
|
10
|
+
## [2.1.3] - 2022-07-13
|
11
|
+
- [#251](https://github.com/boltops-tools/terraspace/pull/251) deprecation warning for `:CACHE_ROOT` in `config.build.cache_dir`
|
12
|
+
|
13
|
+
## [2.1.2] - 2022-07-13
|
14
|
+
- [#249](https://github.com/boltops-tools/terraspace/pull/249) fix cost.enabled setting when nil
|
15
|
+
|
6
16
|
## [2.1.1] - 2022-07-12
|
7
17
|
- [#248](https://github.com/boltops-tools/terraspace/pull/248) fix destroy success return
|
8
18
|
|
data/README.md
CHANGED
@@ -118,6 +118,7 @@ To install modules:
|
|
118
118
|
* [Configurable CLI](https://terraspace.cloud/docs/config/args/): Configurable [CLI Hooks](https://terraspace.cloud/docs/config/hooks/) and [CLI Args](https://terraspace.cloud/docs/config/args/) allow you to adjust the underlying terraform command.
|
119
119
|
* [Testing](https://terraspace.cloud/docs/testing/): A testing framework that allows you to create test harnesses, deploy real-resources, and have higher confidence that your code works.
|
120
120
|
* [Terraform Cloud and Terraform Enterprise Support](https://terraspace.cloud/docs/cloud/): TFC and TFE are both supported. Terraspace adds additional conveniences to make working with Terraform Cloud Workspaces easier.
|
121
|
+
* [Terraspace Cloud Support](https://terraspace.cloud/docs/cloud/): Terraspace Cloud adds additional features and conveniences like a Dashboard, History, Team Management, Permissions, Real-time Logging, and Cost Estimates. It's specifically designed for Terraspace. You might also be interested in this blog post: [Terraspace Cloud Intro](https://blog.boltops.com/2022/06/10/terraspace-cloud/)
|
121
122
|
|
122
123
|
## Comparison
|
123
124
|
|
@@ -10,5 +10,5 @@ build_gemfile(
|
|
10
10
|
|
11
11
|
# Uncomment the ci and vcs provider you wish to use. Should use both ci and vcs gem
|
12
12
|
# Docs: https://terraspace.cloud/docs/ci/
|
13
|
-
# gem "terraspace_ci_github"
|
14
|
-
# gem "terraspace_vcs_github"
|
13
|
+
# gem "terraspace_ci_github" # gathers info from ci env
|
14
|
+
# gem "terraspace_vcs_github" # post comment on pr
|
data/lib/terraspace/app.rb
CHANGED
@@ -52,7 +52,7 @@ module Terraspace
|
|
52
52
|
config.cloud.record = "changes" # IE: changes or all
|
53
53
|
config.cloud.stack = ":APP-:ROLE-:MOD_NAME-:ENV-:EXTRA-:REGION"
|
54
54
|
config.cloud.cost = ActiveSupport::OrderedOptions.new
|
55
|
-
config.cloud.cost.enabled =
|
55
|
+
config.cloud.cost.enabled = cast_boolean(ENV['TS_COST'])
|
56
56
|
config.cloud.vcs = ActiveSupport::OrderedOptions.new
|
57
57
|
config.cloud.vcs.name = nil # github, gitlab, bitbucket. Else default to registered terraspace_vcs_* plugin
|
58
58
|
|
@@ -102,8 +102,8 @@ module Terraspace
|
|
102
102
|
# https://stackoverflow.com/questions/36228873/ruby-how-to-convert-a-string-to-boolean
|
103
103
|
# https://github.com/rails/rails/blob/5-1-stable/activemodel/lib/active_model/type/boolean.rb
|
104
104
|
# so dont have to add activemodel as a dependency just for this method
|
105
|
-
FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
|
106
|
-
def
|
105
|
+
FALSE_VALUES = [nil, false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
|
106
|
+
def cast_boolean(value)
|
107
107
|
if value == ""
|
108
108
|
nil
|
109
109
|
else
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class Terraspace::Cloud::Vcs::LocalGit
|
2
|
+
class Azure < Base
|
3
|
+
def vars
|
4
|
+
super.merge(
|
5
|
+
host: host,
|
6
|
+
full_repo: full_repo,
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
def commit_url
|
11
|
+
# IE: https://dev.azure.com/tongueroo/infra-project/_git/infra-ci/commit/aaa74f96d76053672ff1b91995c903605cd8a245
|
12
|
+
"#{base_repo_url}/commits/#{sha}" if sha
|
13
|
+
end
|
14
|
+
|
15
|
+
def base_repo_url
|
16
|
+
"#{host}/#{org}/#{project}/_git/#{repo}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def branch_url
|
20
|
+
# IE: https://dev.azure.com/tongueroo/infra-project/_git/infra-ci?version=GBmerge
|
21
|
+
"#{base_repo_url}?verison=GB#{sha}" if sha
|
22
|
+
end
|
23
|
+
|
24
|
+
# Also computed in ci plugins which detects it from the ci env.
|
25
|
+
# Also handling here for case when user provides PR_NUMBER and GIT_REPO outside of normal CI env.
|
26
|
+
def pr_url
|
27
|
+
"#{host}/#{full_repo}/pull-requests/#{pr_number}" if pr_number
|
28
|
+
end
|
29
|
+
|
30
|
+
# override to remove ssh
|
31
|
+
# https://ssh.dev.azure.com => https://dev.azure.com
|
32
|
+
def host
|
33
|
+
"https://dev.azure.com"
|
34
|
+
end
|
35
|
+
|
36
|
+
def url_info
|
37
|
+
uri = URI(git_url)
|
38
|
+
# IE: v3/tongueroo/infra-project/infra-ci
|
39
|
+
uri.path.sub(/^\//,'').split('/') # [version, org, project, repo]
|
40
|
+
end
|
41
|
+
|
42
|
+
def org
|
43
|
+
version, org, project, repo = url_info
|
44
|
+
org
|
45
|
+
end
|
46
|
+
|
47
|
+
def repo
|
48
|
+
version, org, project, repo = url_info
|
49
|
+
repo
|
50
|
+
end
|
51
|
+
|
52
|
+
def full_repo
|
53
|
+
version, org, project, repo = url_info
|
54
|
+
"#{org}/#{repo}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def project
|
58
|
+
version, org, project, repo = url_info
|
59
|
+
project
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -2,7 +2,7 @@ class Terraspace::Cloud::Vcs
|
|
2
2
|
class LocalGit < Base
|
3
3
|
def vars
|
4
4
|
if git_repo? && git_installed?
|
5
|
-
provider_vars = vcs_class ? vcs_class.new(base_vars).vars : {}
|
5
|
+
provider_vars = vcs_class ? vcs_class.new(base_vars, git_url).vars : {}
|
6
6
|
base_vars.merge(provider_vars).compact # remove items with nil values
|
7
7
|
else
|
8
8
|
{ build_system: "manual" }
|
@@ -11,9 +11,10 @@ class Terraspace::Cloud::Vcs
|
|
11
11
|
|
12
12
|
def vcs_class
|
13
13
|
case host
|
14
|
-
when /github/ then Github
|
15
|
-
when /gitlab/ then Gitlab
|
16
|
-
when /bitbucket/ then Bitbucket
|
14
|
+
when /github\.com/ then Github
|
15
|
+
when /gitlab\.com/ then Gitlab
|
16
|
+
when /bitbucket\.org/ then Bitbucket
|
17
|
+
when /ssh\.dev\.azure\.com/ then Azure
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
data/lib/terraspace/mod.rb
CHANGED
@@ -128,6 +128,27 @@ module Terraspace
|
|
128
128
|
raise "ERROR: config.build.cache_dir is not a String or responds to the .call method."
|
129
129
|
end
|
130
130
|
|
131
|
+
if pattern.include?(":CACHE_ROOT")
|
132
|
+
old_pattern = pattern
|
133
|
+
pattern = pattern.sub(':CACHE_ROOT/', '')
|
134
|
+
logger.info "WARN: Detected :CACHE_ROOT in config.build.cache_dir".color(:yellow)
|
135
|
+
logger.info <<~EOL
|
136
|
+
This has been deprecated and :CACHE_ROOT should not be in the config.build.cache_dir setting.
|
137
|
+
The :CACHE_ROOT pattern has been removed from config.build.cache_dir automatically.
|
138
|
+
|
139
|
+
To remove this warning, remove the :CACHE_ROOT. For example:
|
140
|
+
|
141
|
+
config/app.rb
|
142
|
+
|
143
|
+
config.build.cache_dir = "#{old_pattern}"
|
144
|
+
|
145
|
+
Update it to:
|
146
|
+
|
147
|
+
config.build.cache_dir = "#{pattern}"
|
148
|
+
|
149
|
+
EOL
|
150
|
+
end
|
151
|
+
|
131
152
|
path = expansion(pattern)
|
132
153
|
path = "#{Terraspace.cache_root}/#{path}"
|
133
154
|
path.gsub!(%r{/+},'/') # remove double slashes are more. IE: // -> / Useful since region is '' in generic expander
|
@@ -16,6 +16,8 @@ class Terraspace::Shell
|
|
16
16
|
Terraspace::BucketNotFoundError.new(message)
|
17
17
|
elsif shared_cache_error?
|
18
18
|
Terraspace::SharedCacheError.new(message)
|
19
|
+
elsif state_lock_error?
|
20
|
+
Terraspace::StateLockError.new(message)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -43,5 +45,10 @@ class Terraspace::Shell
|
|
43
45
|
message.include?("Failed to install provider from shared cache") ||
|
44
46
|
message.include?("Failed to validate installed provider")
|
45
47
|
end
|
48
|
+
|
49
|
+
def state_lock_error?
|
50
|
+
# Example: https://gist.github.com/tongueroo/6bcb86f88053c58fa50f434789268b78
|
51
|
+
message.include?("Error acquiring the state lock")
|
52
|
+
end
|
46
53
|
end
|
47
54
|
end
|
@@ -65,6 +65,18 @@ module Terraspace::Terraform
|
|
65
65
|
else
|
66
66
|
exit(1)
|
67
67
|
end
|
68
|
+
rescue Terraspace::StateLockError => e
|
69
|
+
logger.debug "ERROR: #{e.class}".color(:red)
|
70
|
+
logger.info e.message
|
71
|
+
md = e.message.match(/\s+ID:\s+(.*)/)
|
72
|
+
return unless md
|
73
|
+
return unless lock_id = md[1]
|
74
|
+
logger.info <<~EOL
|
75
|
+
You can force release the lock with:
|
76
|
+
|
77
|
+
terraspace force_unlock #{@mod.name} #{lock_id}
|
78
|
+
|
79
|
+
EOL
|
68
80
|
end
|
69
81
|
|
70
82
|
@@current_dir_message_shown = false
|
data/lib/terraspace/version.rb
CHANGED
data/lib/terraspace.rb
CHANGED
@@ -32,9 +32,10 @@ module Terraspace
|
|
32
32
|
|
33
33
|
class BucketNotFoundError < Error; end
|
34
34
|
class InitRequiredError < Error; end
|
35
|
+
class NetworkError < Error; end
|
35
36
|
class SharedCacheError < Error; end
|
36
37
|
class ShellError < Error; end
|
37
|
-
class
|
38
|
+
class StateLockError < Error; end
|
38
39
|
end
|
39
40
|
|
40
41
|
Terraspace::Booter.boot
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraspace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -670,6 +670,7 @@ files:
|
|
670
670
|
- lib/terraspace/cloud/vcs/interface.rb
|
671
671
|
- lib/terraspace/cloud/vcs/local_env.rb
|
672
672
|
- lib/terraspace/cloud/vcs/local_git.rb
|
673
|
+
- lib/terraspace/cloud/vcs/local_git/azure.rb
|
673
674
|
- lib/terraspace/cloud/vcs/local_git/base.rb
|
674
675
|
- lib/terraspace/cloud/vcs/local_git/bitbucket.rb
|
675
676
|
- lib/terraspace/cloud/vcs/local_git/github.rb
|