pact_broker-client 1.40.0 → 1.45.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +21 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +57 -0
  5. data/Gemfile +4 -0
  6. data/README.md +39 -22
  7. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -280
  8. data/lib/pact_broker/client/backports.rb +9 -0
  9. data/lib/pact_broker/client/base_command.rb +98 -0
  10. data/lib/pact_broker/client/can_i_deploy.rb +57 -5
  11. data/lib/pact_broker/client/cli/broker.rb +23 -76
  12. data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
  13. data/lib/pact_broker/client/cli/deployment_commands.rb +94 -0
  14. data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
  15. data/lib/pact_broker/client/cli/pacticipant_commands.rb +53 -0
  16. data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
  17. data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
  18. data/lib/pact_broker/client/colorize_notices.rb +31 -0
  19. data/lib/pact_broker/client/deployments.rb +4 -0
  20. data/lib/pact_broker/client/deployments/record_deployment.rb +38 -0
  21. data/lib/pact_broker/client/deployments/record_release.rb +99 -0
  22. data/lib/pact_broker/client/deployments/record_support_ended.rb +103 -0
  23. data/lib/pact_broker/client/deployments/record_undeployment.rb +127 -0
  24. data/lib/pact_broker/client/describe_text_formatter.rb +23 -0
  25. data/lib/pact_broker/client/environments.rb +6 -0
  26. data/lib/pact_broker/client/environments/create_environment.rb +31 -0
  27. data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
  28. data/lib/pact_broker/client/environments/describe_environment.rb +26 -0
  29. data/lib/pact_broker/client/environments/environment_command.rb +66 -0
  30. data/lib/pact_broker/client/environments/list_environments.rb +30 -0
  31. data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
  32. data/lib/pact_broker/client/environments/update_environment.rb +31 -0
  33. data/lib/pact_broker/client/generate_display_name.rb +27 -0
  34. data/lib/pact_broker/client/hal/entity.rb +31 -6
  35. data/lib/pact_broker/client/hal/http_client.rb +8 -2
  36. data/lib/pact_broker/client/hal/link.rb +8 -0
  37. data/lib/pact_broker/client/hal_client_methods.rb +1 -3
  38. data/lib/pact_broker/client/matrix.rb +4 -0
  39. data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
  40. data/lib/pact_broker/client/matrix/resource.rb +26 -1
  41. data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
  42. data/lib/pact_broker/client/pacticipants.rb +6 -0
  43. data/lib/pact_broker/client/pacticipants/create.rb +24 -34
  44. data/lib/pact_broker/client/pacticipants/describe.rb +33 -0
  45. data/lib/pact_broker/client/pacticipants/list.rb +34 -0
  46. data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
  47. data/lib/pact_broker/client/publish_pacts.rb +6 -2
  48. data/lib/pact_broker/client/string_refinements.rb +56 -0
  49. data/lib/pact_broker/client/version.rb +1 -1
  50. data/lib/pact_broker/client/versions.rb +4 -1
  51. data/lib/pact_broker/client/versions/describe.rb +3 -1
  52. data/lib/pact_broker/client/versions/formatter.rb +3 -1
  53. data/lib/pact_broker/client/versions/json_formatter.rb +5 -3
  54. data/lib/pact_broker/client/versions/text_formatter.rb +3 -1
  55. data/pact-broker-client.gemspec +2 -0
  56. data/script/approve-all.sh +6 -0
  57. data/script/publish-pact.sh +12 -9
  58. data/script/record-deployments-and-releases.sh +18 -0
  59. data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +7 -0
  60. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
  61. data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +7 -0
  62. data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
  63. data/spec/fixtures/approvals/describe_pacticipant.approved.txt +2 -0
  64. data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
  65. data/spec/integration/describe_environment_spec.rb +31 -0
  66. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +109 -7
  67. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +19 -6
  68. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
  69. data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
  70. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
  71. data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +204 -0
  72. data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +208 -0
  73. data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +219 -0
  74. data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
  75. data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
  76. data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
  77. data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
  78. data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
  79. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +2 -2
  80. data/spec/pacts/pact_broker_client-pact_broker.json +88 -287
  81. data/spec/service_providers/create_environment_spec.rb +78 -0
  82. data/spec/service_providers/list_environments_spec.rb +77 -0
  83. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
  84. data/spec/service_providers/pact_broker_client_register_repository_spec.rb +2 -2
  85. data/spec/service_providers/pacticipants_create_spec.rb +5 -4
  86. data/spec/service_providers/publish_pacts_spec.rb +5 -2
  87. data/spec/service_providers/record_deployment_spec.rb +17 -36
  88. data/spec/service_providers/record_release_spec.rb +132 -0
  89. data/spec/service_providers/record_undeployment_spec.rb +166 -0
  90. data/spec/spec_helper.rb +15 -2
  91. data/spec/support/approvals.rb +26 -0
  92. data/spec/support/shared_context.rb +8 -3
  93. data/tasks/pact.rake +21 -1
  94. metadata +104 -7
  95. data/lib/pact_broker/client/versions/record_deployment.rb +0 -109
  96. data/lib/pact_broker/client/versions/record_undeployment.rb +0 -102
  97. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +0 -82
