firespring_dev_commands 2.3.0.pre.alpha.2 → 2.3.2

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: 0bdbb0bfa35836490090703ca0c1fc24367de88d4d6539ee09b3424090d4c46f
4
- data.tar.gz: 7a2838eaf1a764e643c8290bb7d921cac80d042b21f9ba2cf697af9f737f3065
3
+ metadata.gz: '0649c081bc238700de0be77cfc4741fe6c3fd4eb5f02e3aa3ceaba82e0bd69c9'
4
+ data.tar.gz: cdbac96b5493439811afa9b11e03156d6980b81b8db83aec3e7cc27cf697cdd0
5
5
  SHA512:
6
- metadata.gz: 163658ffa6d4a2b493abe51905aae489ec1955670f6bfc0da65cf81802cfa08a5b833b732d966a0e2f74fd454817c7086cbabfbf3d3998cc51619218cfde5f49
7
- data.tar.gz: 8e107996750229780c086c3cf40d54ce996d25d84d662193575851e2f04a625469d9e8e163c38d4395034ffbb7fe6d61e7754bd8cc027b7508adbbd96ff016c2
6
+ metadata.gz: 671bbd36642608a0068af882e56a15897acdf8150bcd0d92086ed9ab09fc73641366bcfd534db7a7552f513bca11666113ad5e1b33337585f287535fd60887b5
7
+ data.tar.gz: f95cae18a8681a4c19586a3a7b40f3ec5e92a873672a23458c31bbe9e28cd1d0aaa83b4028a7b6a46b7d587b8dd74274eb303ecb9e30174ae2c513507d828522
@@ -61,15 +61,15 @@ module Dev
61
61
  puts " Logging in to #{account} in #{region} as #{role}".light_yellow
62
62
  puts
63
63
 
64
- code = ENV['AWS_TOKEN_CODE'] || Dev::Common.new.ask("Enter the MFA code for the #{ENV.fetch('USERNAME', 'no_username_found')} user serial #{serial}")
64
+ code = mfa_code(serial)
65
65
  raise 'MFA is required' unless code.to_s.strip
66
66
 
67
67
  sts = ::Aws::STS::Client.new(profile: 'default', region:)
68
68
  creds = sts.assume_role(
69
- serial_number: serial,
69
+ serial_number: mfa_serial || serial,
70
70
  role_arn: role,
71
71
  role_session_name: session_name,
72
- token_code: code,
72
+ token_code: code.to_s.strip,
73
73
  duration_seconds: session_duration
74
74
  ).credentials
75
75
  puts
@@ -77,6 +77,32 @@ module Dev
77
77
  Dev::Aws::Credentials.new.write!(account, creds)
78
78
  end
79
79
 
80
+ # The custom local file where target information is stored.
81
+ CUSTOM_CONFIG_FILE = "#{Dir.home}/.bash_profile.d/config/.main".freeze
82
+
83
+ # Targets a custom ini config.
84
+ def custom_config_ini
85
+ IniFile.new(filename: CUSTOM_CONFIG_FILE, default: 'default')['default']
86
+ end
87
+
88
+ def mfa_serial
89
+ return unless !ENV.fetch('OP_LOGIN', nil).nil? && File.exist?(CUSTOM_CONFIG_FILE)
90
+
91
+ custom_config_ini['aws_1pass_mfa_serial']
92
+ end
93
+
94
+ # Handles the MFA code logic.
95
+ def mfa_code(serial)
96
+ # Note, OP_LOGIN likely not needed. Available as feature flag.
97
+ # Checks if OnePassword CLI is installed and the custom config file exist.
98
+ if !ENV.fetch('OP_LOGIN', nil).nil? && system('op --version', out: '/dev/null') && File.exist?(CUSTOM_CONFIG_FILE)
99
+ cmd = "op item get #{custom_config_ini['aws_uuid']} --otp"
100
+ `#{cmd}`
101
+ else
102
+ ENV['AWS_TOKEN_CODE'] || Dev::Common.new.ask("Enter the MFA code for the #{ENV.fetch('USERNAME', 'no_username_found')} user serial #{serial}")
103
+ end
104
+ end
105
+
80
106
  # Returns the config ini file
81
107
  # Runs the setup for our current account if it's not already setup
