terraspace 2.1.3 → 2.1.4

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: 821596efa82fca834084cd1ff1128f2d19e12fcf6b29143eac95c0b160d0724d
4
- data.tar.gz: f423fb9b8958619a342783e5bbcd07f61e39301d6faa8b7af7c1c53d59fcccc4
3
+ metadata.gz: 2409bdde16554e4640220d326b2905ebef223d15b06a9ee92e679b8e4da5d228
4
+ data.tar.gz: 2aac87334644fdb9c7d0d1de547796a8d4719b0c090d9be506fc99494de2ab87
5
5
  SHA512:
6
- metadata.gz: dec9d3e94b3b3e2ab3eea0c14392729eef461cc2a2c451365a158aaf2f6fe7e619b961dc9ccee3f6a18ed329a6eba199d33164c1857df8d469b4fe0f7b034193
7
- data.tar.gz: 3608ca4855cf1a30feb7aa2e2287c97a2f80fbcd5c74e8339076180f34ae54c93eefc13dc57ab6cc74829f9d46b3389ef534659e6804cf98c3d2d21021a61470
6
+ metadata.gz: a3579aef360d7557f69eb4f5db1c3e548b9f8fe788f8bb4a2b13b3e473f3ab0ae6e1d9c0737b7f1e46732b0b81f1b20f7a487baf3d08d936644fc6abb4307448
7
+ data.tar.gz: cedfeb838b20c0c5e4dbf5cc8d9140013c1f8309c43c1e665a85fd375e65310d20e25f837cfa77748c2ccb1a7edc8483427b3ffd3b850cfa1e596d5a4c7d157e
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.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
+
6
10
  ## [2.1.3] - 2022-07-13
7
11
  - [#251](https://github.com/boltops-tools/terraspace/pull/251) deprecation warning for `:CACHE_ROOT` in `config.build.cache_dir`
8
12
 
@@ -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
@@ -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,8 +2,9 @@ class Terraspace::Cloud::Vcs::LocalGit
2
2
  class Base
3
3
  extend Memoist
4
4
 
5
- def initialize(vars)
6
- @vars = vars
5
+ attr_reader :git_url
6
+ def initialize(vars, git_url)
7
+ @vars, @git_url = vars, git_url
7
8
  end
8
9
 
9
10
  def vars
@@ -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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "2.1.3"
2
+ VERSION = "2.1.4"
3
3
  end
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 NetworkError < Error; end
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.3
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-13 00:00:00.000000000 Z
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