awshark 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -1
- data/CHANGELOG.md +3 -0
- data/README.md +2 -2
- data/awshark.gemspec +0 -4
- data/gems.rb +4 -0
- data/lib/awshark/cloud_formation/{file_loading.rb → files.rb} +8 -5
- data/lib/awshark/cloud_formation/manager.rb +1 -1
- data/lib/awshark/cloud_formation/parameters.rb +2 -2
- data/lib/awshark/cloud_formation/stack.rb +2 -1
- data/lib/awshark/cloud_formation/subcommand.rb +2 -1
- data/lib/awshark/cloud_formation/template.rb +16 -10
- data/lib/awshark/profile_resolver.rb +2 -2
- data/lib/awshark/version.rb +1 -1
- metadata +3 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bef9c837050b965232d2ecdb22ee410262cdd4bb204fbeafd5458bd515d5161a
|
4
|
+
data.tar.gz: 87fe084cc741d50679c804bfa7f4e946ff664cbb211ace537b0b17fb8604e325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ecb73e200abbacb8f9e0d40799e968ab33e801550c6ecf6c8b8400fedc6b0594792b6919653a78f25391be4a90804ffbb224593a8eaed67ed2fd2e0081010c
|
7
|
+
data.tar.gz: dc2f4213c6baa6bfcd14fe06a29e23457f9129f58e932f6d7562b3a5b763651d8ff36741152620f8bce2179331015e2e96fa380e4ed3ccfbfc95fb805a7d2094
|
data/.rubocop.yml
CHANGED
@@ -4,11 +4,20 @@
|
|
4
4
|
# See https://docs.rubocop.org/rubocop/configuration
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
|
7
|
+
NewCops: enable
|
8
|
+
TargetRubyVersion: 3.1
|
8
9
|
Exclude:
|
9
10
|
- 'bin/*'
|
10
11
|
- 'tmp/*'
|
11
12
|
|
13
|
+
Bundler/GemFilename:
|
14
|
+
EnforcedStyle: gems.rb
|
15
|
+
|
16
|
+
Gemspec/RequireMFA:
|
17
|
+
Enabled: false
|
18
|
+
Gemspec/RequiredRubyVersion:
|
19
|
+
Enabled: false
|
20
|
+
|
12
21
|
Layout/BeginEndAlignment:
|
13
22
|
Enabled: true
|
14
23
|
EnforcedStyleAlignWith: begin
|
@@ -67,6 +76,7 @@ Lint/UselessMethodDefinition:
|
|
67
76
|
Lint/UselessTimes:
|
68
77
|
Enabled: true
|
69
78
|
|
79
|
+
|
70
80
|
Metrics/AbcSize:
|
71
81
|
Enabled: true
|
72
82
|
Max: 25
|
@@ -85,6 +95,8 @@ Style/ExponentialNotation:
|
|
85
95
|
Enabled: true
|
86
96
|
Style/HashEachMethods:
|
87
97
|
Enabled: true
|
98
|
+
Style/HashSyntax:
|
99
|
+
EnforcedShorthandSyntax: never
|
88
100
|
Style/HashTransformKeys:
|
89
101
|
Enabled: true
|
90
102
|
Style/HashTransformValues:
|
@@ -117,6 +129,8 @@ Style/HashLikeCase:
|
|
117
129
|
Enabled: true
|
118
130
|
Style/KeywordParametersOrder:
|
119
131
|
Enabled: true
|
132
|
+
Style/OpenStructUse:
|
133
|
+
Enabled: false
|
120
134
|
Style/OptionalBooleanParameter:
|
121
135
|
Enabled: true
|
122
136
|
Style/RedundantAssignment:
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,12 +47,12 @@ awshark ecs list
|
|
47
47
|
|
48
48
|
Display changes to AWS Cloud Formation stack.
|
49
49
|
```
|
50
|
-
awshark cf diff TEMPLATE_PATH --stage=STAGE --bucket=S3_BUCKET.bundesimmo.de
|
50
|
+
awshark cf diff TEMPLATE_PATH --stage=STAGE --bucket=S3_BUCKET.bundesimmo.de --format=json|yaml
|
51
51
|
```
|
52
52
|
|
53
53
|
Update or create AWS Cloud Formation stack.
|
54
54
|
```
|
55
|
-
awshark cf deploy TEMPLATE_PATH --stage=STAGE --bucket=S3_BUCKET.bundesimmo.de
|
55
|
+
awshark cf deploy TEMPLATE_PATH --stage=STAGE --bucket=S3_BUCKET.bundesimmo.de --format=json|yaml
|
56
56
|
```
|
57
57
|
|
58
58
|
Save AWS Cloud Formation stack as file `STACK_NAME-STAGE.json`.
|
data/awshark.gemspec
CHANGED
@@ -42,8 +42,4 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_dependency 'mini_mime'
|
43
43
|
spec.add_dependency 'recursive-open-struct'
|
44
44
|
spec.add_dependency 'thor', '~> 1.0'
|
45
|
-
|
46
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
47
|
-
spec.add_development_dependency 'rspec', '~> 3.9.0'
|
48
|
-
spec.add_development_dependency 'rubocop', '0.93.1'
|
49
45
|
end
|
data/gems.rb
CHANGED
@@ -2,20 +2,23 @@
|
|
2
2
|
|
3
3
|
module Awshark
|
4
4
|
module CloudFormation
|
5
|
-
module
|
6
|
-
def
|
5
|
+
module Files
|
6
|
+
def parse_file(filepath)
|
7
7
|
return nil if filepath.blank?
|
8
8
|
|
9
9
|
content = File.read(filepath)
|
10
|
-
content = ERB.new(content).result_with_hash(context) if context.present?
|
11
10
|
|
12
|
-
|
11
|
+
parse_string(filepath, content)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_string(filename, content)
|
15
|
+
case File.extname(filename)
|
13
16
|
when '.json'
|
14
17
|
JSON.parse(content)
|
15
18
|
when '.yml', '.yaml'
|
16
19
|
YAML.safe_load(content, permitted_classes: [Date, Time], aliases: true)
|
17
20
|
else
|
18
|
-
raise ArgumentError, "Unsupported file extension for #{filepath}"
|
21
|
+
raise ArgumentError, "Unsupported file extension for parsing, #{filepath}"
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Awshark
|
4
4
|
module CloudFormation
|
5
5
|
class Parameters
|
6
|
-
include
|
6
|
+
include Files
|
7
7
|
|
8
8
|
attr_reader :stage
|
9
9
|
|
@@ -34,7 +34,7 @@ module Awshark
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def load_parameters(filepath)
|
37
|
-
data =
|
37
|
+
data = parse_file(filepath) || {}
|
38
38
|
|
39
39
|
data[stage] || data
|
40
40
|
end
|
@@ -77,9 +77,10 @@ module Awshark
|
|
77
77
|
client.describe_stacks(stack_name: stack_name)
|
78
78
|
rescue Aws::CloudFormation::Errors::ValidationError
|
79
79
|
@stack = nil
|
80
|
-
return
|
81
80
|
end
|
82
81
|
|
82
|
+
return unless response.present?
|
83
|
+
|
83
84
|
if response.stacks.length > 1
|
84
85
|
raise ArgumentError, "Found too many stacks with name #{stack_name}. There should only be one."
|
85
86
|
end
|
@@ -5,7 +5,7 @@ require 'aws-sdk-ssm'
|
|
5
5
|
require 'diffy'
|
6
6
|
require 'recursive-open-struct'
|
7
7
|
|
8
|
-
require 'awshark/cloud_formation/
|
8
|
+
require 'awshark/cloud_formation/files'
|
9
9
|
require 'awshark/cloud_formation/inferrer'
|
10
10
|
require 'awshark/cloud_formation/manager'
|
11
11
|
require 'awshark/cloud_formation/parameters'
|
@@ -21,6 +21,7 @@ module Awshark
|
|
21
21
|
class_option :bucket, type: :string, desc: 'S3 bucket for template'
|
22
22
|
class_option :iam, type: :boolean, desc: 'Needs IAM capabilities'
|
23
23
|
class_option :stage, type: :string, desc: 'Stage of the configuration'
|
24
|
+
class_option :format, type: :string, desc: 'Stage of the configuration', default: 'json'
|
24
25
|
|
25
26
|
desc 'deploy', 'Updates or creates an AWS CloudFormation stack'
|
26
27
|
long_desc <<-LONGDESC
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Awshark
|
4
4
|
module CloudFormation
|
5
5
|
class Template
|
6
|
-
include
|
6
|
+
include Files
|
7
7
|
|
8
8
|
attr_reader :path
|
9
|
-
attr_reader :bucket, :name, :stage
|
9
|
+
attr_reader :bucket, :name, :stage, :format
|
10
10
|
|
11
11
|
def initialize(path, options = {})
|
12
12
|
@path = path
|
@@ -15,23 +15,29 @@ module Awshark
|
|
15
15
|
@bucket = (options[:bucket] || '').split('/')[0]
|
16
16
|
@name = options[:name]
|
17
17
|
@stage = options[:stage]
|
18
|
+
@format = options[:format] || 'yaml'
|
18
19
|
end
|
19
20
|
|
20
|
-
# @returns
|
21
|
-
def as_json
|
22
|
-
load_file(template_path, context)
|
23
|
-
end
|
24
|
-
|
25
|
-
# @returns [String]
|
21
|
+
# @returns String
|
26
22
|
def body
|
27
|
-
|
23
|
+
return nil if template_path.blank?
|
24
|
+
|
25
|
+
content = File.read(template_path)
|
26
|
+
content = ERB.new(content).result_with_hash(context)
|
27
|
+
|
28
|
+
if format == 'json'
|
29
|
+
json = parse_string(template_path, content)
|
30
|
+
return JSON.pretty_generate(json)
|
31
|
+
end
|
32
|
+
|
33
|
+
content
|
28
34
|
end
|
29
35
|
|
30
36
|
# @returns [Hash]
|
31
37
|
def context
|
32
38
|
@context ||=
|
33
39
|
begin
|
34
|
-
context =
|
40
|
+
context = parse_file(context_path) || {}
|
35
41
|
context = context[stage] if context.key?(stage)
|
36
42
|
|
37
43
|
{
|
@@ -3,12 +3,12 @@
|
|
3
3
|
module Awshark
|
4
4
|
class ProfileResolver
|
5
5
|
def initialize(options)
|
6
|
-
@profile = options[:profile] || ENV
|
6
|
+
@profile = options[:profile] || ENV.fetch('AWS_PROFILE')
|
7
7
|
@shared_config = ::Aws::SharedConfig.new(
|
8
8
|
profile_name: @profile,
|
9
9
|
config_enabled: true
|
10
10
|
)
|
11
|
-
@region = options[:region] || ENV
|
11
|
+
@region = options[:region] || ENV.fetch('REGION', nil)
|
12
12
|
end
|
13
13
|
|
14
14
|
def credentials
|
data/lib/awshark/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awshark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joergen Dahlke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -192,48 +192,6 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '1.0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: bundler
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - "~>"
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '2.0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - "~>"
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '2.0'
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: rspec
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - "~>"
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: 3.9.0
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - "~>"
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: 3.9.0
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: rubocop
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - '='
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: 0.93.1
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - '='
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: 0.93.1
|
237
195
|
description: Custom CLI for for AWS to simplify common tasks with EC2, S3 and Cloud
|
238
196
|
Formation
|
239
197
|
email:
|
@@ -255,7 +213,7 @@ files:
|
|
255
213
|
- lib/awshark/class_options.rb
|
256
214
|
- lib/awshark/cli.rb
|
257
215
|
- lib/awshark/cloud_formation/configuration.rb
|
258
|
-
- lib/awshark/cloud_formation/
|
216
|
+
- lib/awshark/cloud_formation/files.rb
|
259
217
|
- lib/awshark/cloud_formation/inferrer.rb
|
260
218
|
- lib/awshark/cloud_formation/manager.rb
|
261
219
|
- lib/awshark/cloud_formation/parameters.rb
|