firespring_dev_commands 2.2.9.pre.alpha.0 → 2.3.0.pre.alpha.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778ff67e973ecdf910d950b09b6eaae4115696dd611d40681edf117056df6785
|
4
|
+
data.tar.gz: cee645397957dcdba5122f3d569cc5800a70b4c6e4695010acd931dba83092d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77939ad333d8c4ac77623c165ca0541d225361276ac3411dc769cd4dbd469b3543a0b255ce92ba1d8d89a019942f0b0aa6266ffa13321454ae42d6a786592a9d
|
7
|
+
data.tar.gz: 0a86f1791da0270e490ce8fd0cbe6d81ca4fce991db527e900f6ccfbe9aae157bb16177a3ca285ee389c563cf6c2cf7396862e2d14f1e941cf679d77aeaaaf0f
|
@@ -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_branch: nil)
|
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: default_branch, dir: project_dir)
|
198
198
|
puts Dev::Common.new.center_pad.light_green
|
199
199
|
end
|
200
200
|
puts
|
@@ -205,7 +205,7 @@ module Dev
|
|
205
205
|
# Checks out the given branch in the given repo
|
206
206
|
# Defaults to the current directory
|
207
207
|
# optionally raise errors
|
208
|
-
def checkout(branch, dir: default_project_dir, raise_errors: false)
|
208
|
+
def checkout(branch, default: nil, dir: default_project_dir, raise_errors: false)
|
209
209
|
raise 'branch is required' if branch.to_s.strip.empty?
|
210
210
|
return unless File.exist?(dir)
|
211
211
|
|
@@ -218,7 +218,7 @@ module Dev
|
|
218
218
|
# If the branch we are checking out doesn't exist, check out either the staging branch or the main branch
|
219
219
|
actual_branch = branch
|
220
220
|
unless branch_exists?(dir, branch)
|
221
|
-
actual_branch = [staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
221
|
+
actual_branch = [default, staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
|
222
222
|
puts "Branch #{branch} not found, checking out #{actual_branch} instead".light_yellow
|
223
223
|
end
|
224
224
|
|
@@ -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_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.1
|
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-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|