cloudstrap-azure 0.5.6.pre → 0.5.15.pre
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/cloudstrap-azure.gemspec +1 -0
- data/command/internal/cloudstrap-azure.deploy +52 -5
- metadata +21 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31c1a9b980c4b5659876b4354b43847d543c92c626333e10c13874b3bba00195
|
4
|
+
data.tar.gz: 51d7bfe159eef2bd2820c0dd7306d71b272839441eabccb2449e1778556c3e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b959d43035b914283995abd2b99fb78f309246ec134b3e247d97b7b7cd4a0aad5ddd15f347112d3eaa605f865415466b26986ec86a95d732310d5b674260634
|
7
|
+
data.tar.gz: 5c2de399b756aa3e6a70030f8d9f568a8ab09a42c2b3e39f1dc53bc3b690808904c7d69b3a74c3f166c0e063562940edd6d7936e772eebd45b6736377ecb28ee
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/cloudstrap-azure.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_runtime_dependency 'chamber', '~> 2.12', '>= 2.12.0'
|
31
31
|
gem.add_runtime_dependency 'chronic', '~> 0.10', '>= 0.10.0'
|
32
32
|
gem.add_runtime_dependency 'concurrent-ruby', '~> 1.0', '>= 1.0.5'
|
33
|
+
gem.add_runtime_dependency 'facets', '~> 3.1', '>= 3.1.0'
|
33
34
|
gem.add_runtime_dependency 'pastel', '~> 0.7', '>= 0.7.0'
|
34
35
|
gem.add_runtime_dependency 'sshkey', '~> 1.9', '>= 1.9.0'
|
35
36
|
gem.add_runtime_dependency 'tty-prompt', '~> 0.16', '>= 0.16.0'
|
@@ -11,6 +11,7 @@ require 'azure_mgmt_container_service' # MIT License
|
|
11
11
|
require 'azure_mgmt_network' # MIT License
|
12
12
|
require 'azure_mgmt_resources' # MIT License
|
13
13
|
require 'chamber' # MIT License
|
14
|
+
require 'facets/string/snakecase' # BSD-2-Clause License
|
14
15
|
require 'concurrent' # MIT License
|
15
16
|
require 'pastel' # MIT License
|
16
17
|
require 'sshkey' # MIT License
|
@@ -138,7 +139,7 @@ Red = ->(string) { Pastel.new.red(string) }
|
|
138
139
|
Blue = ->(string) { Pastel.new.blue(string) }
|
139
140
|
|
140
141
|
UsageHelp = ->(method) {
|
141
|
-
[method.name,
|
142
|
+
[(method.respond_to?(:name) ? method.name : 'λ'),
|
142
143
|
method.parameters.map do |type, name|
|
143
144
|
case type
|
144
145
|
when :req then "<#{name}>"
|
@@ -158,6 +159,40 @@ UsageError = ->(method, exception) {
|
|
158
159
|
Blue.("#{Bold.('Usage')}: #{UsageHelp.(method)}"))
|
159
160
|
}
|
160
161
|
|
162
|
+
ParameterChunks = ->(string) {
|
163
|
+
chunks = string.snakecase.split('_')
|
164
|
+
1.upto(chunks.length).map { |n|
|
165
|
+
[chunks.take(n).map(&:capitalize).join, chunks.drop(n).join('_')]}}
|
166
|
+
|
167
|
+
WhatProvides = ->(parameter) {
|
168
|
+
parameter_chunks = ParameterChunks.(parameter)
|
169
|
+
Constants.(AzureAPI)
|
170
|
+
.select { |constant|constant.name =~ /::Models::/ }
|
171
|
+
.select { |constant| constant.is_a? Class }
|
172
|
+
.select { |model| parameter_chunks.any? { |class_name, instance_method_name|
|
173
|
+
(OwnClass.(model) == class_name) and model.instance_methods.include?(instance_method_name.to_sym)}}}
|
174
|
+
|
175
|
+
WhatAccepts = lambda do |object|
|
176
|
+
name = OwnClass.(object).snakecase
|
177
|
+
SERVICES
|
178
|
+
.flat_map(&MethodsReturningSiblings)
|
179
|
+
.map(&:call)
|
180
|
+
.flat_map(&AsyncableMethods).select do |method|
|
181
|
+
method.parameters.any? do |_, parameter|
|
182
|
+
parameter.to_s.start_with? name
|
183
|
+
end
|
184
|
+
end.group_by(&:owner).map { |owner, methods| [owner, methods.map(&:name)] }.to_h
|
185
|
+
end
|
186
|
+
|
187
|
+
UsageSummary = ->(object) {
|
188
|
+
WhatAccepts.(object).flat_map { |service, methods|
|
189
|
+
methods.map { |method| [
|
190
|
+
"#{AzureServiceName.(service)}::#{OwnClass.(service)}",
|
191
|
+
UsageHelp.(service.instance_method(method))]}}
|
192
|
+
.sort_by(&:last)
|
193
|
+
.sort_by(&:first)
|
194
|
+
.map { |service, operation| "#{service}##{operation}"}}
|
195
|
+
|
161
196
|
BindOperation = ->(namespace, operation) {
|
162
197
|
constant = FormatMethodName.(operation)
|
163
198
|
namespace.const_set(constant, operation)
|
@@ -461,11 +496,25 @@ AssociatePublicIP = ->(resource_group, network_interface, public_ip_address) {
|
|
461
496
|
network_interface.tap {
|
462
497
|
network_interface.ip_configurations[0].public_ipaddress = public_ip_address})}}
|
463
498
|
|
499
|
+
Purge = -> {
|
500
|
+
if resource_group = FindResourceGroup.(Chamber.env.identifier)
|
501
|
+
WhileSpinning.('Purge Resources') {
|
502
|
+
AzureAPI::Resource::ResourceGroups.delete(resource_group.name)}
|
503
|
+
end
|
504
|
+
if application = FindApplication.(Chamber.env.identifier)
|
505
|
+
if service_principal = FindServicePrincipal.(application)
|
506
|
+
WhileSpinning.('Purge Service Principal') {
|
507
|
+
AzureAPI::GraphRbac::ServicePrincipals.delete(service_principal.object_id)}
|
508
|
+
end
|
509
|
+
WhileSpinning.('Purge Application') {
|
510
|
+
AzureAPI::GraphRbac::Applications.delete(application.object_id)}
|
511
|
+
end}
|
512
|
+
|
464
513
|
################
|
465
514
|
# Main Program #
|
466
515
|
################
|
467
516
|
|
468
|
-
WhileSpinning.('Constructing Library') do
|
517
|
+
SERVICES = WhileSpinning.('Constructing Library') do
|
469
518
|
AzureAPI = Module.new
|
470
519
|
Constants
|
471
520
|
.(Azure)
|
@@ -478,11 +527,9 @@ WhileSpinning.('Constructing Library') do
|
|
478
527
|
.map(&ApplyIf.(Bindable.(:tenant_id), BindTenantID))
|
479
528
|
.map(&ApplyIf.(Bindable.(:subscription_id), BindSubscriptionID))
|
480
529
|
.each(&BindService.(AzureAPI))
|
481
|
-
|
482
|
-
AddInteractiveCalls.(AzureAPI)
|
530
|
+
.tap { AddInteractiveCalls.(AzureAPI) }
|
483
531
|
end
|
484
532
|
|
485
|
-
|
486
533
|
application = FindApplication.(Chamber.env.identifier) || CreateApplication.(Chamber.env.identifier)
|
487
534
|
service_principal = FindServicePrincipal.(application) || CreateServicePrincipal.(application)
|
488
535
|
role_definition = FindRoleDefinition.(Chamber.env.role_definition)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstrap-azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.15.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Olstrom
|
@@ -236,6 +236,26 @@ dependencies:
|
|
236
236
|
- - ">="
|
237
237
|
- !ruby/object:Gem::Version
|
238
238
|
version: 1.0.5
|
239
|
+
- !ruby/object:Gem::Dependency
|
240
|
+
name: facets
|
241
|
+
requirement: !ruby/object:Gem::Requirement
|
242
|
+
requirements:
|
243
|
+
- - "~>"
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '3.1'
|
246
|
+
- - ">="
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: 3.1.0
|
249
|
+
type: :runtime
|
250
|
+
prerelease: false
|
251
|
+
version_requirements: !ruby/object:Gem::Requirement
|
252
|
+
requirements:
|
253
|
+
- - "~>"
|
254
|
+
- !ruby/object:Gem::Version
|
255
|
+
version: '3.1'
|
256
|
+
- - ">="
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: 3.1.0
|
239
259
|
- !ruby/object:Gem::Dependency
|
240
260
|
name: pastel
|
241
261
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|