firespring_dev_commands 2.1.1.pre.alpha.1 → 2.1.1.pre.alpha.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d10b933492abcb58534be8f719de98cd99343e9bb150722ba06f06bc30ada3e4
|
4
|
+
data.tar.gz: da6153b815fd1b3b8c16d1da502cb083f74f1743fbd207d79c60369e2867e18a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8ece475f87702fe6bb3841ec84301d7d3017870d93e4dacd86a17e7b174dc8975b9b508d935eaf6e235192aefbe59a1f1cd4894356c70e904274a5d84097658
|
7
|
+
data.tar.gz: 54d47ffc91f1177743b980df5c00b9d8a9d2c3e5870e31b08c6f0117ce33ef0a7701c7ec8f6a295a7043f94038fc98426faebbb04459583f91a31358db60e992
|
@@ -40,8 +40,10 @@ module Dev
|
|
40
40
|
# Wraps a block of code in a y/n question.
|
41
41
|
# If the user answers 'y' then the block is executed.
|
42
42
|
# If the user answers 'n' then the block is skipped.
|
43
|
-
def with_confirmation(message, default = 'y')
|
44
|
-
|
43
|
+
def with_confirmation(message, default = 'y', color_message: true)
|
44
|
+
message = "\n #{message}? "
|
45
|
+
message = message.light_green if color_message
|
46
|
+
print message
|
45
47
|
print '('.light_green << 'y'.light_yellow << '/'.light_green << 'n'.light_yellow << ') '.light_green
|
46
48
|
|
47
49
|
answer = default
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require_relative 'base_interface'
|
2
|
+
|
3
|
+
module Dev
|
4
|
+
module Template
|
5
|
+
# Contains all default rake tasks for a docker application
|
6
|
+
class Application
|
7
|
+
# Contains rake tasks for displaying and setting application variables in parameter store
|
8
|
+
class Config < Dev::Template::ApplicationInterface
|
9
|
+
attr_reader :path
|
10
|
+
|
11
|
+
# Allow for custom config path for the application
|
12
|
+
def initialize(name, path, exclude: [])
|
13
|
+
@path = path
|
14
|
+
super(name, exclude:)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Create the list rake task
|
18
|
+
def create_list_task!
|
19
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
20
|
+
application = @name
|
21
|
+
path = @path
|
22
|
+
exclude = @exclude
|
23
|
+
|
24
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
25
|
+
namespace application do
|
26
|
+
namespace :config do
|
27
|
+
return if exclude.include?(:list)
|
28
|
+
|
29
|
+
desc "List all #{application} configs"
|
30
|
+
task list: %w(init) do
|
31
|
+
puts
|
32
|
+
Dev::Aws::Parameter.new.list(path).each do |it|
|
33
|
+
puts " #{it.name} => #{it.value} (#{it.type})"
|
34
|
+
end
|
35
|
+
puts
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# rubocop:disable Metrics/MethodLength
|
43
|
+
# Create the set task
|
44
|
+
def create_set_task!
|
45
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
46
|
+
application = @name
|
47
|
+
path = @path
|
48
|
+
exclude = @exclude
|
49
|
+
|
50
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
51
|
+
namespace application do
|
52
|
+
namespace :config do
|
53
|
+
return if exclude.include?(:set)
|
54
|
+
|
55
|
+
desc 'Updates the parameter with the given name to the new value' \
|
56
|
+
"\n\tspecify NAME as the name of the parameter to be set (it will be prefixed with the base path for this app)" \
|
57
|
+
"\n\tspecify VALUE is required and is the value you wish the paramete to be set to" \
|
58
|
+
"\n\toptionally specify ENCRYPT=true to change a String type to a SecureString type"
|
59
|
+
task set: %w(ensure_aws_credentials) do
|
60
|
+
raise 'NAME is required' if ENV['NAME'].to_s.strip.blank?
|
61
|
+
raise 'NAME is not found in this apps parameters' if Dev::Aws::Parameter.new.list(path).none? { |it| it.name == ENV['NAME'] }
|
62
|
+
raise 'VALUE is required' if ENV['VALUE'].to_s.strip.blank?
|
63
|
+
|
64
|
+
param_path = ENV.fetch('NAME', nil)
|
65
|
+
new_value = ENV.fetch('VALUE', nil)
|
66
|
+
old_value = Dev::Aws::Parameter.new.get(param_path)
|
67
|
+
|
68
|
+
params = {type: 'String'}
|
69
|
+
if ENV['ENCRYPT'].to_s.strip == 'true' || old_value.type == 'SecureString'
|
70
|
+
params[:type] = 'SecureString'
|
71
|
+
params[:key_id] = Dev::Aws::Parameter.new.get_value("#{path}/kms/id")
|
72
|
+
end
|
73
|
+
|
74
|
+
message = _set_confirmation_message(param_path, old_value.value, old_value.type, new_value, params[:type])
|
75
|
+
Dev::Common.new.with_confirmation(message, color_message: false) do
|
76
|
+
Dev::Aws::Parameter.new.put(param_path, new_value, **params)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
# rubocop:enable Metrics/MethodLength
|
84
|
+
|
85
|
+
# Create the confirmation message text
|
86
|
+
def _set_confirmation_message(path, old_value, old_value_type, new_value, new_value_type)
|
87
|
+
'This will change '.light_green +
|
88
|
+
path.light_yellow +
|
89
|
+
' from "'.light_green +
|
90
|
+
old_value.light_yellow +
|
91
|
+
'" ('.light_green +
|
92
|
+
old_value_type.light_yellow +
|
93
|
+
') to "'.light_green +
|
94
|
+
new_value.light_yellow +
|
95
|
+
'" ('.light_green +
|
96
|
+
new_value_type.light_yellow +
|
97
|
+
'). Continue'.light_green
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.1.pre.alpha.
|
4
|
+
version: 2.1.1.pre.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -305,6 +305,7 @@ files:
|
|
305
305
|
- lib/firespring_dev_commands/templates/aws.rb
|
306
306
|
- lib/firespring_dev_commands/templates/base_interface.rb
|
307
307
|
- lib/firespring_dev_commands/templates/ci.rb
|
308
|
+
- lib/firespring_dev_commands/templates/config.rb
|
308
309
|
- lib/firespring_dev_commands/templates/docker/application.rb
|
309
310
|
- lib/firespring_dev_commands/templates/docker/default.rb
|
310
311
|
- lib/firespring_dev_commands/templates/docker/node/application.rb
|