octopus-serverspec-extensions 0.18.1 → 0.19.0
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 +4 -4
- data/.gitignore +14 -14
- data/.rspec +2 -2
- data/.travis.yml +5 -5
- data/Gemfile +4 -4
- data/LICENSE.txt +12 -12
- data/README.md +39 -39
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/docs/authentication.md +45 -45
- data/docs/octopus_deploy_account.md +37 -37
- data/docs/octopus_deploy_doc_template.md +16 -16
- data/docs/octopus_deploy_environment.md +32 -32
- data/docs/octopus_deploy_project_group.md +30 -30
- data/docs/octopus_deploy_smtp_config.md +39 -39
- data/docs/octopus_deploy_space.md +32 -32
- data/docs/octopus_deploy_team.md +25 -25
- data/docs/octopus_deploy_tentacle.md +40 -40
- data/docs/octopus_deploy_upgrade_config.md +33 -33
- data/docs/octopus_deploy_user.md +33 -33
- data/docs/octopus_deploy_worker.md +38 -38
- data/docs/octopus_deploy_worker_pool.md +25 -25
- data/lib/octopus_serverspec_extensions.rb +85 -85
- data/lib/octopus_serverspec_extensions/matcher/allow_dynamic_infrastructure.rb +12 -12
- data/lib/octopus_serverspec_extensions/matcher/have_linux_line_endings.rb +13 -13
- data/lib/octopus_serverspec_extensions/matcher/have_version.rb +36 -36
- data/lib/octopus_serverspec_extensions/matcher/have_windows_line_endings.rb +13 -13
- data/lib/octopus_serverspec_extensions/matcher/run_under_account.rb +17 -17
- data/lib/octopus_serverspec_extensions/matcher/use_guided_failure.rb +12 -12
- data/lib/octopus_serverspec_extensions/type/chocolatey_package.rb +33 -33
- data/lib/octopus_serverspec_extensions/type/java_property_file.rb +28 -28
- data/lib/octopus_serverspec_extensions/type/npm_package.rb +36 -36
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_account.rb +176 -176
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_environment.rb +117 -117
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_project_group.rb +127 -127
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_smtp_config.rb +109 -109
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_space.rb +92 -92
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_team.rb +81 -81
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb +208 -208
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_upgrade_config.rb +112 -112
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_user.rb +110 -110
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_worker.rb +173 -173
- data/lib/octopus_serverspec_extensions/type/octopus_deploy_worker_pool.rb +88 -88
- data/lib/octopus_serverspec_extensions/type/windows_dsc.rb +37 -37
- data/lib/octopus_serverspec_extensions/type/windows_firewall.rb +32 -32
- data/lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb +33 -33
- data/lib/octopus_serverspec_extensions/version.rb +3 -3
- data/octopus-serverspec-extensions.gemspec +34 -34
- metadata +15 -16
@@ -1,117 +1,117 @@
|
|
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
|
-
@environment_name = nil
|
10
|
-
@serverUrl = nil
|
11
|
-
@apiKey = nil
|
12
|
-
@spaceId = nil
|
13
|
-
@spaceFragment = ""
|
14
|
-
|
15
|
-
def initialize(*url_and_api_key, environment_name)
|
16
|
-
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
17
|
-
|
18
|
-
@environment_name = environment_name
|
19
|
-
@name = "Octopus Deploy Environment #{environment_name}"
|
20
|
-
@runner = Specinfra::Runner
|
21
|
-
@serverUrl = serverUrl
|
22
|
-
@apiKey = apiKey
|
23
|
-
|
24
|
-
if environment_name.nil?
|
25
|
-
raise "'environment_name' was not provided. Unable to connect to Octopus server to validate configuration."
|
26
|
-
end
|
27
|
-
|
28
|
-
@serverSupportsSpaces = check_supports_spaces(serverUrl)
|
29
|
-
end
|
30
|
-
|
31
|
-
def exists?
|
32
|
-
load_resource_if_nil
|
33
|
-
(!@environment.nil?) && (@environment != [])
|
34
|
-
end
|
35
|
-
|
36
|
-
def use_guided_failure?
|
37
|
-
load_resource_if_nil
|
38
|
-
false if @environment.nil?
|
39
|
-
@environment['UseGuidedFailure'] == true
|
40
|
-
end
|
41
|
-
|
42
|
-
def allow_dynamic_infrastructure?
|
43
|
-
load_resource_if_nil
|
44
|
-
false if @environment.nil?
|
45
|
-
@environment['AllowDynamicInfrastructure'] == true
|
46
|
-
end
|
47
|
-
|
48
|
-
def in_space(space_name)
|
49
|
-
# allows us to tag .in_space() onto the end of the resource. as in
|
50
|
-
# describe octopus_account("account name").in_space("MyNewSpace") do
|
51
|
-
@spaceId = get_space_id(space_name)
|
52
|
-
if @environment_name.nil?
|
53
|
-
raise "'environment_name' was not provided. Unable to connect to Octopus server to validate configuration."
|
54
|
-
end
|
55
|
-
if(@spaceId.nil?)
|
56
|
-
raise "unable to resolve space '#{@spaceId}'"
|
57
|
-
end
|
58
|
-
self
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def load_resource_if_nil
|
64
|
-
if @environment.nil?
|
65
|
-
@environment = get_environment_via_api(@serverUrl, @apiKey, @environment_name)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_space_id(space_name)
|
70
|
-
return false if @serverSupportsSpaces.nil?
|
71
|
-
url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
|
72
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
73
|
-
spaces = JSON.parse(resp.body)
|
74
|
-
space_id = spaces.select {|e| e["Name"] == space_name}.first["Id"]
|
75
|
-
space_id
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# module-level constructors/entrypoints
|
80
|
-
|
81
|
-
def octopus_deploy_environment(*url_and_api_key, environment_name)
|
82
|
-
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
83
|
-
|
84
|
-
OctopusDeployEnvironment.new(serverUrl, apiKey, environment_name)
|
85
|
-
end
|
86
|
-
|
87
|
-
def octopus_environment(*url_and_api_key, environment_name)
|
88
|
-
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
89
|
-
|
90
|
-
OctopusDeployEnvironment.new(serverUrl, apiKey, environment_name)
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def get_environment_via_api(serverUrl, apiKey, environment_name)
|
96
|
-
environment = nil
|
97
|
-
|
98
|
-
unless @spaceId.nil?
|
99
|
-
# set the spaceId correctly
|
100
|
-
@spaceFragment = "#{@spaceId}/"
|
101
|
-
end
|
102
|
-
|
103
|
-
url = "#{serverUrl}/api/#{@spaceFragment}environments?name=#{environment_name}&api-key=#{apiKey}"
|
104
|
-
|
105
|
-
begin
|
106
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
107
|
-
body = JSON.parse(resp.body)
|
108
|
-
environment = body['Items'].first unless body.nil?
|
109
|
-
rescue => e
|
110
|
-
raise "Unable to connect to #{url}: #{e}"
|
111
|
-
end
|
112
|
-
|
113
|
-
environment
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
include Serverspec::Type
|
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
|
+
@environment_name = nil
|
10
|
+
@serverUrl = nil
|
11
|
+
@apiKey = nil
|
12
|
+
@spaceId = nil
|
13
|
+
@spaceFragment = ""
|
14
|
+
|
15
|
+
def initialize(*url_and_api_key, environment_name)
|
16
|
+
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
17
|
+
|
18
|
+
@environment_name = environment_name
|
19
|
+
@name = "Octopus Deploy Environment #{environment_name}"
|
20
|
+
@runner = Specinfra::Runner
|
21
|
+
@serverUrl = serverUrl
|
22
|
+
@apiKey = apiKey
|
23
|
+
|
24
|
+
if environment_name.nil?
|
25
|
+
raise "'environment_name' was not provided. Unable to connect to Octopus server to validate configuration."
|
26
|
+
end
|
27
|
+
|
28
|
+
@serverSupportsSpaces = check_supports_spaces(serverUrl)
|
29
|
+
end
|
30
|
+
|
31
|
+
def exists?
|
32
|
+
load_resource_if_nil
|
33
|
+
(!@environment.nil?) && (@environment != [])
|
34
|
+
end
|
35
|
+
|
36
|
+
def use_guided_failure?
|
37
|
+
load_resource_if_nil
|
38
|
+
false if @environment.nil?
|
39
|
+
@environment['UseGuidedFailure'] == true
|
40
|
+
end
|
41
|
+
|
42
|
+
def allow_dynamic_infrastructure?
|
43
|
+
load_resource_if_nil
|
44
|
+
false if @environment.nil?
|
45
|
+
@environment['AllowDynamicInfrastructure'] == true
|
46
|
+
end
|
47
|
+
|
48
|
+
def in_space(space_name)
|
49
|
+
# allows us to tag .in_space() onto the end of the resource. as in
|
50
|
+
# describe octopus_account("account name").in_space("MyNewSpace") do
|
51
|
+
@spaceId = get_space_id(space_name)
|
52
|
+
if @environment_name.nil?
|
53
|
+
raise "'environment_name' was not provided. Unable to connect to Octopus server to validate configuration."
|
54
|
+
end
|
55
|
+
if(@spaceId.nil?)
|
56
|
+
raise "unable to resolve space '#{@spaceId}'"
|
57
|
+
end
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def load_resource_if_nil
|
64
|
+
if @environment.nil?
|
65
|
+
@environment = get_environment_via_api(@serverUrl, @apiKey, @environment_name)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_space_id(space_name)
|
70
|
+
return false if @serverSupportsSpaces.nil?
|
71
|
+
url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
|
72
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
73
|
+
spaces = JSON.parse(resp.body)
|
74
|
+
space_id = spaces.select {|e| e["Name"] == space_name}.first["Id"]
|
75
|
+
space_id
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# module-level constructors/entrypoints
|
80
|
+
|
81
|
+
def octopus_deploy_environment(*url_and_api_key, environment_name)
|
82
|
+
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
83
|
+
|
84
|
+
OctopusDeployEnvironment.new(serverUrl, apiKey, environment_name)
|
85
|
+
end
|
86
|
+
|
87
|
+
def octopus_environment(*url_and_api_key, environment_name)
|
88
|
+
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
89
|
+
|
90
|
+
OctopusDeployEnvironment.new(serverUrl, apiKey, environment_name)
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def get_environment_via_api(serverUrl, apiKey, environment_name)
|
96
|
+
environment = nil
|
97
|
+
|
98
|
+
unless @spaceId.nil?
|
99
|
+
# set the spaceId correctly
|
100
|
+
@spaceFragment = "#{@spaceId}/"
|
101
|
+
end
|
102
|
+
|
103
|
+
url = "#{serverUrl}/api/#{@spaceFragment}environments?name=#{environment_name}&api-key=#{apiKey}"
|
104
|
+
|
105
|
+
begin
|
106
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
107
|
+
body = JSON.parse(resp.body)
|
108
|
+
environment = body['Items'].first unless body.nil?
|
109
|
+
rescue => e
|
110
|
+
raise "Unable to connect to #{url}: #{e}"
|
111
|
+
end
|
112
|
+
|
113
|
+
environment
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
include Serverspec::Type
|
@@ -1,128 +1,128 @@
|
|
1
|
-
require 'serverspec/type/base'
|
2
|
-
require 'net/http'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module Serverspec::Type
|
6
|
-
class OctopusDeployProjectGroup < Base
|
7
|
-
@project_group = nil
|
8
|
-
@project_group_name = nil
|
9
|
-
@serverUrl = nil
|
10
|
-
@apiKey = nil
|
11
|
-
@serverSupportsSpaces = nil
|
12
|
-
@spaceId = nil
|
13
|
-
@spaceFragment = ""
|
14
|
-
|
15
|
-
def initialize(*url_and_api_key, project_group_name)
|
16
|
-
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
17
|
-
|
18
|
-
raise "'project_group_name' was not provided. Unable to connect to Octopus server to validate configuration." if project_group_name.nil?
|
19
|
-
|
20
|
-
@project_group_name = project_group_name
|
21
|
-
|
22
|
-
@name = "Octopus Deploy Project Group #{project_group_name}"
|
23
|
-
@runner = Specinfra::Runner
|
24
|
-
@serverUrl = serverUrl
|
25
|
-
@apiKey = apiKey
|
26
|
-
|
27
|
-
@serverSupportsSpaces = check_supports_spaces(serverUrl)
|
28
|
-
end
|
29
|
-
|
30
|
-
def exists?
|
31
|
-
load_resource_if_nil
|
32
|
-
(!@project_group.nil?) && (@project_group != [])
|
33
|
-
end
|
34
|
-
|
35
|
-
def has_description?(project_group_description)
|
36
|
-
load_resource_if_nil
|
37
|
-
return false if @project_group.nil?
|
38
|
-
@project_group["Description"] == project_group_description
|
39
|
-
end
|
40
|
-
|
41
|
-
def in_space(space_name)
|
42
|
-
# allows us to tag .in_space() onto the end of the resource. as in
|
43
|
-
# describe octopus_account("account name").in_space("MyNewSpace") do
|
44
|
-
@spaceId = get_space_id(space_name)
|
45
|
-
if @project_group_name.nil?
|
46
|
-
raise "'project_group_name' was not provided. Please provide a project group name and try again."
|
47
|
-
end
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def get_space_id(space_name)
|
54
|
-
return false if @serverSupportsSpaces.nil?
|
55
|
-
url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
|
56
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
57
|
-
spaces = JSON.parse(resp.body)
|
58
|
-
space_id = spaces.select {|e| e["Name"] == space_name}.first["Id"]
|
59
|
-
space_id
|
60
|
-
end
|
61
|
-
|
62
|
-
def load_resource_if_nil
|
63
|
-
if @project_group.nil?
|
64
|
-
@project_group = get_project_group_via_api(@serverUrl, @apiKey, @project_group_name)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# module-level constructors/entrypoints
|
70
|
-
|
71
|
-
def octopus_deploy_projectgroup(*url_and_api_key, project_group_name) # deprecated - no underscore in name
|
72
|
-
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
73
|
-
OctopusDeployProjectGroup.new(serverUrl, apiKey, project_group_name)
|
74
|
-
end
|
75
|
-
|
76
|
-
def octopus_deploy_project_group(*url_and_api_key, project_group_name)
|
77
|
-
url, apikey = get_octopus_creds(url_and_api_key)
|
78
|
-
octopus_deploy_projectgroup(url, apikey, project_group_name)
|
79
|
-
end
|
80
|
-
|
81
|
-
def octopus_project_group(*url_and_api_key, project_group_name)
|
82
|
-
url, apikey = get_octopus_creds(url_and_api_key)
|
83
|
-
octopus_deploy_projectgroup(url, apikey, project_group_name)
|
84
|
-
end
|
85
|
-
|
86
|
-
def octopus_projectgroup(*url_and_api_key, project_group_name) # deprecated - no underscore in name
|
87
|
-
url, apikey = get_octopus_creds(url_and_api_key)
|
88
|
-
octopus_deploy_projectgroup(url, apikey, project_group_name)
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
|
93
|
-
def get_project_group_via_api(serverUrl, apiKey, project_group_name)
|
94
|
-
pg = nil
|
95
|
-
|
96
|
-
raise "'project_group_name' not supplied" if(project_group_name.nil? || project_group_name == '')
|
97
|
-
|
98
|
-
unless @spaceId.nil?
|
99
|
-
@spaceFragment = "#{@spaceId}/"
|
100
|
-
end
|
101
|
-
|
102
|
-
url = "#{serverUrl}/api/#{@spaceFragment}projectgroups/all?api-key=#{apiKey}"
|
103
|
-
|
104
|
-
begin
|
105
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
106
|
-
body = JSON.parse(resp.body)
|
107
|
-
pg = body.select {|i| i['Name'] == project_group_name }.first unless body.nil?
|
108
|
-
rescue => e
|
109
|
-
raise "get_project_group_via_api: Unable to connect to #{url}: #{e}"
|
110
|
-
end
|
111
|
-
|
112
|
-
pg
|
113
|
-
end
|
114
|
-
|
115
|
-
def get_space_id?(space_name)
|
116
|
-
url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
|
117
|
-
begin
|
118
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
119
|
-
spaces = JSON.parse(resp.body)
|
120
|
-
space_id = spaces.select {|e| e["Name"] == space_name}.first["Id"]
|
121
|
-
rescue
|
122
|
-
raise "get_space_id: unable to connect to #{url}: #{e}"
|
123
|
-
end
|
124
|
-
space_id
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
1
|
+
require 'serverspec/type/base'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Serverspec::Type
|
6
|
+
class OctopusDeployProjectGroup < Base
|
7
|
+
@project_group = nil
|
8
|
+
@project_group_name = nil
|
9
|
+
@serverUrl = nil
|
10
|
+
@apiKey = nil
|
11
|
+
@serverSupportsSpaces = nil
|
12
|
+
@spaceId = nil
|
13
|
+
@spaceFragment = ""
|
14
|
+
|
15
|
+
def initialize(*url_and_api_key, project_group_name)
|
16
|
+
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
17
|
+
|
18
|
+
raise "'project_group_name' was not provided. Unable to connect to Octopus server to validate configuration." if project_group_name.nil?
|
19
|
+
|
20
|
+
@project_group_name = project_group_name
|
21
|
+
|
22
|
+
@name = "Octopus Deploy Project Group #{project_group_name}"
|
23
|
+
@runner = Specinfra::Runner
|
24
|
+
@serverUrl = serverUrl
|
25
|
+
@apiKey = apiKey
|
26
|
+
|
27
|
+
@serverSupportsSpaces = check_supports_spaces(serverUrl)
|
28
|
+
end
|
29
|
+
|
30
|
+
def exists?
|
31
|
+
load_resource_if_nil
|
32
|
+
(!@project_group.nil?) && (@project_group != [])
|
33
|
+
end
|
34
|
+
|
35
|
+
def has_description?(project_group_description)
|
36
|
+
load_resource_if_nil
|
37
|
+
return false if @project_group.nil?
|
38
|
+
@project_group["Description"] == project_group_description
|
39
|
+
end
|
40
|
+
|
41
|
+
def in_space(space_name)
|
42
|
+
# allows us to tag .in_space() onto the end of the resource. as in
|
43
|
+
# describe octopus_account("account name").in_space("MyNewSpace") do
|
44
|
+
@spaceId = get_space_id(space_name)
|
45
|
+
if @project_group_name.nil?
|
46
|
+
raise "'project_group_name' was not provided. Please provide a project group name and try again."
|
47
|
+
end
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def get_space_id(space_name)
|
54
|
+
return false if @serverSupportsSpaces.nil?
|
55
|
+
url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
|
56
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
57
|
+
spaces = JSON.parse(resp.body)
|
58
|
+
space_id = spaces.select {|e| e["Name"] == space_name}.first["Id"]
|
59
|
+
space_id
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_resource_if_nil
|
63
|
+
if @project_group.nil?
|
64
|
+
@project_group = get_project_group_via_api(@serverUrl, @apiKey, @project_group_name)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# module-level constructors/entrypoints
|
70
|
+
|
71
|
+
def octopus_deploy_projectgroup(*url_and_api_key, project_group_name) # deprecated - no underscore in name
|
72
|
+
serverUrl, apiKey = get_octopus_creds(url_and_api_key)
|
73
|
+
OctopusDeployProjectGroup.new(serverUrl, apiKey, project_group_name)
|
74
|
+
end
|
75
|
+
|
76
|
+
def octopus_deploy_project_group(*url_and_api_key, project_group_name)
|
77
|
+
url, apikey = get_octopus_creds(url_and_api_key)
|
78
|
+
octopus_deploy_projectgroup(url, apikey, project_group_name)
|
79
|
+
end
|
80
|
+
|
81
|
+
def octopus_project_group(*url_and_api_key, project_group_name)
|
82
|
+
url, apikey = get_octopus_creds(url_and_api_key)
|
83
|
+
octopus_deploy_projectgroup(url, apikey, project_group_name)
|
84
|
+
end
|
85
|
+
|
86
|
+
def octopus_projectgroup(*url_and_api_key, project_group_name) # deprecated - no underscore in name
|
87
|
+
url, apikey = get_octopus_creds(url_and_api_key)
|
88
|
+
octopus_deploy_projectgroup(url, apikey, project_group_name)
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def get_project_group_via_api(serverUrl, apiKey, project_group_name)
|
94
|
+
pg = nil
|
95
|
+
|
96
|
+
raise "'project_group_name' not supplied" if(project_group_name.nil? || project_group_name == '')
|
97
|
+
|
98
|
+
unless @spaceId.nil?
|
99
|
+
@spaceFragment = "#{@spaceId}/"
|
100
|
+
end
|
101
|
+
|
102
|
+
url = "#{serverUrl}/api/#{@spaceFragment}projectgroups/all?api-key=#{apiKey}"
|
103
|
+
|
104
|
+
begin
|
105
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
106
|
+
body = JSON.parse(resp.body)
|
107
|
+
pg = body.select {|i| i['Name'] == project_group_name }.first unless body.nil?
|
108
|
+
rescue => e
|
109
|
+
raise "get_project_group_via_api: Unable to connect to #{url}: #{e}"
|
110
|
+
end
|
111
|
+
|
112
|
+
pg
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_space_id?(space_name)
|
116
|
+
url = "#{@serverUrl}/api/Spaces/all?api-key=#{@apiKey}"
|
117
|
+
begin
|
118
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
119
|
+
spaces = JSON.parse(resp.body)
|
120
|
+
space_id = spaces.select {|e| e["Name"] == space_name}.first["Id"]
|
121
|
+
rescue
|
122
|
+
raise "get_space_id: unable to connect to #{url}: #{e}"
|
123
|
+
end
|
124
|
+
space_id
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
128
|
include Serverspec::Type
|