mina-infinum 2.1.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7515a358a97fb531c9234b5af9f66d38b21ca179baa2630a6c0cdab7594bc81d
4
- data.tar.gz: 0d1c15c942585a620cae300808ae5c509dbc8329fd68a17a67913e27203e3ab0
3
+ metadata.gz: b9e1081ff27138ce5b9264ec25ed270c8e394ffd35ee7272e9a60897a4e87a3b
4
+ data.tar.gz: 81e98a8aaeceefbef746339be9ad07860a8ae11eff653131832b84444960312d
5
5
  SHA512:
6
- metadata.gz: d636c8821a835dc329c263ebe7da0cafc1689aa4b4c41829988e243979c76f1867fedea43b1d2fdad509e11ff2bd96ed0e60a27645b217b47591056c29c386b0
7
- data.tar.gz: 28ce51888667a163a17dd3274643f9071d1cc88fa2981f593454cb92a2940996665deb17d9512e6cdcfa0c3f319af8003e778e2632faae3306927bd89ab4c725
6
+ metadata.gz: 6e4863e6edadd84172c87cc34d043b4db4445be056373d1b1ba8b6982e839a205e3c9390bc84050d0f9ded00911440e0ac541bedadeb396d26282369f84db0d8
7
+ data.tar.gz: d02cb8f73830e4e4f5436d0e25a5eb5ae842543c8c55887e3ce739208780c3ba6309560abae8f04b14a26e0d28e762a290b467ae1a2f4326c93f50bb2a45aea0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [v2.2.0](https://github.com/infinum/mina-infinum/tree/v-2.2.0) (2025-07-25)
4
+ [Full Changelog](https://github.com/infinum/mina-infinum/compare/v2.1.0...v2.2.0)
5
+
6
+ ### Enhancements
7
+
8
+ - Add aliases for aws:login and rails:console tasks [\#6](https://github.com/infinum/mina-infinum/pull/6)
9
+ - Add params:pull and params:read tasks to AWS tasks [\#7](https://github.com/infinum/mina-infinum/pull/7)
10
+
3
11
  ## [v2.1.0](https://github.com/infinum/mina-infinum/tree/v-2.1.0) (2025-05-29)
4
12
  [Full Changelog](https://github.com/infinum/mina-infinum/compare/v2.0.0...v2.1.0)
5
13
 
@@ -91,3 +91,6 @@ def profile_exists?(profile)
91
91
 
92
92
  profiles.split("\n").include?(profile)
93
93
  end
94
+
95
+ desc 'Alias for aws:login'
96
+ task :login => 'aws:login'
@@ -0,0 +1,73 @@
1
+ require 'mina/infinum/ecs/aws'
2
+
3
+ namespace :params do
4
+ desc <<~TXT
5
+ Print AWS Param Store params to stdout
6
+
7
+ By default, params are fetched from path "/:cluster/".
8
+ All levels of params are fetched under this path, e.g.
9
+ both "/:cluster/A" and "/:cluster/A/B/C" will be fetched.
10
+
11
+ You can override the path by setting :params_path.
12
+ TXT
13
+ task read: ['aws:profile:check'] do
14
+ puts get_params.map(&:as_env)
15
+ end
16
+
17
+ desc <<~TXT
18
+ Save AWS Param Store params to .env file
19
+
20
+ See params:read documentation for details on how params
21
+ are fetched.
22
+ TXT
23
+ task pull: ['aws:profile:check'] do
24
+ env_file_path = File.join(Dir.pwd, '.env')
25
+
26
+ File.write(env_file_path, get_params.map(&:as_env).join("\n"))
27
+ end
28
+ end
29
+
30
+ Param = Data.define(:name, :value) do
31
+ # /staging-acme/acme/staging/BUGSNAG_API_KEY -> BUGSNAG_API_KEY
32
+ def variable_name
33
+ name.split('/').last
34
+ end
35
+
36
+ def as_env
37
+ "#{variable_name}=#{value}"
38
+ end
39
+ end
40
+
41
+ def get_params
42
+ normalize_params(get_params_from_aws)
43
+ end
44
+
45
+ def normalize_params(raw_params)
46
+ raw_params.map do |param|
47
+ Param.new(name: param.fetch('Name'), value: param.fetch('Value'))
48
+ end
49
+ end
50
+
51
+ def get_params_from_aws
52
+ params_path = fetch(:params_path) || default_params_path
53
+ output = run_cmd squish(<<~CMD)
54
+ aws ssm get-parameters-by-path
55
+ --path #{params_path}
56
+ --with-decryption
57
+ --recursive
58
+ --profile #{fetch(:aws_profile)}
59
+ #{'--debug' if debug?}
60
+ CMD
61
+
62
+ unless $CHILD_STATUS.success?
63
+ error! "Cannot fetch params from AWS... do you need to log in (use task aws:login)? For more info, add debug=true to command"
64
+ end
65
+
66
+ JSON.parse(output).dig('Parameters') || error!('There are no params in the response')
67
+ end
68
+
69
+ def default_params_path
70
+ ensure!(:cluster)
71
+
72
+ "/#{fetch(:cluster)}/"
73
+ end
@@ -21,7 +21,7 @@ end
21
21
 
22
22
  namespace :rails do
23
23
  desc <<~TXT
24
- Open rails console
24
+ Open Rails console
25
25
 
26
26
  Runs "bundle exec rails console" on the ECS container.
27
27
  TXT
@@ -40,3 +40,6 @@ namespace :rails do
40
40
  invoke 'ecs:exec', "tail -f log/#{fetch(:rails_env)}.log"
41
41
  end
42
42
  end
43
+
44
+ desc 'Alias for rails:console'
45
+ task :console => 'rails:console'
@@ -1,6 +1,7 @@
1
1
  require 'mina/default'
2
2
  require 'mina/infinum/ecs/rails'
3
3
  require 'mina/infinum/ecs/db'
4
+ require 'mina/infinum/ecs/params'
4
5
 
5
6
  # INFO: hides default Mina tasks when running "mina --tasks"
6
7
  Rake::Task['run'].clear_comments
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Infinum
3
- VERSION = '2.1.0'.freeze
3
+ VERSION = '2.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-infinum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stjepan Hadjic
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -145,6 +145,7 @@ files:
145
145
  - lib/mina/infinum/ecs/aws.rb
146
146
  - lib/mina/infinum/ecs/db.rb
147
147
  - lib/mina/infinum/ecs/ecs.rb
148
+ - lib/mina/infinum/ecs/params.rb
148
149
  - lib/mina/infinum/ecs/rails.rb
149
150
  - lib/mina/infinum/helpers.rb
150
151
  - lib/mina/infinum/tasks.rb
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  - !ruby/object:Gem::Version
170
171
  version: '0'
171
172
  requirements: []
172
- rubygems_version: 3.6.2
173
+ rubygems_version: 3.6.7
173
174
  specification_version: 4
174
175
  summary: Collection of mina plugins we use in infinum
175
176
  test_files: []