azure_info 0.1.0 → 0.1.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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +6 -2
- data/lib/azure_info.rb +1 -1
- data/lib/azure_info/account.rb +31 -1
- data/lib/azure_info/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08572df2ac88f55e30953102b474fdc5bf73335d969a07a1648eeea184292fce'
|
4
|
+
data.tar.gz: 906aba07a7070e7723ff509d29dfd31326111d57b2b17f6eec959fe3212c384d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3a57a19786c6b412838cd6426ce4d30f1ea2e7406947d991c5607b1356e2d9836711ac2f78f8b2fa0591d5eaa18535caaaffb0ff5199d530d1714fc6c1848b4
|
7
|
+
data.tar.gz: b8cf86bf3740b9b08c964d36b9628f9cd23537fb6e67b689148e259b1e3d91534886e3ac2d5f9264ce97ca9e484fde3d7a9afb6c0b8d50a4c71aa6682622d0ff
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
|
+
|
6
|
+
## [0.1.1]
|
7
|
+
- fix default location
|
8
|
+
- provide friendly error message when az not returning json
|
9
|
+
|
10
|
+
## [0.1.0]
|
11
|
+
- Initial release.
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# AzureInfo
|
2
2
|
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/azure_info)
|
4
|
+
|
5
|
+
[](https://www.boltops.com)
|
6
|
+
|
7
|
+
Simple library to get current Azure info like subscription_id, tenant_id, group, and location.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -36,7 +40,7 @@ This tool calls out to the az CLI. So the az CLI is required.
|
|
36
40
|
az login --username EMAIL_ADDRESS -t TENANT_ID
|
37
41
|
az account set --subscription SUBSCRIPTION_ID
|
38
42
|
|
39
|
-
az configure --defaults location=
|
43
|
+
az configure --defaults location=eastus group=RESOURCE_GROUP
|
40
44
|
|
41
45
|
## Contributing
|
42
46
|
|
data/lib/azure_info.rb
CHANGED
data/lib/azure_info/account.rb
CHANGED
@@ -8,8 +8,38 @@ module AzureInfo
|
|
8
8
|
def az_account_show
|
9
9
|
return @az_account_show if @az_account_show
|
10
10
|
check_az_installed!
|
11
|
-
|
11
|
+
|
12
|
+
command = "az account show --output json"
|
13
|
+
out = `#{command}`.strip
|
14
|
+
|
15
|
+
raise_status_error(command) unless $?.success?
|
16
|
+
raise_empty_error(command) if out.strip == ""
|
17
|
+
|
12
18
|
@az_account_show = JSON.load(out)
|
13
19
|
end
|
20
|
+
|
21
|
+
def raise_status_error(command)
|
22
|
+
message =<<~EOL
|
23
|
+
ERROR: error running '#{command}'.
|
24
|
+
Maybe you havent ran `az login` or configured ~/.azure manually.
|
25
|
+
You can configure az login non-interactively with
|
26
|
+
|
27
|
+
az login --service-principal \
|
28
|
+
--username USERNAME \
|
29
|
+
--password PASSWORD \
|
30
|
+
--tenant TENANT
|
31
|
+
|
32
|
+
Per https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#sign-in-using-a-service-principal
|
33
|
+
EOL
|
34
|
+
raise Error.new(message)
|
35
|
+
end
|
36
|
+
|
37
|
+
def raise_empty_error(command)
|
38
|
+
message =<<~EOL
|
39
|
+
The '#{command}' return a blank string.
|
40
|
+
Something went wrong. Try running it manually and confirm it returns json.
|
41
|
+
EOL
|
42
|
+
raise Error.new(message)
|
43
|
+
end
|
14
44
|
end
|
15
45
|
end
|
data/lib/azure_info/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -19,6 +19,7 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
21
|
- ".rspec"
|
22
|
+
- CHANGELOG.md
|
22
23
|
- Gemfile
|
23
24
|
- LICENSE.txt
|
24
25
|
- README.md
|