terradactyl-terraform 0.13.0 → 0.15.0
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 +4 -4
- data/.github/workflows/build-and-release.yml +5 -2
- data/.github/workflows/build-status.yml +26 -0
- data/.github/workflows/validate-pullrequest.yml +6 -5
- data/CHANGELOG.md +11 -0
- data/README.md +6 -3
- data/lib/terradactyl/terraform/commands.rb +0 -7
- data/lib/terradactyl/terraform/commands/apply.rb +1 -7
- data/lib/terradactyl/terraform/commands/base.rb +7 -3
- data/lib/terradactyl/terraform/commands/destroy.rb +15 -3
- data/lib/terradactyl/terraform/commands/fmt.rb +1 -7
- data/lib/terradactyl/terraform/commands/init.rb +11 -3
- data/lib/terradactyl/terraform/commands/plan.rb +1 -7
- data/lib/terradactyl/terraform/commands/refresh.rb +1 -7
- data/lib/terradactyl/terraform/commands/show.rb +7 -5
- data/lib/terradactyl/terraform/commands/validate.rb +1 -1
- data/lib/terradactyl/terraform/commands/version.rb +1 -7
- data/lib/terradactyl/terraform/planfile.rb +58 -17
- data/lib/terradactyl/terraform/version.rb +1 -1
- data/lib/terradactyl/terraform/version_manager.rb +62 -16
- metadata +4 -4
- data/lib/terradactyl/terraform/commands/checklist.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4c248e4fe981818a665e02636456e0cd6e88049d0e0495fe1cc3e2487c933ff
|
4
|
+
data.tar.gz: 37c74ac64e91d4697f00776c3b3e5491f065d2ef008bf0b813785593131008dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340b3e0c1ddfa250c5f04dbc59c4fdc4d6a25077f1097d41a5ab1588fbaa3467a20dbb1232baed536cd4c2e8deba7873e5841f914a2a97af26b245af775f33b3
|
7
|
+
data.tar.gz: 98c08dcd41f886c6d43f8921a84795b555585b2b923f07ff438610060eb0785ae266cbec381dddb079c3a580680b644174c027ccec9d9574ee9e45bca283de44
|
@@ -7,6 +7,9 @@ on:
|
|
7
7
|
paths:
|
8
8
|
- lib/terradactyl/terraform/version.rb
|
9
9
|
|
10
|
+
# Using the Ruby teams https://github.com/ruby/setup-ruby, not the Github
|
11
|
+
# team's https://github.com/actions/setup-ruby
|
12
|
+
|
10
13
|
jobs:
|
11
14
|
release:
|
12
15
|
env:
|
@@ -20,7 +23,7 @@ jobs:
|
|
20
23
|
- name: Checkout Code
|
21
24
|
uses: actions/checkout@v2
|
22
25
|
- name: Setup Ruby
|
23
|
-
uses:
|
26
|
+
uses: ruby/setup-ruby@v1
|
24
27
|
with:
|
25
28
|
ruby-version: '2.7'
|
26
29
|
bundler-cache: true
|
@@ -39,7 +42,7 @@ jobs:
|
|
39
42
|
with:
|
40
43
|
tag_name: v${{ env.RELEASE_VERSION }}
|
41
44
|
release_name: v${{ env.RELEASE_VERSION }}
|
42
|
-
|
45
|
+
body_path: ${{ env.RELEASE_BODY_PATH }}
|
43
46
|
draft: false
|
44
47
|
prerelease: false
|
45
48
|
- name: Upload Asset
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Build Status
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
# Using the Ruby teams https://github.com/ruby/setup-ruby, not the Github
|
9
|
+
# team's https://github.com/actions/setup-ruby
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
validate:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- name: Git clone
|
16
|
+
uses: actions/checkout@v2
|
17
|
+
with:
|
18
|
+
fetch-depth: 2
|
19
|
+
- name: Setup Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: '2.7'
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Run tests
|
25
|
+
id: test
|
26
|
+
run: bundle exec rake spec
|
@@ -5,6 +5,9 @@ on:
|
|
5
5
|
paths:
|
6
6
|
- '**.rb'
|
7
7
|
|
8
|
+
# Using the Ruby teams https://github.com/ruby/setup-ruby, not the Github
|
9
|
+
# team's https://github.com/actions/setup-ruby
|
10
|
+
|
8
11
|
jobs:
|
9
12
|
validate:
|
10
13
|
runs-on: ubuntu-latest
|
@@ -14,15 +17,13 @@ jobs:
|
|
14
17
|
with:
|
15
18
|
fetch-depth: 2
|
16
19
|
- name: Setup Ruby
|
17
|
-
uses:
|
20
|
+
uses: ruby/setup-ruby@v1
|
18
21
|
with:
|
19
22
|
ruby-version: '2.7'
|
20
23
|
bundler-cache: true
|
21
|
-
- name: Bundle install
|
22
|
-
run: |
|
23
|
-
bundle config path vendor/bundle
|
24
|
-
bundle install --jobs 4 --retry 3
|
25
24
|
- name: Run lint
|
25
|
+
id: lint
|
26
26
|
run: bundle exec rake lint
|
27
27
|
- name: Run tests
|
28
|
+
id: test
|
28
29
|
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.15.0 (2021-04-27)
|
4
|
+
|
5
|
+
NEW FEATURES:
|
6
|
+
|
7
|
+
* adds support for Terraform version `0.14.x`
|
8
|
+
* adds support for Terraform version `0.15.x`
|
9
|
+
|
10
|
+
BUG FIXES:
|
11
|
+
|
12
|
+
* fix broken version expression resolution
|
13
|
+
|
3
14
|
## 0.13.0 (2020-11-23)
|
4
15
|
|
5
16
|
NEW FEATURES:
|
data/README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# Terradactyl::Terraform
|
2
2
|
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/terradactyl-terraform)
|
4
|
+

