firespring_dev_commands 2.3.0.pre.alpha.2 → 2.3.1
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: dcc3db9cef00a1d1fc8df7b3e37156e1bf4bf2c1b4e609af6b493ffe73eb8c8e
|
4
|
+
data.tar.gz: cd49faeb589c8a0344351b37bfd717dd3f78a173091f651468fac148a05c00cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa84cbf2a6bd1d7ba4dffac839e2f8c01536f0321bd104916909283a85720038457a8cbff3acd7c4acafb38e0cdd0c1ff4c5dcf97a6f87c57bddd06ac8d9b0c
|
7
|
+
data.tar.gz: de18614349ca0a9f4fdde9318f6f0bc55e66f7cdd338aeed854873a7b1edb191c2c55f72f5a99147c3a89aa6b2638de40cd01c3785cd0ae4a863f457de53783f
|
@@ -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 =
|
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
|
-
#
|
92
|
-
#
|
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
|
-
#
|
104
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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:)
|
@@ -185,7 +185,7 @@ module Dev
|
|
185
185
|
end
|
186
186
|
|
187
187
|
# Checks out the given branch in all repositories with some additional formatting
|
188
|
-
def checkout_all(branch
|
188
|
+
def checkout_all(branch)
|
189
189
|
@success = true
|
190
190
|
puts
|
191
191
|
puts "Checking out #{branch} in each repo".light_yellow if project_dirs.length > 1
|
@@ -194,7 +194,7 @@ module Dev
|
|
194
194
|
|
195
195
|
repo_basename = File.basename(File.realpath(project_dir))
|
196
196
|
puts Dev::Common.new.center_pad(repo_basename).light_green
|
197
|
-
@success &= checkout(branch,
|
197
|
+
@success &= checkout(branch, dir: project_dir)
|
198
198
|
puts Dev::Common.new.center_pad.light_green
|
199
199
|
end
|
200
200
|
puts
|
@@ -203,10 +203,9 @@ module Dev
|
|
203
203
|
end
|
204
204
|
|
205
205
|
# Checks out the given branch in the given repo
|
206
|
-
# If the given branch isn't found, falls back to default branch, then staging, then main
|
207
206
|
# Defaults to the current directory
|
208
207
|
# optionally raise errors
|
209
|
-
def checkout(branch,
|
208
|
+
def checkout(branch, dir: default_project_dir, raise_errors: false)
|
210
209
|
raise 'branch is required' if branch.to_s.strip.empty?
|
211
210
|
return unless File.exist?(dir)
|
212
211
|
|
@@ -216,11 +215,10 @@ module Dev
|
|
216
215
|
g = ::Git.open(dir)
|
217
216
|
g.fetch('origin', prune: true)
|
218
217
|
|
219
|
-
# If the branch we are checking out doesn't exist,
|
220
|
-
# check out either the default branch, staging branch, or the main branch
|
218
|
+
# If the branch we are checking out doesn't exist, check out either the staging branch or the main branch
|
221
219
|
actual_branch = branch
|
222
220
|
unless branch_exists?(dir, branch)
|
223
|
-
actual_branch = [
|
221
|
+
actual_branch = [staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
224
222
|
puts "Branch #{branch} not found, checking out #{actual_branch} instead".light_yellow
|
225
223
|
end
|
226
224
|
|
@@ -31,15 +31,13 @@ module Dev
|
|
31
31
|
return if exclude.include?(:checkout)
|
32
32
|
|
33
33
|
desc 'Checks out a branch for each repo (alias: git:co)' \
|
34
|
-
"\n\tuse BRANCH=abc123 to specify the branch of code you
|
35
|
-
"\n\
|
36
|
-
"\n\tIf branch and default do not exist, the configured staging or main branch will be checked out"
|
34
|
+
"\n\tuse BRANCH=abc123 to specify the branch of code you with to switch to (required)" \
|
35
|
+
"\n\tIf the branch does not exist, the configured staging or main branch will be checked out"
|
37
36
|
task checkout: %w(init) do
|
38
37
|
branch = ENV['BRANCH'].to_s.strip
|
39
|
-
default = ENV['DEFAULT'].to_s.strip
|
40
38
|
raise 'branch is required' if branch.empty?
|
41
39
|
|
42
|
-
Dev::Git.new.checkout_all(branch
|
40
|
+
Dev::Git.new.checkout_all(branch)
|
43
41
|
end
|
44
42
|
|
45
43
|
task co: %w(init checkout) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
@@ -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:
|
480
|
+
version: '0'
|
481
481
|
requirements: []
|
482
482
|
rubygems_version: 3.4.10
|
483
483
|
signing_key:
|