cloudstrap-azure 0.4.13.pre → 0.5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf4a3f1537b5d2c7bbab41fb4b3c32228ac92bba385d2111b857a388388d6f2f
4
- data.tar.gz: 97be7e2baf85259063e966ea75598608f2ecf17dbab74277cf9185c2c0f1b962
3
+ metadata.gz: 066f8b2d9a48ffff68c8ff9b2ad849020cb69d43c75b9ed0b08a35d9f976c305
4
+ data.tar.gz: e7787cf84a74a2e27e9c69158bcb72a543ff33254d1fd81aebf58cc4eb5b366d
5
5
  SHA512:
6
- metadata.gz: b831640b78716c3e56d4ae4453a891f45ad62041c9993fdef662165d0b3cc09ee9a0b78dd0819f263943e816e1215aa58adcda08b1e533944c44cd9b74e9edec
7
- data.tar.gz: 72fa83ab526ac70acaa457ccf5d03e2e74a37086f3f7e4b56194e3f7d0991b4e577a3687f1d0eefd67266706fc397e1ea68944c699a1142a6d8c2a23c8a4e608
6
+ metadata.gz: b7d0015456d7096c04a330292a5a9258994ae90df2709f29e81ee331c85f146e70fbb8457613f04c2ceb8080a10889d0be494a80d2ca8106fe172fc89d2db124
7
+ data.tar.gz: 2417e01b9edb67eaf0fc5abfec56fe1941620b6d9abfb878db24e5c3a56054a1528d754254dbd71f4c313a5af812278d4a7dab74ad57b2b7bd88e70ed88fb9ac
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,13 +1,134 @@
1
1
  #! /usr/bin/env ruby
2
2
  # -*- ruby -*-
3
3
 
