train 1.5.0 → 1.5.4

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: e0d6951ed34583f2ee93e624dfee665eeac69ece0c77e142699fc4c28b87e6d2
4
- data.tar.gz: ff38812176b7daf727e44bcd189b3af909199398107a30b42deaee29b784f7cd
3
+ metadata.gz: 1f8a8136ef1361afa88f951fb3095bd894482ae737d5546c94a2311027383797
4
+ data.tar.gz: 3214e7d84ffe45af4d0997c444a052d49607fe6fb3d79fbfc737068328b553e5
5
5
  SHA512:
6
- metadata.gz: 3e8ef41d9b67af33e36093b3ea86db4564e1b39e0eb400fb85aa2f21753c234b08abfe40ce9f3a1703ebd79b52a570b7c7e571a31847b54ea6f1a630e08dda25
7
- data.tar.gz: 967d5fe1b319da6da65ecffcaf1bc3674cb8c0e2b3dfb626a75d93a81f37ed8deca17b9fca351d6a319250f95dbe48e1f6e1e43aead1e495fcfa06609d29aee0
6
+ metadata.gz: 80f9ff5fac3af02c41061434cef335569cb6e4d1b067027c9b7f119e844e5193655eb7d58d1f9b16504b8f8d0c28c51b008f51c7dda27597adfa346088696570
7
+ data.tar.gz: fe2a5fa5de52041ffeb96d7349cd2949e98ec410bb501494f7643c48b79d546a5a393f99261f961b3dbb05948d0ee728a288b9ec4c5bbba5ed4dbf938e54d1a7
@@ -1,27 +1,35 @@
1
- <!-- latest_release 1.5.0 -->
2
- ## [v1.5.0](https://github.com/inspec/train/tree/v1.5.0) (2018-09-27)
1
+ <!-- latest_release 1.5.4 -->
2
+ ## [v1.5.4](https://github.com/inspec/train/tree/v1.5.4) (2018-10-15)
3
3
 
4
4
  #### Merged Pull Requests
