firespring_dev_commands 2.1.1.pre.alpha.2 → 2.1.1.pre.alpha.3

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: 369c113ffd1b5a9c345d8123c4df7e5a635983cbdffbb9b9a2dadc8826be7fb5
4
- data.tar.gz: fa3643a4470b8f041af334969af99543ce7581bf088656a18bffae6ba2587e96
3
+ metadata.gz: d10b933492abcb58534be8f719de98cd99343e9bb150722ba06f06bc30ada3e4
4
+ data.tar.gz: da6153b815fd1b3b8c16d1da502cb083f74f1743fbd207d79c60369e2867e18a
5
5
  SHA512:
6
- metadata.gz: 6cded404bdfaf2aa243fac1cf9a344fefad9023ab1cb7c339dba77f4ffec8acbd6f86d8c94baebc72d3e79d63dfba56c253a863b9d5c868379d9bad7cadcabef
7
- data.tar.gz: 3f272118fc39705182f6f7365a68bb67e9e3f9faf1e6e9fd4ef2043ea0e9a25e2472f80e01aa50a8f032662a0abe39d28944b8205b8065108ec447a8a1a363ec
6
+ metadata.gz: d8ece475f87702fe6bb3841ec84301d7d3017870d93e4dacd86a17e7b174dc8975b9b508d935eaf6e235192aefbe59a1f1cd4894356c70e904274a5d84097658
7
+ data.tar.gz: 54d47ffc91f1177743b980df5c00b9d8a9d2c3e5870e31b08c6f0117ce33ef0a7701c7ec8f6a295a7043f94038fc98426faebbb04459583f91a31358db60e992
@@ -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
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.1.pre.alpha.2'.freeze
9
+ VERSION = '2.1.1.pre.alpha.3'.freeze
10
10
  end
11
11
  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.2
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 00:00:00.000000000 Z
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