firespring_dev_commands 2.2.9.pre.alpha.0 → 2.3.0.pre.alpha.2
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: 0bdbb0bfa35836490090703ca0c1fc24367de88d4d6539ee09b3424090d4c46f
|
4
|
+
data.tar.gz: 7a2838eaf1a764e643c8290bb7d921cac80d042b21f9ba2cf697af9f737f3065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163658ffa6d4a2b493abe51905aae489ec1955670f6bfc0da65cf81802cfa08a5b833b732d966a0e2f74fd454817c7086cbabfbf3d3998cc51619218cfde5f49
|
7
|
+
data.tar.gz: 8e107996750229780c086c3cf40d54ce996d25d84d662193575851e2f04a625469d9e8e163c38d4395034ffbb7fe6d61e7754bd8cc027b7508adbbd96ff016c2
|
@@ -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 = ENV['AWS_TOKEN_CODE'] || Dev::Common.new.ask("Enter the MFA code for the #{ENV.fetch('USERNAME', 'no_username_found')} user serial #{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:
|
69
|
+
serial_number: serial,
|
70
70
|
role_arn: role,
|
71
71
|
role_session_name: session_name,
|
72
|
-
token_code: code
|
72
|
+
token_code: code,
|
73
73
|
duration_seconds: session_duration
|
74
74
|
).credentials
|
75
75
|
puts
|
@@ -77,32 +77,6 @@ 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
|
-
|
106
80
|
# Returns the config ini file
|
107
81
|
# Runs the setup for our current account if it's not already setup
|
108
82
|
def setup_cfgini(account)
|
@@ -114,8 +88,8 @@ module Dev
|
|
114
88
|
cfgini
|
115
89
|
end
|
116
90
|
|
117
|
-
#
|
118
|
-
#
|
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
|
119
93
|
def registry_logins!(registry_ids: nil, region: nil)
|
120
94
|
registry_ids ||= Dev::Aws::Account.new.ecr_registry_ids
|
121
95
|
region ||= Dev::Aws::Credentials.new.logged_in_region || Dev::Aws::DEFAULT_REGION
|
@@ -126,8 +100,8 @@ module Dev
|
|
126
100
|
puts
|
127
101
|
end
|
128
102
|
|
129
|
-
#
|
130
|
-
#
|
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
|
131
105
|
def registry_login!(registry_id: nil, region: nil)
|
132
106
|
registry_id ||= Dev::Aws::Account.new.ecr_registry_ids.first
|
133
107
|
region ||= Dev::Aws::Credentials.new.logged_in_region || Dev::Aws::DEFAULT_REGION
|
@@ -142,7 +116,7 @@ module Dev
|
|
142
116
|
ENV['ECR_REGISTRY'] ||= registry
|
143
117
|
end
|
144
118
|
|
145
|
-
#
|
119
|
+
# Authroizes the docker cli to pull/push images from the Aws container registry
|
146
120
|
# (e.g. if docker compose needs to pull an image)
|
147
121
|
# @deprecated Please use {Dev::Aws::Login#registry_login!} instead
|
148
122
|
def docker_login!(registry_id: nil, region: nil)
|
@@ -153,7 +127,7 @@ module Dev
|
|
153
127
|
puts
|
154
128
|
end
|
155
129
|
|
156
|
-
#
|
130
|
+
# Authroizes the docker cli to pull/push images from the Aws container registry
|
157
131
|
# (e.g. if docker compose needs to pull an image)
|
158
132
|
private def docker_cli_login!(registry:, region:)
|
159
133
|
print(" Logging in to #{registry} in docker... ")
|
@@ -163,7 +137,7 @@ module Dev
|
|
163
137
|
Dev::Common.new.run_command([login_cmd])
|
164
138
|
end
|
165
139
|
|
166
|
-
#
|
140
|
+
# Authroizes the docker ruby library to pull/push images from the Aws container registry
|
167
141
|
# @deprecated Please use {Dev::Aws::Login#registry_login!} instead
|
168
142
|
def ecr_login!(registry_id: nil, region: nil)
|
169
143
|
registry_id ||= Dev::Aws::Account.new.ecr_registry_ids.first
|
@@ -172,7 +146,7 @@ module Dev
|
|
172
146
|
docker_lib_login!(registry_id:, region:)
|
173
147
|
end
|
174
148
|
|
175
|
-
#
|
149
|
+
# Authroizes the docker ruby library to pull/push images from the Aws container registry
|
176
150
|
private def docker_lib_login!(registry_id:, region:)
|
177
151
|
# Grab your authentication token from AWS ECR
|
178
152
|
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, default)
|
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, dir: project_dir)
|
197
|
+
@success &= checkout(branch, default, dir: project_dir)
|
198
198
|
puts Dev::Common.new.center_pad.light_green
|
199
199
|
end
|
200
200
|
puts
|
@@ -203,9 +203,10 @@ 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
|
206
207
|
# Defaults to the current directory
|
207
208
|
# optionally raise errors
|
208
|
-
def checkout(branch, dir: default_project_dir, raise_errors: false)
|
209
|
+
def checkout(branch, default, dir: default_project_dir, raise_errors: false)
|
209
210
|
raise 'branch is required' if branch.to_s.strip.empty?
|
210
211
|
return unless File.exist?(dir)
|
211
212
|
|
@@ -215,10 +216,11 @@ module Dev
|
|
215
216
|
g = ::Git.open(dir)
|
216
217
|
g.fetch('origin', prune: true)
|
217
218
|
|
218
|
-
# If the branch we are checking out doesn't exist,
|
219
|
+
# If the branch we are checking out doesn't exist,
|
220
|
+
# check out either the default branch, staging branch, or the main branch
|
219
221
|
actual_branch = branch
|
220
222
|
unless branch_exists?(dir, branch)
|
221
|
-
actual_branch = [staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
223
|
+
actual_branch = [default, staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
222
224
|
puts "Branch #{branch} not found, checking out #{actual_branch} instead".light_yellow
|
223
225
|
end
|
224
226
|
|
@@ -31,13 +31,15 @@ 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\
|
34
|
+
"\n\tuse BRANCH=abc123 to specify the branch of code you wish to switch to (required)" \
|
35
|
+
"\n\tuse DEFAULT=abc456 to specify the branch of code to fall back to" \
|
36
|
+
"\n\tIf branch and default do not exist, the configured staging or main branch will be checked out"
|
36
37
|
task checkout: %w(init) do
|
37
38
|
branch = ENV['BRANCH'].to_s.strip
|
39
|
+
default = ENV['DEFAULT'].to_s.strip
|
38
40
|
raise 'branch is required' if branch.empty?
|
39
41
|
|
40
|
-
Dev::Git.new.checkout_all(branch)
|
42
|
+
Dev::Git.new.checkout_all(branch, default)
|
41
43
|
end
|
42
44
|
|
43
45
|
task co: %w(init checkout) do
|
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.
|
4
|
+
version: 2.3.0.pre.alpha.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-11
|
11
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|