azure_info 0.1.0 → 0.1.1

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: f54bada299a0f5e98838be7c05dab9de5d7c721f1a4934a1f08a2a94c9d15f2c
4
- data.tar.gz: 7e946eddcb904a1f352e50a8f1a7ca709263dd4b9343eb25fae4150d18602b6f
3
+ metadata.gz: '08572df2ac88f55e30953102b474fdc5bf73335d969a07a1648eeea184292fce'
4
+ data.tar.gz: 906aba07a7070e7723ff509d29dfd31326111d57b2b17f6eec959fe3212c384d
5
5
  SHA512:
6
- metadata.gz: 1e3f1049ebcae5a4ec412a1e65f9df3245cfcecd9704a3eaedf9eb75351f813ac3f8a2c9a672720ae24ff8d25cff94b80fd14e1017445c0aecd8b0ac5eead993
7
- data.tar.gz: 1d49d741021fdda2b73a70544dda901f4856e1a0a613edbcd77f7cfa64f3ec7cc177bcf9e554ef94f8c88aef2b54f7c8a50d669337296b13d77feb8e05e90f0d
6
+ metadata.gz: d3a57a19786c6b412838cd6426ce4d30f1ea2e7406947d991c5607b1356e2d9836711ac2f78f8b2fa0591d5eaa18535caaaffb0ff5199d530d1714fc6c1848b4
7
+ data.tar.gz: b8cf86bf3740b9b08c964d36b9628f9cd23537fb6e67b689148e259b1e3d91534886e3ac2d5f9264ce97ca9e484fde3d7a9afb6c0b8d50a4c71aa6682622d0ff
@@ -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
- Simple library to get current gcp data like subscription_id, tenant_id, group, and location.
3
+ [![Gem Version](https://badge.fury.io/rb/azure_info.svg)](https://badge.fury.io/rb/azure_info)
4
+
5
+ [![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](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=useast group=RESOURCE_GROUP
43
+ az configure --defaults location=eastus group=RESOURCE_GROUP
40
44
 
41
45
  ## Contributing
42
46
 
@@ -13,7 +13,7 @@ module AzureInfo
13
13
  alias_method :group_id, :group
14
14
 
15
15
  def location
16
- configure.get("location") || "useast"
16
+ configure.get("location") || "eastus"
17
17
  end
18
18
 
19
19
  def subscription_id
@@ -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
- out = `az account show --output json`.strip
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
@@ -1,3 +1,3 @@
1
1
  module AzureInfo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-03 00:00:00.000000000 Z
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