|
5
|
+
|
6
|
+
Library for executing Terraform CLI operations, managing Terraform binary versions, and other related tasks.
|
4
7
|
|
5
8
|
## Requirements
|
6
9
|
|
7
10
|
Requires Ruby 2.5 or greater.
|
8
11
|
|
9
|
-
NOTE: While `VersionManager` can fetch & install ANY available version of Terraform, the Terraform sub-command operations are only supported between stable versions `~> 0.11.x` and `~> 0.
|
12
|
+
NOTE: While `VersionManager` can fetch & install ANY available version of Terraform, the Terraform sub-command operations are only supported between stable versions `~> 0.11.x` and `~> 0.15.x`.
|
10
13
|
|
11
14
|
## Installation
|
12
15
|
|
@@ -32,7 +35,7 @@ If you wish to try out some features, launch a `pry` repl and poke around ...
|
|
32
35
|
|
33
36
|
$ bundle exec pry -r 'terradactyl/terraform'
|
34
37
|
[1] pry(main)> Terradactyl::Terraform::VERSION
|
35
|
-
=> "0.
|
38
|
+
=> "0.15.0"
|
36
39
|
|
37
40
|
### Managing different Terraform versions
|
38
41
|
|
@@ -11,10 +11,3 @@ require_relative 'commands/destroy'
|
|
11
11
|
require_relative 'commands/fmt'
|
12
12
|
require_relative 'commands/show'
|
13
13
|
require_relative 'commands/validate'
|
14
|
-
require_relative 'commands/checklist'
|
15
|
-
|
16
|
-
module Terradactyl
|
17
|
-
module Terraform
|
18
|
-
Rev013 = Rev012
|
19
|
-
end
|
20
|
-
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Apply
|
7
7
|
def defaults
|
8
8
|
{
|
@@ -31,12 +31,6 @@ module Terradactyl
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
module Rev012
|
35
|
-
module Apply
|
36
|
-
include Rev011::Apply
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
34
|
module Commands
|
41
35
|
class Apply < Base
|
42
36
|
end
|
@@ -8,15 +8,19 @@ module Terradactyl
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def revisions
|
11
|
-
|
11
|
+
constants.select { |c| c =~ /Rev/ }.sort
|
12
12
|
end
|
13
13
|
|
14
14
|
def select_revision(version, object)
|
15
15
|
klass_name = object.class.name.split('::').last
|
16
|
-
|
16
|
+
revision = "#{revision(version)}::#{klass_name}"
|
17
17
|
return if klass_name == 'Base'
|
18
18
|
|
19
|
-
|
19
|
+
if Terradactyl::Terraform.const_defined?(revision)
|
20
|
+
object.extend(Terradactyl::Terraform.const_get(revision))
|
21
|
+
else
|
22
|
+
object.extend(Terradactyl::Terraform.const_get("Subcommands::#{klass_name}"))
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Destroy
|
7
7
|
def defaults
|
8
8
|
{
|
@@ -32,9 +32,21 @@ module Terradactyl
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
module
|
35
|
+
module Rev015
|
36
36
|
module Destroy
|
37
|
-
include
|
37
|
+
include Terradactyl::Terraform::Subcommands::Destroy
|
38
|
+
|
39
|
+
def defaults
|
40
|
+
super.reject { |k, _v| k == 'force' }
|
41
|
+
end
|
42
|
+
|
43
|
+
def switches
|
44
|
+
super.reject { |e| e == 'force' }
|
45
|
+
end
|
46
|
+
|
47
|
+
def arguments
|
48
|
+
super.reject { |k, _v| k == 'force' }
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
40
52
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Fmt
|
7
7
|
def defaults
|
8
8
|
{
|
@@ -19,12 +19,6 @@ module Terradactyl
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
module Rev012
|
23
|
-
module Fmt
|
24
|
-
include Rev011::Fmt
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
22
|
module Commands
|
29
23
|
class Fmt < Base
|
30
24
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Init
|
7
7
|
def defaults
|
8
8
|
{
|
@@ -33,9 +33,17 @@ module Terradactyl
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
module
|
36
|
+
module Rev015
|
37
37
|
module Init
|
38
|
-
include
|
38
|
+
include Terradactyl::Terraform::Subcommands::Init
|
39
|
+
|
40
|
+
def defaults
|
41
|
+
super.reject { |k, _v| k == 'lock' }
|
42
|
+
end
|
43
|
+
|
44
|
+
def arguments
|
45
|
+
super.reject { |k, _v| k == 'lock' }
|
46
|
+
end
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Plan
|
7
7
|
def defaults
|
8
8
|
{
|
@@ -33,12 +33,6 @@ module Terradactyl
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
module Rev012
|
37
|
-
module Plan
|
38
|
-
include Rev011::Plan
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
36
|
module Commands
|
43
37
|
class Plan < Base
|
44
38
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Refresh
|
7
7
|
def defaults
|
8
8
|
{
|
@@ -27,12 +27,6 @@ module Terradactyl
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
module Rev012
|
31
|
-
module Refresh
|
32
|
-
include Rev011::Refresh
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
30
|
module Commands
|
37
31
|
class Refresh < Base
|
38
32
|
end
|
@@ -2,35 +2,37 @@
|
|
2
2
|
|
3
3
|
module Terradactyl
|
4
4
|
module Terraform
|
5
|
-
module
|
5
|
+
module Subcommands
|
6
6
|
module Show
|
7
7
|
def defaults
|
8
8
|
{
|
9
|
-
'
|
9
|
+
'json' => false,
|
10
10
|
'no-color' => false
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
14
14
|
def switches
|
15
15
|
%w[
|
16
|
+
json
|
16
17
|
no-color
|
17
18
|
]
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
module
|
23
|
+
module Rev011
|
24
|
+
include Terradactyl::Terraform::Subcommands::Show
|
25
|
+
|
23
26
|
module Show
|
24
27
|
def defaults
|
25
28
|
{
|
26
|
-
'
|
29
|
+
'module-depth' => -1,
|
27
30
|
'no-color' => false
|
28
31
|
}
|
29
32
|
end
|
30
33
|
|
31
34
|
def switches
|
32
35
|
%w[
|
33
|
-
json
|
34
36
|
no-color
|
35
37
|
]
|
36
38
|
end
|
@@ -8,6 +8,8 @@ module Terradactyl
|
|
8
8
|
class PlanFileParser
|
9
9
|
attr_reader :plan_path
|
10
10
|
|
11
|
+
PLAN_FILE_SIGNATURE = 'Terraform will perform the following actions'
|
12
|
+
|
11
13
|
def self.load(plan_path)
|
12
14
|
new(plan_path)
|
13
15
|
end
|
@@ -24,10 +26,19 @@ module Terradactyl
|
|
24
26
|
@data ||= parse(@plan_path)
|
25
27
|
end
|
26
28
|
|
29
|
+
def signature
|
30
|
+
self.class::PLAN_FILE_SIGNATURE
|
31
|
+
end
|
32
|
+
|
27
33
|
private
|
28
34
|
|
35
|
+
# rubocop:disable Metrics/AbcSize
|
29
36
|
def parse(plan_path)
|
30
|
-
|
37
|
+
file_name = File.basename(plan_path)
|
38
|
+
stack_name = File.dirname(plan_path)
|
39
|
+
pushd(stack_name)
|
40
|
+
|
41
|
+
captured = Commands::Show.execute(dir_or_plan: file_name,
|
31
42
|
options: options,
|
32
43
|
capture: true)
|
33
44
|
|
@@ -40,7 +51,7 @@ module Terradactyl
|
|
40
51
|
parsed = JSON.parse(captured.stdout)
|
41
52
|
|
42
53
|
# The the `prior_state` node in the JSON returned from the
|
43
|
-
# planfile is not assembled
|
54
|
+
# planfile is not assembled consistently and therefore, never obeys
|
44
55
|
# any sort order. It does not appear to be of any consequence when
|
45
56
|
# calculating a checksum for the plan, so we excise it in an effort
|
46
57
|
# to conform the data. This is sub-optimal, but presently necessary.
|
@@ -48,7 +59,10 @@ module Terradactyl
|
|
48
59
|
# brian.warsing@visioncritical.com (2020-06-18)
|
49
60
|
|
50
61
|
parsed.reject { |k| k == 'prior_state' }.to_json
|
62
|
+
ensure
|
63
|
+
popd
|
51
64
|
end
|
65
|
+
# rubocop:enable Metrics/AbcSize
|
52
66
|
|
53
67
|
def options
|
54
68
|
Commands::Options.new do |opts|
|
@@ -57,6 +71,30 @@ module Terradactyl
|
|
57
71
|
opts.json = true
|
58
72
|
end
|
59
73
|
end
|
74
|
+
|
75
|
+
def pushd(path)
|
76
|
+
@working_dir_last = Dir.pwd
|
77
|
+
Dir.chdir(path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def popd
|
81
|
+
Dir.chdir(@working_dir_last)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
module Rev013
|
87
|
+
class PlanFileParser < Rev012::PlanFileParser
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module Rev014
|
92
|
+
class PlanFileParser < Rev012::PlanFileParser
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
module Rev015
|
97
|
+
class PlanFileParser < Rev012::PlanFileParser
|
60
98
|
end
|
61
99
|
end
|
62
100
|
|
@@ -120,20 +158,18 @@ module Terradactyl
|
|
120
158
|
end
|
121
159
|
# rubocop:enable Security/MarshalLoad
|
122
160
|
|
123
|
-
attr_reader :data, :checksum, :file_name, :stack_name
|
124
|
-
attr_writer :plan_output
|
161
|
+
attr_reader :data, :checksum, :file_name, :stack_name, :parser
|
162
|
+
attr_writer :plan_output, :error_output
|
125
163
|
attr_accessor :base_folder
|
126
164
|
|
127
165
|
WARN_NO_PLAN_OUTPUT = 'WARN: no plan output is available'
|
128
166
|
|
129
167
|
def initialize(plan_path:, parser:)
|
130
168
|
@plan_path = plan_path.to_s
|
131
|
-
@parser = parser
|
132
169
|
@file_name = File.basename(@plan_path)
|
133
170
|
@stack_name = File.basename(@plan_path, '.tfout')
|
134
171
|
@base_folder = File.dirname(@plan_path).split('/')[-2]
|
135
|
-
|
136
|
-
parse(@plan_path)
|
172
|
+
@parser = parse(parser, @plan_path)
|
137
173
|
end
|
138
174
|
|
139
175
|
def save(artifact_path: artifact)
|
@@ -150,7 +186,11 @@ module Terradactyl
|
|
150
186
|
end
|
151
187
|
|
152
188
|
def plan_output
|
153
|
-
|
189
|
+
format_plan_output(@plan_output)
|
190
|
+
end
|
191
|
+
|
192
|
+
def error_output
|
193
|
+
format_error_output(@error_output)
|
154
194
|
end
|
155
195
|
|
156
196
|
def to_markdown
|
@@ -172,8 +212,8 @@ module Terradactyl
|
|
172
212
|
|
173
213
|
private
|
174
214
|
|
175
|
-
def parse(plan_path)
|
176
|
-
|
215
|
+
def parse(parser, plan_path)
|
216
|
+
parser.load(plan_path).tap do |dat|
|
177
217
|
@data = dat.data
|
178
218
|
@checksum = dat.checksum
|
179
219
|
end
|
@@ -186,17 +226,18 @@ module Terradactyl
|
|
186
226
|
'terradactyl.planfile.data')
|
187
227
|
end
|
188
228
|
|
189
|
-
def
|
229
|
+
def format_error_output(string)
|
230
|
+
string.strip
|
231
|
+
end
|
232
|
+
|
233
|
+
def format_plan_output(string)
|
190
234
|
return WARN_NO_PLAN_OUTPUT unless string
|
191
235
|
|
192
|
-
|
236
|
+
# These hypens are different!
|
237
|
+
delimit = /(?:─|-){72,77}/
|
193
238
|
content = string.split(delimit).compact.reject(&:empty?)
|
194
239
|
|
195
|
-
|
196
|
-
content.last.strip
|
197
|
-
else
|
198
|
-
content[content.size / 3].strip
|
199
|
-
end
|
240
|
+
content.select { |e| e =~ /#{parser.signature}/ }.first.strip
|
200
241
|
end
|
201
242
|
end
|
202
243
|
end
|
@@ -8,6 +8,7 @@ require_relative 'version_manager/binary'
|
|
8
8
|
|
9
9
|
module Terradactyl
|
10
10
|
module Terraform
|
11
|
+
# rubocop:disable Metrics/ModuleLength
|
11
12
|
module VersionManager
|
12
13
|
class VersionManagerError < RuntimeError
|
13
14
|
def initialize(msg)
|
@@ -17,8 +18,10 @@ module Terradactyl
|
|
17
18
|
|
18
19
|
ERROR_MISSING = 'Terraform not installed'
|
19
20
|
ERROR_INVALID_VERSION_STRING = 'Invalid version string'
|
21
|
+
ERROR_UNRESOLVABLE_VERSION = 'Unresolvable version string'
|
22
|
+
ERROR_UNPARSEABLE_VERSION = 'Unparsable version string'
|
20
23
|
SEMVER_EXP_RE = /
|
21
|
-
^\s*((?<op>(
|
24
|
+
^\s*((?<op>(=|<=|>=|>|<|~>))\s+)?
|
22
25
|
(?<semver>\d+(\.\d+)?(\.\d+)?(-\w+)?)
|
23
26
|
/x.freeze
|
24
27
|
|
@@ -78,12 +81,8 @@ module Terradactyl
|
|
78
81
|
end
|
79
82
|
|
80
83
|
def resolve(expression)
|
81
|
-
|
82
|
-
|
83
|
-
semver = data['semver']
|
84
|
-
|
85
|
-
unless (resolution = resolve_expression(op, semver))
|
86
|
-
raise VersionManagerError, ERROR_INVALID_VERSION_STRING
|
84
|
+
unless (resolution = resolve_expression(expression.to_s.strip))
|
85
|
+
raise VersionManagerError, ERROR_UNRESOLVABLE_VERSION
|
87
86
|
end
|
88
87
|
|
89
88
|
resolution
|
@@ -91,19 +90,65 @@ module Terradactyl
|
|
91
90
|
|
92
91
|
private
|
93
92
|
|
94
|
-
def resolve_expression(
|
95
|
-
case
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
93
|
+
def resolve_expression(expression)
|
94
|
+
candiates = case expression
|
95
|
+
when /^~>/
|
96
|
+
resolve_pessimistic(expression)
|
97
|
+
when /^(?:>=|>|<=|<)/
|
98
|
+
resolve_range(expression)
|
99
|
+
when /^(?:=\s+)?\d+\.\d+\.\d+(?:-.*)?/
|
100
|
+
return resolve_equality(expression)
|
101
|
+
else
|
102
|
+
raise VersionManagerError, ERROR_INVALID_VERSION_STRING
|
103
|
+
end
|
104
|
+
|
105
|
+
candiates.reject { |v| v =~ /-/ }.last
|
106
|
+
end
|
107
|
+
|
108
|
+
def resolve_equality(expression)
|
109
|
+
expression.split(/\s+/).last
|
110
|
+
end
|
111
|
+
|
112
|
+
# rubocop:disable Metrics/AbcSize
|
113
|
+
def resolve_range(expression)
|
114
|
+
left, right = expression.split(/\s*,\s*/)
|
115
|
+
l_op, l_semver = parse_expression(left).captures
|
116
|
+
|
117
|
+
if right
|
118
|
+
r_op, r_semver = parse_expression(right).captures
|
102
119
|
else
|
103
|
-
|
120
|
+
r_op = l_op
|
121
|
+
r_semver = l_semver
|
122
|
+
end
|
123
|
+
|
124
|
+
l_gemver = Gem::Version.new(l_semver)
|
125
|
+
r_gemver = Gem::Version.new(r_semver)
|
126
|
+
|
127
|
+
versions(local: false).select do |v|
|
128
|
+
v = Gem::Version.new(v)
|
129
|
+
(v.send(l_op.to_sym, l_gemver) && v.send(r_op.to_sym, r_gemver))
|
130
|
+
end
|
131
|
+
end
|
132
|
+
# rubocop:enable Metrics/AbcSize
|
133
|
+
|
134
|
+
def resolve_pessimistic(expression)
|
135
|
+
semver = parse_expression(expression).captures.last
|
136
|
+
min = Gem::Version.new(semver)
|
137
|
+
max = Gem::Version.new(pessimistic_max(semver))
|
138
|
+
|
139
|
+
versions(local: false).select do |v|
|
140
|
+
v = Gem::Version.new(v)
|
141
|
+
(v >= min && v < max)
|
104
142
|
end
|
105
143
|
end
|
106
144
|
|
145
|
+
def parse_expression(expression)
|
146
|
+
match = expression.to_s.match(SEMVER_EXP_RE)
|
147
|
+
raise VersionManagerError, ERROR_UNPARSEABLE_VERSION unless match
|
148
|
+
|
149
|
+
match
|
150
|
+
end
|
151
|
+
|
107
152
|
def remote_versions
|
108
153
|
fh = Downloader.fetch(releases_url)
|
109
154
|
re = /terraform_(?<version>\d+\.\d+\.\d+(-\w+)?)/
|
@@ -127,5 +172,6 @@ module Terradactyl
|
|
127
172
|
end
|
128
173
|
end
|
129
174
|
end
|
175
|
+
# rubocop:enable Metrics/ModuleLength
|
130
176
|
end
|
131
177
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terradactyl-terraform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Warsing
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -146,6 +146,7 @@ extensions: []
|
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
148
148
|
- ".github/workflows/build-and-release.yml"
|
149
|
+
- ".github/workflows/build-status.yml"
|
149
150
|
- ".github/workflows/validate-pullrequest.yml"
|
150
151
|
- ".gitignore"
|
151
152
|
- ".rubocop.yml"
|
@@ -158,7 +159,6 @@ files:
|
|
158
159
|
- lib/terradactyl/terraform/commands.rb
|
159
160
|
- lib/terradactyl/terraform/commands/apply.rb
|
160
161
|
- lib/terradactyl/terraform/commands/base.rb
|
161
|
-
- lib/terradactyl/terraform/commands/checklist.rb
|
162
162
|
- lib/terradactyl/terraform/commands/destroy.rb
|
163
163
|
- lib/terradactyl/terraform/commands/fmt.rb
|
164
164
|
- lib/terradactyl/terraform/commands/init.rb
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
- !ruby/object:Gem::Version
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
|
-
rubygems_version: 3.1.
|
199
|
+
rubygems_version: 3.1.6
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Core functionality for managing a Terraform repo
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Terradactyl
|
4
|
-
module Terraform
|
5
|
-
module Rev011
|
6
|
-
module Checklist
|
7
|
-
def defaults
|
8
|
-
{}
|
9
|
-
end
|
10
|
-
|
11
|
-
def switches
|
12
|
-
[]
|
13
|
-
end
|
14
|
-
|
15
|
-
def subcmd
|
16
|
-
'0.12checklist'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
module Rev012
|
22
|
-
module Checklist
|
23
|
-
include Rev011::Checklist
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module Commands
|
28
|
-
class Checklist < Base
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|