octopus-serverspec-extensions 0.11.8 → 0.12.0

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
  SHA1:
3
- metadata.gz: 52f0d116c786c5dfb99c8717b2f395eddc4afcd4
4
- data.tar.gz: aec8c3545003ac320d4fc2efb6a9fdfae0d9474a
3
+ metadata.gz: 0e06553887a2d35d4327d7e1d71a8e1742d042d5
4
+ data.tar.gz: d7780fd1eb08d43d216211deec5468d44f4dc797
5
5
  SHA512:
6
- metadata.gz: 6809e58d6736172020aa7a9b4e0f00dc4ab67742ead3aa65c5badb3ad0dcb1729db71a28d165468487336eeffe2e1e658b828646f8855ebcfdbe25d14741e848
7
- data.tar.gz: c6632b7be7db10e3c2369625fbeaefdad929ce7e0acb3c71bb1509f8fc208426d453f32b053b5d9acf10734cf1fa9bdb89559259178b33826af4d233d7cf870c
6
+ metadata.gz: ea8a042bb746a985a6c72bdb406605a1623752dd5cbf4857479de85279f166d365c84e9d3b039f8406404f0cd5751ed8680fe12553faa920d276b3094620c02f
7
+ data.tar.gz: bad17af2ace2fdd5e0a43ccb4f5d5e1fa4233ec13d93b0a1f91ae038712daad7bc1f2be1dbea2d69f645c9f5c5dd6b5ee79ba8375da883f1b3d664a61fd680d3
@@ -2,6 +2,7 @@ require 'octopus_serverspec_extensions/type/chocolatey_package.rb'
2
2
  require 'octopus_serverspec_extensions/type/npm_package.rb'
3
3
  require 'octopus_serverspec_extensions/type/java_property_file.rb'
4
4
  require 'octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb'
5
+ require 'octopus_serverspec_extensions/type/octopus_deploy_environment.rb'
5
6
  require 'octopus_serverspec_extensions/type/windows_firewall.rb'
6
7
  require 'octopus_serverspec_extensions/type/windows_scheduled_task.rb'
7
8
  require 'octopus_serverspec_extensions/matcher/have_version.rb'
@@ -0,0 +1,57 @@
1
+ require 'serverspec'
2
+ require 'serverspec/type/base'
3
+ require 'net/http'
4
+ require 'json'
5
+
6
+ module Serverspec::Type
7
+ class OctopusDeployEnvironment < Base
8
+ @environment = nil
9
+ @serverUrl = nil
10
+ @apiKey = nil
11
+
12
+ def initialize(serverUrl, apiKey, environment_name)
13
+ @name = "Octopus Deploy Environment #{environment_name}"
14
+ @runner = Specinfra::Runner
15
+ @serverUrl = serverUrl
16
+ @apiKey = apiKey
17
+
18
+ if (serverUrl.nil?)
19
+ puts "'serverUrl' was not provided. Unable to connect to Octopus server to validate configuration."
20
+ return
21
+ end
22
+ if (apiKey.nil?)
23
+ puts "'apiKey' was not provided. Unable to connect to Octopus server to validate configuration."
24
+ return
25
+ end
26
+
27
+ @environment = get_environment_via_api(serverUrl, apiKey, thumbprint)
28
+ end
29
+
30
+ def exists?
31
+ !@environment.nil?
32
+ end
33
+ end
34
+
35
+ def octopus_deploy_tentacle(serverUrl, apiKey, environment_name)
36
+ OctopusDeployEnvironment.new(serverUrl, apiKey, environment_name)
37
+ end
38
+
39
+ private
40
+
41
+ def get_environment_via_api(serverUrl, apiKey, environment_name)
42
+ environment = nil
43
+ url = "#{serverUrl}/api/environments?name=#{environment_name}&api-key=#{apiKey}"
44
+
45
+ begin
46
+ resp = Net::HTTP.get_response(URI.parse(url))
47
+ body = JSON.parse(resp.body)
48
+ environment = body['Items'].first unless body.nil?
49
+ rescue => e
50
+ puts "Unable to connect to #{url}: #{e}"
51
+ end
52
+
53
+ environment
54
+ end
55
+ end
56
+
57
+ include Serverspec::Type
@@ -1,3 +1,3 @@
1
1
  module OctopusServerSpecExtensions
2
- VERSION = "0.11.8"
2
+ VERSION = "0.12.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopus-serverspec-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.8
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Richardson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-30 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serverspec
@@ -146,6 +146,7 @@ files:
146
146
  - lib/octopus_serverspec_extensions/type/chocolatey_package.rb
147
147
  - lib/octopus_serverspec_extensions/type/java_property_file.rb
148
148
  - lib/octopus_serverspec_extensions/type/npm_package.rb
149
+ - lib/octopus_serverspec_extensions/type/octopus_deploy_environment.rb
149
150
  - lib/octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb
150
151
  - lib/octopus_serverspec_extensions/type/windows_firewall.rb
151
152
  - lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb