azure_info 0.1.2 → 0.1.3

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: d64fdf9124a081dfc9e90c33752a9306866babcfbfa969d1d6ae07acacd44533
4
- data.tar.gz: fd3e22f714b79af5761095ae4202db4157f7e0d3a9815ea961304433d28830c0
3
+ metadata.gz: 646dd5f9bdd9dde86186dfbe79c9830f0350580f22ee314ddd25a5e35ad4542e
4
+ data.tar.gz: 4d40f19ff4c6d1651871d43436c7e8901ce917fa75c1cf506a3c4ba132ecf530
5
5
  SHA512:
6
- metadata.gz: 820551163d07c69b52590ba94a8a43aa0f9d72acf9a8cb4cf7bfebeed4dd26f08d27296dd7c3e8bc87e07418f5c6cc590256fcd551ebb3643364225d88ff5901
7
- data.tar.gz: 7850d0d6edefb3e143d324a27cd5fef69e0d1e9c2149be85a70da57fc7bb94a24baf540795caaeafa428872618e32e28afea2d8124e2d630f232f928a25bbcce
6
+ metadata.gz: 2a9dc4214da271076da2f09dea0388d9a27ec32e3fb120e4d0b8197d46c17aaf941514cb46a01d9567a1f7e2c6f0357fc1bac60d5d08adeae86b156fd0f471f1
7
+ data.tar.gz: 8aeee66d296a7c30fad2ecce720c85c6fc41d83d8d23e9ad21e49ed0e6b50e8858348340e2057bcbc42e9760c5230aa27aec9ada09cedb523a3d9daa509c68b9
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.1.3] - 2021-12-27
7
+ - [#3](https://github.com/boltops-tools/azure_info/pull/3) improve error message when az cli not installed
8
+ - comment about what is used in the account and configure object
9
+
6
10
  ## [0.1.2] - 2021-04-15
7
11
  - [#2](https://github.com/boltops-tools/azure_info/pull/2) consider env vars also
8
12
 
data/README.md CHANGED
@@ -53,6 +53,10 @@ The config file used by the `az` command looks something like this:
53
53
  [defaults]
54
54
  location = eastus
55
55
 
56
+ This command is also useful:
57
+
58
+ az account show
59
+
56
60
  ## Setting the Defaults with az cli
57
61
 
58
62
  az login --username EMAIL_ADDRESS -t TENANT_ID
@@ -3,7 +3,24 @@ module AzureInfo
3
3
  def check_az_installed!
4
4
  installed = system("type az > /dev/null 2>&1")
5
5
  return if installed
6
- raise Error.new("ERROR: az is not installed. Please install the az command.")
6
+ message = <<~EOL
7
+ ERROR: az is not installed. Please install the az command and configure it.
8
+ AzureInfo uses it to detect azure resource group, location, subscription id, and tenant id.
9
+
10
+ You can also configure these environment variables instead of installing the az cli.
11
+
12
+ ARM_CLIENT_ID
13
+ ARM_CLIENT_SECRET
14
+ ARM_SUBSCRIPTION_ID
15
+ ARM_TENANT_ID
16
+
17
+ EOL
18
+ if ENV['AZ_INFO_RAISE_ERROR']
19
+ raise Error.new(message)
20
+ else
21
+ puts message
22
+ exit 1
23
+ end
7
24
  end
8
25
  end
9
26
  end
@@ -5,18 +5,18 @@
5
5
  module AzureInfo
6
6
  class Configure < Base
7
7
  def get(name)
8
- item = az_configure_defaults.find do |i|
8
+ item = az_configure_list_defaults.find do |i|
9
9
  i["name"] == name
10
10
  end
11
11
  item["value"] if item
12
12
  end
13
13
 
14
14
  # looks like az configure stores settings in ~/.azure/config
15
- def az_configure_defaults
16
- return @az_configure_defaults if @az_configure_defaults
15
+ def az_configure_list_defaults
16
+ return @az_configure_list_defaults if @az_configure_list_defaults
17
17
  check_az_installed!
18
18
  out = `az configure --list-defaults --output json`.strip
19
- @az_configure_defaults = JSON.load(out)
19
+ @az_configure_list_defaults = JSON.load(out)
20
20
  end
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module AzureInfo
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/azure_info.rb CHANGED
@@ -27,10 +27,12 @@ module AzureInfo
27
27
  alias_method :tenant, :tenant_id
28
28
 
29
29
  private
30
+ # info: group (resource group), location
30
31
  def configure
31
32
  @configure ||= Configure.new
32
33
  end
33
34
 
35
+ # info: id (subscription id), name (subscription name), tenantId
34
36
  def account
35
37
  @account ||= Account.new
36
38
  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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.2.5
55
+ rubygems_version: 3.2.32
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: 'Azure info: Simple library to get current subscription, resource group,