4
+ require 'optparse' # Ruby Standard Library
5
+
6
+ require 'pastel' # MIT License
7
+
8
+ #############
9
+ # Constants #
10
+ #############
11
+
12
+ INTERNAL_COMMAND_PATH = File.expand_path(File.join(__dir__, 'internal'))
13
+ LICENSE_FILE = File.expand_path(File.join(__dir__, '..', 'LICENSE.txt'))
14
+ PROGRAM = File.basename($PROGRAM_NAME)
15
+ SPDX_LICENSE_IDENTIFIER = 'MIT'
16
+
17
+ ####################
18
+ # Helper Functions #
19
+ ####################
20
+
21
+ Bold = ->(string) { Pastel.new.bold(string) }
22
+ Red = ->(string) { Pastel.new.red(string) }
23
+ ExitAfterPrinting = ->(message) { puts(message); exit }
24
+
25
+ def commands
26
+ if RUBY_VERSION >= '2.5.0'
27
+ Dir.children(INTERNAL_COMMAND_PATH)
28
+ else
29
+ Dir.entries(INTERNAL_COMMAND_PATH).reject do |entry|
30
+ %w(. ..).include? entry
31
+ end
32
+ end.map do |command|
33
+ command.gsub Regexp.new("^#{PROGRAM}."), ''
34
+ end
35
+ end
36
+
37
+ ###################
38
+ # Option Handling #
39
+ ###################
40
+
41
+ options = {}
42
+
43
+ OptionParser.new do |opts|
44
+ opts.banner = "#{PROGRAM} [options] <command>"
45
+ opts.on('--available-commands') { ExitAfterPrinting.(commands) }
46
+ opts.on('--guide') do
47
+ ExitAfterPrinting.("
48
+ Welcome to #{Bold.(PROGRAM)}!
49
+
50
+ This program automates Azure Container Service deployments.
51
+
52
+ The first thing you should do is log in to Azure (this only needs to be done
53
+ once under normal operating conditions):
54
+
55
+ #{Bold.('az login')}
56
+
57
+ Once you have successfully logged in, you can use the #{Bold.('environment')}
58
+ command to get a fresh set of tokens at any time. Given no arguments, this will
59
+ print some JSON to STDOUT that includes access tokens. This is intended for use
60
+ in scripts.
61
+
62
+ #{Bold.(PROGRAM + ' environment')}
63
+
64
+ If you provide additional arguments to the #{Bold.('environment')} command, the
65
+ access tokens will be added to the environment, and the program
66
+ will #{Bold.('exec')} into the remaining arguments. This is intended for
67
+ programs that read from environment.
68
+
69
+ #{Bold.(PROGRAM + ' environment -- env')}
70
+
71
+ The rest of #{Bold.(PROGRAM)} assumes that access tokens will be available in
72
+ the environment.
73
+
74
+ The next step is to configure #{Bold.(PROGRAM)}! The #{Bold.('configure')}
75
+ command provides a simple way to do this interactively. This is generally a
76
+ one-time process, but you can safely run it multiple times. It will read the
77
+ current configuration and only change the things you tell it to.
78
+
79
+ #{Bold.(PROGRAM + ' environment -- ' + PROGRAM + ' configure')}
80
+
81
+ Once the program is configured, it's time to deploy things!
82
+ The #{Bold.('deploy')} command takes care of this. Like #{Bold.('configure')},
83
+ it is safe to run multiple times.
84
+
85
+ #{Bold.(PROGRAM + ' environment -- ' + PROGRAM + ' deploy')}
86
+
87
+ That's it! If you've made it this far, you should have a working ACS deployment.
88
+
89
+ Thanks for using #{Bold.(PROGRAM)}!
90
+
91
+ ")
92
+ end
93
+
94
+ opts.on('--workaround-linux-shebang-limitations') do
95
+ # https://lists.gnu.org/archive/html/bug-sh-utils/2002-04/msg00020.html
96
+ options[:workaround_linux_shebang_limitations] = true
97
+ end
98
+ opts.on('--spdx-license-identifier') { ExitAfterPrinting.(SPDX_LICENSE_IDENTIFIER) }
99
+ opts.on('--full-license-text') { ExitAfterPrinting.(File.read(LICENSE_FILE) + "\n") }
100
+ end.parse!
101
+
102
+ #################
103
+ # Sanity Checks #
104
+ #################
105
+
106
+ exit Errno::EINVAL::Errno if ARGV.empty?
107
+
108
+ options[:workaround_linux_shebang_limitations] ||= (RbConfig::CONFIG['arch'] =~ /linux/) ? true : false
109
+
110
+ ################
111
+ # Main Program #
112
+ ################
113
+
114
+ COMMAND = ARGV.shift
115
+
4
116
  PATH = ENV['PATH'] = [
5
- File.expand_path(File.join(__dir__, 'internal')),
117
+ INTERNAL_COMMAND_PATH,
6
118
  ENV['PATH']
7
119
  ].join(':')
8
120
 
9
- PROGRAM = File.basename($PROGRAM_NAME)
10
-
11
- abort unless (COMMAND = ARGV.shift)
121
+ begin
122
+ if options[:workaround_linux_shebang_limitations]
123
+ INTERNAL_COMMAND = File.join(INTERNAL_COMMAND_PATH, "#{PROGRAM}.#{COMMAND}")
124
+ raise Errno::ENOENT unless File.exist? INTERNAL_COMMAND
125
+ exec(RbConfig.ruby, '-W0', INTERNAL_COMMAND)
126
+ else
127
+ exec({ 'PATH' => PATH }, "#{PROGRAM}.#{COMMAND}", *ARGV)
128
+ end
12
129
 
13
- exec({ 'PATH' => PATH }, "#{PROGRAM}.#{COMMAND}", *ARGV)
130
+ rescue Errno::ENOENT
131
+ STDERR.puts Red.("#{Bold.(COMMAND)} does not seem to be a valid command. Try this:\n")
132
+ STDERR.puts Bold.("#{PROGRAM} --available-commands\n")
133
+ exit Errno::ENOENT::Errno
134
+ end
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.4.13.pre
4
+ version: 0.5.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Olstrom
@@ -34,7 +34,7 @@ cert_chain:
34
34
  EIKh6yDoB+oCRuiTV0uw/lKE2PtbONhJb7uN1qhZqla/iBpmUjiEu8+skI+ygv9n
35
35
  7Krw8FJrV3+VRCiZTPKHeshAfL9yeIZh
36
36
  -----END CERTIFICATE-----
37
- date: 2018-04-19 00:00:00.000000000 Z
37
+ date: 2018-04-20 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: azure_graph_rbac
metadata.gz.sig CHANGED
Binary file