@@ -0,0 +1,70 @@
1
+ module PactBroker
2
+ module Client
3
+ module CLI
4
+ module EnvironmentCommands
5
+ ENVIRONMENT_PARAM_NAMES = [:name, :display_name, :production, :contact_name, :contact_email_address]
6
+
7
+ def self.included(thor)
8
+ thor.class_eval do
9
+ def self.shared_environment_options(name_required: false)
10
+ method_option :name, required: name_required, desc: "The uniquely identifying name of the environment as used in deployment code"
11
+ method_option :display_name, desc: "The display name of the environment"
12
+ method_option :production, type: :boolean, default: false, desc: "Whether or not this environment is a production environment. Default: false"
13
+ method_option :contact_name, required: false, desc: "The name of the team/person responsible for this environment"
14
+ method_option :contact_email_address, required: false, desc: "The email address of the team/person responsible for this environment"
15
+ output_option_json_or_text
16
+ end
17
+
18
+ desc "create-environment", "Create an environment resource in the Pact Broker to represent a real world deployment or release environment."
19
+ shared_environment_options(name_required: true)
20
+ shared_authentication_options
21
+ def create_environment
22
+ execute_environment_command(params_from_options(ENVIRONMENT_PARAM_NAMES), "CreateEnvironment")
23
+ end
24
+
25
+ desc "update-environment", "Update an environment resource in the Pact Broker."
26
+ method_option :uuid, required: true, desc: "The UUID of the environment to update"
27
+ shared_environment_options(name_required: false)
28
+ shared_authentication_options
29
+ def update_environment
30
+ execute_environment_command(params_from_options(ENVIRONMENT_PARAM_NAMES + [:uuid]), "UpdateEnvironment")
31
+ end
32
+
33
+ desc "describe-environment", "Describe an environment"
34
+ method_option :uuid, required: true, desc: "The UUID of the environment to describe"
35
+ method_option :output, aliases: "-o", desc: "json or text", default: 'text'
36
+ shared_authentication_options
37
+ def describe_environment
38
+ execute_environment_command(params_from_options([:uuid]), "DescribeEnvironment")
39
+ end
40
+
41
+ desc "list-environments", "List environment"
42
+ method_option :output, aliases: "-o", desc: "json or text", default: 'text'
43
+ shared_authentication_options
44
+ def list_environments
45
+ execute_environment_command({}, "ListEnvironments")
46
+ end
47
+
48
+ desc "delete-environment", "Delete an environment"
49
+ method_option :uuid, required: true, desc: "The UUID of the environment to delete"
50
+ method_option :output, aliases: "-o", desc: "json or text", default: 'text'
51
+ shared_authentication_options
52
+ def delete_environment
53
+ execute_environment_command(params_from_options([:uuid]), "DeleteEnvironment")
54
+ end
55
+
56
+ no_commands do
57
+ def execute_environment_command(params, command_class_name)
58
+ require 'pact_broker/client/environments'
59
+ command_options = { verbose: options.verbose, output: options.output }
60
+ result = PactBroker::Client::Environments.const_get(command_class_name).call(params, command_options, pact_broker_client_options)
61
+ $stdout.puts result.message
62
+ exit(1) unless result.success
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,53 @@
1
+ module PactBroker
2
+ module Client
3
+ module CLI
4
+ module PacticipantCommands
5
+ PACTICIPANT_PARAM_NAMES = [:name, :display_name, :repository_url]
6
+
7
+ def self.included(thor)
8
+ thor.class_eval do
9
+ desc 'create-or-update-pacticipant', 'Create or update pacticipant by name'
10
+ method_option :name, type: :string, required: true, desc: "Pacticipant name"
11
+ method_option :display_name, type: :string, desc: "Display name"
12
+ method_option :repository_url, type: :string, required: false, desc: "The repository URL of the pacticipant"
13
+ output_option_json_or_text
14
+ shared_authentication_options
15
+ verbose_option
16
+
17
+ def create_or_update_pacticipant(*required_but_ignored)
18
+ raise ::Thor::RequiredArgumentMissingError, "Pacticipant name cannot be blank" if options.name.strip.size == 0
19
+ execute_pacticipant_command(params_from_options(PACTICIPANT_PARAM_NAMES), 'Create')
20
+ end
21
+
22
+ desc 'list-pacticipants', 'List pacticipants'
23
+ output_option_json_or_text
24
+ shared_authentication_options
25
+ verbose_option
26
+ def list_pacticipants
27
+ execute_pacticipant_command(params_from_options(PACTICIPANT_PARAM_NAMES), 'List')
28
+ end
29
+
30
+ desc 'describe-pacticipant', "Describe a pacticipant"
31
+ method_option :name, type: :string, required: true, desc: "Pacticipant name"
32
+ output_option_json_or_text
33
+ shared_authentication_options
34
+ verbose_option
35
+ def describe_pacticipant
36
+ execute_pacticipant_command({ name: options.name }, 'Describe')
37
+ end
38
+
39
+ no_commands do
40
+ def execute_pacticipant_command(params, command_class_name)
41
+ require 'pact_broker/client/pacticipants'
42
+ command_options = { verbose: options.verbose, output: options.output }
43
+ result = PactBroker::Client::Pacticipants2.const_get(command_class_name).call(params, command_options, pact_broker_client_options)
44
+ $stdout.puts result.message
45
+ exit(1) unless result.success
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,55 +0,0 @@
1
- The record-deployment command is used to allow the Pact Broker to keep track of which version(s) of an application are currently deployed in each environment. It is used to keep track of applications that are deployed to known instances. If you are releasing a client library or mobile application to a repository or application store, please use record-release instead.
2
-
3
- ## Examples
4
-
5
-
6
- record-deployment --pacticipant Foo --version 6897aa95e --environment production
7
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target blue
8
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target green
9
-
10
- ## Target
11
-
12
- The "target" field is used to distinguish between deployed versions of an application within the same environment, and most importantly, to identify which previously deployed version has been replaced by the current deployment. The Pact Broker only allows one unique combination of pacticipant/environment/target to be considered the "currently deployed" one, and any call to record a deployment will cause the previously deployed version with the same pacticipant/environment/target to be automatically marked as undeployed (mimicking the real world process of "deploying over" a previous version).
13
-
14
- ### Use cases
15
-
16
- #### There is a single instance of an application deployed within an environment and deployments of integrated applications are NOT likely to happen during the deployment window of this application
17
-
18
- eg.
19
-
20
- * the window of time when there are multiple versions in prod is small
21
- * or there aren't many other integrations
22
- * or deployments happen rarely
23
- * or the same team controls all the deployments and generally only runs one deployment at a time
24
-
25
- In this case, there is no need to specify a target. The call to record deployment should be done at the end of the deployment and it will automatically mark the version of Foo that was previously the currently deployed version as undeployed. Only one version of the pacticipant is ever considered to be currently deployed at a time.
26
-
27
- eg.
28
-
29
- # actual call to deploy here...
30
- record-deployment --pacticipant Foo --version 6897aa95e --environment production
31
-
32
- #### There is a single instance of an application deployed within an environment and but deployments of integrated applications ARE likely to happen during the deployment window of this application
33
-
34
- eg.
35
- * the window of time when there are multiple versions in prod is large
36
- * or there are many integrations
37
- * or deployments happen often
38
- * or there are many different teams deploying and deployments aren't coordinated
39
-
40
- To allow multiple versions to be considered currently deployed at the same time, use two different targets, and call the first record-deployment at the start of the deployment process and a second one at the end.
41
-
42
- eg.
43
-
44
- This will use the targets "blue" and "green" to model stages of the deployment.
45
-
46
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target blue
47
- # actual call to deploy here...
48
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target green
49
-
50
- After the first call to record-deployment, there will be two versions considered currently deployed - the "blue" one that was just recorded, and the one from the previous "green" deployment. After the second call to record-deployment, there is only one version considered currently deployed - both "blue" and "green" targets will be have version 6897aa95e deployed to them.
51
-
52
-
53
- #### There are multiple permanent application versions deployed to the same environment
54
-
55
- TBC
@@ -12,6 +12,8 @@ module PactBroker
12
12
  case word