5
- - Bump minor version. [#357](https://github.com/inspec/train/pull/357) ([jquick](https://github.com/jquick))
5
+ - Correct example plugin link [#363](https://github.com/inspec/train/pull/363) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
6
6
  <!-- latest_release -->
7
7
 
8
- <!-- release_rollup since=1.4.37 -->
9
- ### Changes since 1.4.37 release
8
+ <!-- release_rollup since=1.5.0 -->
9
+ ### Changes since 1.5.0 release
10
10
 
11
11
  #### Merged Pull Requests
12
- - Bump minor version. [#357](https://github.com/inspec/train/pull/357) ([jquick](https://github.com/jquick)) <!-- 1.5.0 -->
13
- - Plugins: Test harness, test fixture, docs, and local-type example [#356](https://github.com/inspec/train/pull/356) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 1.4.40 -->
14
- - Adding GCP admin_client helper. [#349](https://github.com/inspec/train/pull/349) ([skpaterson](https://github.com/skpaterson)) <!-- 1.4.39 -->
15
- - Update google-api-client version. [#348](https://github.com/inspec/train/pull/348) ([skpaterson](https://github.com/skpaterson)) <!-- 1.4.38 -->
12
+ - Correct example plugin link [#363](https://github.com/inspec/train/pull/363) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 1.5.4 -->
13
+ - Adds Azure Vault Client [#351](https://github.com/inspec/train/pull/351) ([r-fennell](https://github.com/r-fennell)) <!-- 1.5.3 -->
14
+ - Remove the legacy version bumping from the rakefile [#359](https://github.com/inspec/train/pull/359) ([tas50](https://github.com/tas50)) <!-- 1.5.2 -->
15
+ - Fixes the link pointing back to the plugin docs [#362](https://github.com/inspec/train/pull/362) ([cattywampus](https://github.com/cattywampus)) <!-- 1.5.1 -->
16
16
  <!-- release_rollup -->
17
17
 
18
18
  <!-- latest_stable_release -->
19
+ ## [v1.5.0](https://github.com/inspec/train/tree/v1.5.0) (2018-09-27)
20
+
21
+ #### Merged Pull Requests
22
+ - Update google-api-client version. [#348](https://github.com/inspec/train/pull/348) ([skpaterson](https://github.com/skpaterson))
23
+ - Adding GCP admin_client helper. [#349](https://github.com/inspec/train/pull/349) ([skpaterson](https://github.com/skpaterson))
24
+ - Plugins: Test harness, test fixture, docs, and local-type example [#356](https://github.com/inspec/train/pull/356) ([clintoncwolfe](https://github.com/clintoncwolfe))
25
+ - Bump minor version. [#357](https://github.com/inspec/train/pull/357) ([jquick](https://github.com/jquick))
26
+ <!-- latest_stable_release -->
27
+
19
28
  ## [v1.4.37](https://github.com/inspec/train/tree/v1.4.37) (2018-09-13)
20
29
 
21
30
  #### Merged Pull Requests
22
31
  - Rescues SystemCallError instead of Errno [#346](https://github.com/inspec/train/pull/346) ([dmccown](https://github.com/dmccown))
23
32
  - Add a export method for platforms [#347](https://github.com/inspec/train/pull/347) ([jquick](https://github.com/jquick))
24
- <!-- latest_stable_release -->
25
33
 
26
34
  ## [v1.4.35](https://github.com/inspec/train/tree/v1.4.35) (2018-08-23)
27
35
 
data/Rakefile CHANGED
@@ -71,80 +71,3 @@ namespace :test do
71
71
  sh('sh', '-c', sh_cmd)
72
72
  end
73
73
  end
74
-
75
- # Print the current version of this gem or update it.
76
- #
77
- # @param [Type] target the new version you want to set, or nil if you only want to show
78
- def train_version(target = nil)
79
- path = 'lib/train/version.rb'
80
- require_relative path.sub(/.rb$/, '')
81
-
82
- nu_version = target.nil? ? '' : " -> #{target}"
83
- puts "Train: #{Train::VERSION}#{nu_version}"
84
-
85
- unless target.nil?
86
- raw = File.read(path)
87
- nu = raw.sub(/VERSION.*/, "VERSION = '#{target}'.freeze")
88
- File.write(path, nu)
89
- load(path)
90
- end
91
- end
92
-
93
- # Check if a command is available
94
- #
95
- # @param [Type] x the command you are interested in
96
- # @param [Type] msg the message to display if the command is missing
97
- def require_command(x, msg = nil)
98
- return if system("command -v #{x} || exit 1")
99
- msg ||= 'Please install it first!'
100
- puts "\033[31;1mCan't find command #{x.inspect}. #{msg}\033[0m"
101
- exit 1
102
- end
103
-
104
- # Check if a required environment variable has been set
105
- #
106
- # @param [String] x the variable you are interested in
107
- # @param [String] msg the message you want to display if the variable is missing
108
- def require_env(x, msg = nil)
109
- exists = `env | grep "^#{x}="`
110
- return unless exists.empty?
111
- puts "\033[31;1mCan't find environment variable #{x.inspect}. #{msg}\033[0m"
112
- exit 1
113
- end
114
-
115
- # Check the requirements for running an update of this repository.
116
- def check_update_requirements
117
- require_command 'git'
118
- require_command 'github_changelog_generator', "\n"\
119
- "For more information on how to install it see:\n"\
120
- " https://github.com/skywinder/github-changelog-generator\n"
121
- require_env 'CHANGELOG_GITHUB_TOKEN', "\n"\
122
- "Please configure this token to make sure you can run all commands\n"\
123
- "against GitHub.\n\n"\
124
- "See github_changelog_generator homepage for more information:\n"\
125
- " https://github.com/skywinder/github-changelog-generator\n"
126
- end
127
-
128
- # Show the current version of this gem.
129
- desc 'Show the version of this gem'
130
- task :version do
131
- train_version
132
- end
133
-
134
- desc 'Generate the changelog'
135
- task :changelog do
136
- require_relative 'lib/train/version'
137
- system "github_changelog_generator -u chef -p train --future-release #{Train::VERSION}"
138
- end
139
-
140
- # Update the version of this gem and create an updated
141
- # changelog. It covers everything short of actually releasing
142
- # the gem.
143
- desc 'Bump the version of this gem'
144
- task :bump_version, [:version] do |_, args|
145
- v = args[:version] || ENV['to']
146
- fail "You must specify a target version! rake bump_version to=1.2.3" if v.empty?
147
- check_update_requirements
148
- train_version(v)
149
- Rake::Task['changelog'].invoke
150
- end
@@ -4,10 +4,12 @@ require 'train/plugins'
4
4
  require 'ms_rest_azure'
5
5
  require 'azure_mgmt_resources'
6
6
  require 'azure_graph_rbac'
7
+ require 'azure_mgmt_key_vault'
7
8
  require 'socket'
8
9
  require 'timeout'
9
10
  require 'train/transports/helpers/azure/file_credentials'
10
11
  require 'train/transports/clients/azure/graph_rbac'
12
+ require 'train/transports/clients/azure/vault'
11
13
 
12
14
  module Train::Transports
13
15
  class Azure < Train.plugin(1)
@@ -59,7 +61,7 @@ module Train::Transports
59
61
  force_platform!('azure', @platform_details)
60
62
  end
61
63
 
62
- def azure_client(klass = ::Azure::Resources::Profiles::Latest::Mgmt::Client)
64
+ def azure_client(klass = ::Azure::Resources::Profiles::Latest::Mgmt::Client, opts = {})
63
65
  if cache_enabled?(:api_call)
64
66
  return @cache[:api_call][klass.to_s.to_sym] unless @cache[:api_call][klass.to_s.to_sym].nil?
65
67
  end
@@ -67,7 +69,9 @@ module Train::Transports
67
69
  if klass == ::Azure::Resources::Profiles::Latest::Mgmt::Client
68
70
  @credentials[:base_url] = MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
69
71
  elsif klass == ::Azure::GraphRbac::Profiles::Latest::Client
70
- client = GraphRbac.client(@credentials)
72
+ client = GraphRbac.client(@credentials)
73
+ elsif klass == ::Azure::KeyVault::Profiles::Latest::Mgmt::Client
74
+ client = Vault.client(opts[:vault_name], @credentials)
71
75
  end
72
76
 
73
77
  client ||= klass.new(@credentials)
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'azure_graph_rbac'
3
4
 
4
5
  # Wrapper class for ::Azure::GraphRbac::Profiles::Latest::Client allowing custom configuration,
@@ -8,15 +9,19 @@ class GraphRbac
8
9
  API_ENDPOINT = MsRestAzure::AzureEnvironments::AzureCloud.active_directory_graph_resource_id
9
10
 
10
11
  def self.client(credentials)
11
- provider = ::MsRestAzure::ApplicationTokenProvider.new(
12
+ credentials[:credentials] = ::MsRest::TokenCredentials.new(provider(credentials))
13
+ credentials[:base_url] = API_ENDPOINT
14
+
15
+ ::Azure::GraphRbac::Profiles::Latest::Client.new(credentials)
16
+ end
17
+
18
+ def self.provider(credentials)
19
+ ::MsRestAzure::ApplicationTokenProvider.new(
12
20
  credentials[:tenant_id],
13
21
  credentials[:client_id],
14
22
  credentials[:client_secret],
15
23
  settings,
16
24
  )
17
- credentials[:credentials] = ::MsRest::TokenCredentials.new(provider)
18
- credentials[:base_url] = API_ENDPOINT
19
- ::Azure::GraphRbac::Profiles::Latest::Client.new(credentials)
20
25
  end
21
26
 
22
27
  def self.settings
@@ -25,4 +30,6 @@ class GraphRbac
25
30
  client_settings.token_audience = API_ENDPOINT
26
31
  client_settings
27
32
  end
33
+
34
+ private_class_method :provider, :settings
28
35
  end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ require 'azure_mgmt_key_vault'
4
+
5
+ # Wrapper class for ::Azure::KeyVault::Profiles::Latest::Mgmt::Client allowing custom configuration,
6
+ # for example, defining additional settings for the ::MsRestAzure::ApplicationTokenProvider.
7
+ class Vault
8
+ AUTH_ENDPOINT = MsRestAzure::AzureEnvironments::AzureCloud.active_directory_endpoint_url
9
+ RESOURCE_ENDPOINT = 'https://vault.azure.net'.freeze
10
+
11
+ def self.client(vault_name, credentials)
12
+ raise ::Train::UserError, 'Vault Name cannot be nil' if vault_name.nil?
13
+
14
+ credentials[:credentials] = ::MsRest::TokenCredentials.new(provider(credentials))
15
+ credentials[:base_url] = api_endpoint(vault_name)
16
+
17
+ ::Azure::KeyVault::Profiles::Latest::Mgmt::Client.new(credentials)
18
+ end
19
+
20
+ def self.provider(credentials)
21
+ ::MsRestAzure::ApplicationTokenProvider.new(
22
+ credentials[:tenant_id],
23
+ credentials[:client_id],
24
+ credentials[:client_secret],
25
+ settings,
26
+ )
27
+ end
28
+
29
+ def self.api_endpoint(vault_name)
30
+ "https://#{vault_name}#{MsRestAzure::AzureEnvironments::AzureCloud.key_vault_dns_suffix}"
31
+ end
32
+
33
+ def self.settings
34
+ client_settings = MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
35
+ client_settings.authentication_endpoint = AUTH_ENDPOINT
36
+ client_settings.token_audience = RESOURCE_ENDPOINT
37
+ client_settings
38
+ end
39
+
40
+ private_class_method :provider, :api_endpoint, :settings
41
+ end
@@ -3,5 +3,5 @@
3
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
4
 
5
5
  module Train
6
- VERSION = '1.5.0'.freeze
6
+ VERSION = '1.5.4'.freeze
7
7
  end
@@ -81,10 +81,23 @@ describe 'azure transport' do
81
81
  end
82
82
 
83
83
  it 'can use azure_client graph client' do
84
- GRAPH_API_CLIENT = Azure::GraphRbac::Profiles::Latest::Client
84
+ GRAPH_API_CLIENT = Azure::GraphRbac::Profiles::Latest::Client
85
85
  client = connection.azure_client(GRAPH_API_CLIENT)
86
86
  client.class.must_equal GRAPH_API_CLIENT
87
87
  end
88
+
89
+ it 'can use azure_client vault client' do
90
+ VAULT_API_CLIENT = ::Azure::KeyVault::Profiles::Latest::Mgmt::Client
91
+ client = connection.azure_client(VAULT_API_CLIENT, vault_name: 'Test Vault')
92
+ client.class.must_equal VAULT_API_CLIENT
93
+ end
94
+
95
+ it 'cannot instantiate azure_client vault client without a vault name' do
96
+ VAULT_API_CLIENT = ::Azure::KeyVault::Profiles::Latest::Mgmt::Client
97
+ assert_raises(Train::UserError) do
98
+ connection.azure_client(VAULT_API_CLIENT)
99
+ end
100
+ end
88
101
  end
89
102
 
90
103
  describe 'connect' do
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'aws-sdk', '~> 2'
37
37
  spec.add_dependency 'azure_mgmt_resources', '~> 0.15'
38
38
  spec.add_dependency 'azure_graph_rbac', '~> 0.16'
39
+ spec.add_dependency 'azure_mgmt_key_vault', '~> 0.17'
39
40
  spec.add_dependency 'google-api-client', '~> 0.23.9'
40
41
  spec.add_dependency 'googleauth', '~> 0.6.6'
41
42
  spec.add_dependency 'inifile'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-27 00:00:00.000000000 Z
11
+ date: 2018-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -162,6 +162,20 @@ dependencies:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0.16'
165
+ - !ruby/object:Gem::Dependency
166
+ name: azure_mgmt_key_vault
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: '0.17'
172
+ type: :runtime
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
177
+ - !ruby/object:Gem::Version
178
+ version: '0.17'
165
179
  - !ruby/object:Gem::Dependency
166
180
  name: google-api-client
167
181
  requirement: !ruby/object:Gem::Requirement
@@ -268,6 +282,7 @@ files:
268
282
  - lib/train/transports/azure.rb
269
283
  - lib/train/transports/cisco_ios_connection.rb
270
284
  - lib/train/transports/clients/azure/graph_rbac.rb
285
+ - lib/train/transports/clients/azure/vault.rb
271
286
  - lib/train/transports/docker.rb
272
287
  - lib/train/transports/gcp.rb
273
288
  - lib/train/transports/helpers/azure/file_credentials.rb