mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Specific credentials can now be used
If not specified the first one in the credentials file is used Fixes #14 Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
This commit is contained in:
parent
b011b71a27
commit
7699ffb6e2
1 changed files with 8 additions and 4 deletions
|
@ -40,13 +40,17 @@ class AzureConnection
|
|||
# If a connection already exists then return it
|
||||
return @conn if defined?(@conn)
|
||||
|
||||
# Determine if more than one subscription is specified in the configuration file, if so use the first one
|
||||
if @credentials.sections.length >= 1
|
||||
@subscription_id = @credentials.sections[0]
|
||||
else
|
||||
# If a subscription to be used has been specified as en environment variable use that
|
||||
# otherwise use the first one in the credentials file
|
||||
if !ENV['AZURE_SUBSCRIPTION_ID'].nil?
|
||||
@subscription_id = ENV['AZURE_SUBSCRIPTION_ID']
|
||||
else
|
||||
@subscription_id = @credentials.sections[0]
|
||||
end
|
||||
|
||||
# Check that the credential exists
|
||||
raise format('The specified Azure Subscription cannot be found in your credentials: %s', @subscription_id) unless @credentials.sections.include?(@subscription_id)
|
||||
|
||||
# Determine the client_id, tenant_id and the client_secret
|
||||
tenant_id = ENV['AZURE_TENANT_ID'] || @credentials[@subscription_id]['tenant_id']
|
||||
client_id = ENV['AZURE_CLIENT_ID'] || @credentials[@subscription_id]['client_id']
|
||||
|
|
Loading…
Reference in a new issue