13
13
  when "--pacticipant", "-a"
14
14
  selectors << {}
15
+ when "--ignore"
16
+ selectors << { ignore: true }
15
17
  when "--latest", "-l"
16
18
  selectors << { pacticipant: nil } if selectors.empty?
17
19
  selectors.last[:latest] = true
@@ -21,6 +23,8 @@ module PactBroker
21
23
  case previous_option
22
24
  when "--pacticipant", "-a"
23
25
  selectors.last[:pacticipant] = word
26
+ when "--ignore"
27
+ selectors.last[:pacticipant] = word
24
28
  when "--version", "-e"
25
29
  selectors << { pacticipant: nil } if selectors.empty?
26
30
  selectors.last[:version] = word
@@ -0,0 +1,31 @@
1
+ require 'term/ansicolor'
2
+
3
+ module PactBroker
4
+ module Client
5
+ class ColorizeNotices
6
+ def self.call(notices)
7
+ notices.collect do | notice |
8
+ colorized_message(notice)
9
+ end
10
+ end
11
+
12
+ def self.colorized_message(notice)
13
+ color = color_for_type(notice.type)
14
+ if color
15
+ ::Term::ANSIColor.color(color, notice.text || '')
16
+ else
17
+ notice.text
18
+ end
19
+ end
20
+
21
+ def self.color_for_type(type)
22
+ case type
23
+ when "warning", "prompt" then "yellow"
24
+ when "error", "danger" then :red
25
+ when "success" then :green
26
+ else nil
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ require "pact_broker/client/deployments/record_deployment"
2
+ require "pact_broker/client/deployments/record_release"
3
+ require "pact_broker/client/deployments/record_undeployment"
4
+ require "pact_broker/client/deployments/record_support_ended"
@@ -0,0 +1,38 @@
1
+ require 'pact_broker/client/deployments/record_release'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Deployments
6
+ class RecordDeployment < PactBroker::Client::Deployments::RecordRelease
7
+ def initialize(params, options, pact_broker_client_options)
8
+ super
9
+ @target = params.fetch(:target)
10
+ end
11
+
12
+ private
13
+
14
+ attr_reader :target
15
+
16
+ def action
17
+ "deployment"
18
+ end
19
+
20
+ def action_relation_name
21
+ "pb:record-deployment"
22
+ end
23
+
24
+ def record_action_request_body
25
+ { target: target }.compact
26
+ end
27
+
28
+ def result_text_message
29
+ if target
30
+ "#{super} (target #{target})"
31
+ else
32
+ super
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,99 @@
1
+ require 'pact_broker/client/base_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Deployments
6
+ class RecordRelease < PactBroker::Client::BaseCommand
7
+ def initialize(params, options, pact_broker_client_options)
8
+ super
9
+ @pacticipant_name = params.fetch(:pacticipant_name)
10
+ @version_number = params.fetch(:version_number)
11
+ @environment_name = params.fetch(:environment_name)
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :pacticipant_name, :version_number, :environment_name
17
+ attr_reader :deployed_version_resource
18
+
19
+ def do_call
20
+ record_action
21
+ PactBroker::Client::CommandResult.new(true, result_message)
22
+ end
23
+
24
+ def action
25
+ "release"
26
+ end
27
+
28
+ def action_relation_name
29
+ "pb:record-release"
30
+ end
31
+
32
+ def not_supported_message
33
+ "This version of the Pact Broker does not support recording #{action}s. Please upgrade to version 2.80.0 or later."
34
+ end
35
+
36
+ def environment_exists?
37
+ index_resource
38
+ ._link!("pb:environments")
39
+ .get!
40
+ ._links("pb:environments")
41
+ .find(environment_name)
42
+ end
43
+
44
+ def record_action
45
+ @deployed_version_resource =
46
+ get_record_action_relation
47
+ .post(record_action_request_body)
48
+ .assert_success!
49
+ end
50
+
51
+ def record_action_links
52
+ get_pacticipant_version._links(action_relation_name) or raise PactBroker::Client::Error.new(not_supported_message)
53
+ end
54
+
55
+ def get_record_action_relation
56
+ record_action_links.find(environment_name) or record_action_links.find!(environment_name, environment_relation_not_found_error_message)
57
+ end
58
+
59
+ def environment_relation_not_found_error_message
60
+ if environment_exists?
61
+ "Environment '#{environment_name}' is not an available option for recording a deployment of #{pacticipant_name}."
62
+ else
63
+ "No environment found with name '#{environment_name}'."
64
+ end
65
+ end
66
+
67
+ def get_pacticipant_version
68
+ index_resource
69
+ ._link!("pb:pacticipant-version")
70
+ .expand(pacticipant: pacticipant_name, version: version_number)
71
+ .get
72
+ .assert_success!(404 => "#{pacticipant_name} version #{version_number} not found")
73
+ end
74
+
75
+ def record_action_request_body
76
+ {}
77
+ end
78
+
79
+ def result_message
80
+ if json_output?
81
+ deployed_version_resource.response.raw_body
82
+ else
83
+ green("#{result_text_message} in #{pact_broker_name}.")
84
+ end
85
+ end
86
+
87
+ def result_text_message
88
+ "Recorded #{action} of #{pacticipant_name} version #{version_number} to #{environment_name} environment"
89
+ end
90
+
91
+ def check_if_command_supported
92
+ unless index_resource.can?("pb:environments")
93
+ raise PactBroker::Client::Error.new(not_supported_message)
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,103 @@
1
+ require 'pact_broker/client/base_command'
2
+
3
+ module PactBroker
4
+ module Client
5
+ module Deployments
6
+ class RecordSupportEnded < PactBroker::Client::BaseCommand
7
+ def initialize(params, options, pact_broker_client_options)
8
+ super
9
+ @pacticipant_name = params.fetch(:pacticipant_name)
10
+ @environment_name = params.fetch(:environment_name)
11
+ @version_number = params.fetch(:version_number)
12
+ end
13
+
14
+ private
15
+
16
+ def do_call
17
+ if unsupported_versions_resources.empty?
18
+ PactBroker::Client::CommandResult.new(false, error_result_message)
19
+ else
20
+ PactBroker::Client::CommandResult.new(unsupported_versions_resources.all?(&:success?), result_message)
21
+ end
22
+ end
23
+
24
+ attr_reader :pacticipant_name, :environment_name, :version_number
25
+
26
+ def currently_supported_versions_link
27
+ environment_resource._link("pb:currently-supported-versions") or raise PactBroker::Client::Error.new(not_supported_message)
28
+ end
29
+
30
+ def currently_supported_version_entities_for_pacticipant_version
31
+ @deployed_version_links ||= currently_supported_versions_link.get!(pacticipant: pacticipant_name, version: version_number).embedded_entities!("releasedVersions")
32
+ end
33
+
34
+ def unsupported_versions_resources
35
+ @unsupported_versions_resources ||= currently_supported_version_entities_for_pacticipant_version.collect do | entity |
36
+ entity._link!("self").patch(currentlySupported: false)
37
+ end
38
+ end
39
+
40
+ def action
41
+ "undeployment"
42
+ end
43
+
44
+ def environment_resource
45
+ index_resource
46
+ ._link!("pb:environments")
47
+ .get!
48
+ ._links("pb:environments")
49
+ .find!(environment_name, "No environment found with name '#{environment_name}'")
50
+ .get!
51
+ end
52
+
53
+ def result_message
54
+ if json_output?
55
+ unsupported_versions_resources.collect{ | resource | resource.response.body }.to_a.to_json
56
+ else
57
+ unsupported_versions_resources.collect do | undeployed_versions_resource |
58
+ if undeployed_versions_resource.success?
59
+ green("#{success_result_text_message(undeployed_versions_resource)} in #{pact_broker_name}.")
60
+ else
61
+ red(undeployed_versions_resource.error_message)
62
+ end
63
+ end.join("\n")
64
+ end
65
+ end
66
+
67
+ def success_result_text_message(undeployed_versions_resource)
68
+ "Recorded support ended for #{pacticipant_name} version #{version_number} in #{environment_name} environment"
69
+ end
70
+
71
+ def error_result_message
72
+ if json_output?
73
+ error_message_as_json(error_text)
74
+ else
75
+ red(error_text)
76
+ end
77
+ end
78
+
79
+ def error_text
80
+ if pacticipant_does_not_exist?
81
+ "No pacticipant with name '#{pacticipant_name}' found."
82
+ else
83
+ "#{pacticipant_name} version #{version_number} is not currently released in #{environment_name} environment. Cannot record support ended."
84
+ end
85
+ end
86
+
87
+ def not_supported_message
88
+ "This version of the Pact Broker does not support recording end of support. Please upgrade to version 2.80.0 or later."
89
+ end
90
+
91
+ def pacticipant_does_not_exist?
92
+ index_resource._link("pb:pacticipant") && index_resource._link("pb:pacticipant").expand(pacticipant: pacticipant_name).get.does_not_exist?
93
+ end
94
+
95
+ def check_if_command_supported
96
+ unless index_resource.can?("pb:environments")
97
+ raise PactBroker::Client::Error.new(not_supported_message)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end