82
108
  def setup_cfgini(account)
@@ -88,8 +114,8 @@ module Dev
88
114
  cfgini
89
115
  end
90
116
 
91
- # Authroizes the docker cli to pull/push images from the Aws container registry (e.g. if docker compose needs to pull an image)
92
- # Authroizes the docker ruby library to pull/push images from the Aws container registry
117
+ # Authorizes the docker cli to pull/push images from the Aws container registry (e.g. if docker compose needs to pull an image)
118
+ # Authorizes the docker ruby library to pull/push images from the Aws container registry
93
119
  def registry_logins!(registry_ids: nil, region: nil)
94
120
  registry_ids ||= Dev::Aws::Account.new.ecr_registry_ids
95
121
  region ||= Dev::Aws::Credentials.new.logged_in_region || Dev::Aws::DEFAULT_REGION
@@ -100,8 +126,8 @@ module Dev
100
126
  puts
101
127
  end
102
128
 
103
- # Authroizes the docker cli to pull/push images from the Aws container registry (e.g. if docker compose needs to pull an image)
104
- # Authroizes the docker ruby library to pull/push images from the Aws container registry
129
+ # Authorizes the docker cli to pull/push images from the Aws container registry (e.g. if docker compose needs to pull an image)
130
+ # Authorizes the docker ruby library to pull/push images from the Aws container registry
105
131
  def registry_login!(registry_id: nil, region: nil)
106
132
  registry_id ||= Dev::Aws::Account.new.ecr_registry_ids.first
107
133
  region ||= Dev::Aws::Credentials.new.logged_in_region || Dev::Aws::DEFAULT_REGION
@@ -116,7 +142,7 @@ module Dev
116
142
  ENV['ECR_REGISTRY'] ||= registry
117
143
  end
118
144
 
119
- # Authroizes the docker cli to pull/push images from the Aws container registry
145
+ # Authorizes the docker cli to pull/push images from the Aws container registry
120
146
  # (e.g. if docker compose needs to pull an image)
121
147
  # @deprecated Please use {Dev::Aws::Login#registry_login!} instead
122
148
  def docker_login!(registry_id: nil, region: nil)
@@ -127,7 +153,7 @@ module Dev
127
153
  puts
128
154
  end
129
155
 
130
- # Authroizes the docker cli to pull/push images from the Aws container registry
156
+ # Authorizes the docker cli to pull/push images from the Aws container registry
131
157
  # (e.g. if docker compose needs to pull an image)
132
158
  private def docker_cli_login!(registry:, region:)
133
159
  print(" Logging in to #{registry} in docker... ")
@@ -137,7 +163,7 @@ module Dev
137
163
  Dev::Common.new.run_command([login_cmd])
138
164
  end
139
165
 
140
- # Authroizes the docker ruby library to pull/push images from the Aws container registry
166
+ # Authorizes the docker ruby library to pull/push images from the Aws container registry
141
167
  # @deprecated Please use {Dev::Aws::Login#registry_login!} instead
142
168
  def ecr_login!(registry_id: nil, region: nil)
143
169
  registry_id ||= Dev::Aws::Account.new.ecr_registry_ids.first
@@ -146,7 +172,7 @@ module Dev
146
172
  docker_lib_login!(registry_id:, region:)
147
173
  end
148
174
 
149
- # Authroizes the docker ruby library to pull/push images from the Aws container registry
175
+ # Authorizes the docker ruby library to pull/push images from the Aws container registry
150
176
  private def docker_lib_login!(registry_id:, region:)
151
177
  # Grab your authentication token from AWS ECR
152
178
  ecr_client = ::Aws::ECR::Client.new(region:)
@@ -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.3.0.pre.alpha.2'.freeze
9
+ VERSION = '2.3.2'.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.3.0.pre.alpha.2
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-11 00:00:00.000000000 Z
11
+ date: 2024-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -475,9 +475,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
475
475
  version: '3.1'
476
476
  required_rubygems_version: !ruby/object:Gem::Requirement
477
477
  requirements:
478
- - - ">"
478
+ - - ">="
479
479
  - !ruby/object:Gem::Version
480
- version: 1.3.1
480
+ version: '0'
481
481
  requirements: []
482
482
  rubygems_version: 3.4.10
483
483
  signing_key: