-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into azure-bump-rebase
- Loading branch information
Showing
36 changed files
with
704 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module VCAP::CloudController | ||
class RouteDestinationUpdate | ||
class Error < StandardError | ||
end | ||
|
||
class << self | ||
def update(destination, message) | ||
validate_protocol_matches_route!(destination, message) | ||
|
||
destination.db.transaction do | ||
destination.lock! | ||
|
||
destination.protocol = message.protocol if message.requested? :protocol | ||
|
||
destination.save | ||
end | ||
end | ||
|
||
private | ||
|
||
def validate_protocol_matches_route!(destination, message) | ||
if destination.route&.protocol == 'tcp' | ||
unless message.protocol == 'tcp' | ||
raise Error.new("Destination protocol must be 'tcp' if the parent route's protocol is 'tcp'") | ||
end | ||
elsif message.protocol == 'tcp' | ||
raise Error.new("Destination protocol must be 'http1' or 'http2' if the parent route's protocol is 'http'") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module VCAP::CloudController | ||
class RouteDestinationUpdateMessage < BaseMessage | ||
def initialize(params) | ||
super(params) | ||
end | ||
|
||
def self.key_requested?(key) | ||
proc { |a| a.requested?(key) } | ||
end | ||
|
||
register_allowed_keys [:protocol] | ||
|
||
validates_with NoAdditionalKeysValidator | ||
|
||
validate :validate_protocol?, if: key_requested?(:protocol) | ||
|
||
private | ||
|
||
def validate_protocol? | ||
unless protocol.is_a?(String) && RouteMappingModel::VALID_PROTOCOLS.include?(protocol) | ||
errors.add(:destination, "protocol must be 'http1', 'http2' or 'tcp'.") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.