1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Take care of RedirectConfig in listeners parser

This commit is contained in:
KevinLoiseau 2019-11-26 11:35:33 +01:00
parent 4ef5513890
commit f195b59528
No known key found for this signature in database
GPG key ID: 709159A779B96CC3
3 changed files with 52 additions and 27 deletions

View file

@ -7,6 +7,7 @@ module Fog
reset_listener reset_listener
@default_action = {} @default_action = {}
@certificate = {} @certificate = {}
@redirect_config = {}
@results = { 'Listeners' => [] } @results = { 'Listeners' => [] }
@response = { 'DescribeListenersResult' => {}, 'ResponseMetadata' => {} } @response = { 'DescribeListenersResult' => {}, 'ResponseMetadata' => {} }
end end
@ -26,38 +27,47 @@ module Fog
end end
def end_element(name) def end_element(name)
case name if @in_default_actions
when 'member' case name
if @in_default_actions when 'member'
@listener['DefaultActions'] << @default_action @listener['DefaultActions'] << @default_action
@default_action = {} @default_action = {}
elsif @in_certificates when 'Type', 'TargetGroupArn'
@listener['Certificates'] << @certificate @default_action[name] = value
@certificate = {} when 'Path', 'Protocol', 'Port', 'Query', 'Host', 'StatusCode'
else @redirect_config[name] = value
@results['Listeners'] << @listener when 'RedirectConfig'
reset_listener @default_action[name] = @redirect_config
@redirect_config = {}
when 'DefaultActions'
@in_default_actions = false
end end
when 'LoadBalancerArn', 'Protocol', 'Port', 'ListenerArn' else
@listener[name] = value case name
when 'Type', 'TargetGroupArn' when 'member'
@default_action[name] = value if @in_certificates
when 'CertificateArn' @listener['Certificates'] << @certificate
@certificate[name] = value @certificate = {}
else
@results['Listeners'] << @listener
reset_listener
end
when 'LoadBalancerArn', 'Protocol', 'Port', 'ListenerArn'
@listener[name] = value
when 'CertificateArn'
@certificate[name] = value
when 'Certificates'
@in_certificates = false
when 'DefaultActions' when 'RequestId'
@in_default_actions = false @response['ResponseMetadata'][name] = value
when 'Certificates'
@in_certificates = false
when 'RequestId' when 'NextMarker'
@response['ResponseMetadata'][name] = value @results['NextMarker'] = value
when 'NextMarker' when 'DescribeListenersResponse'
@results['NextMarker'] = value @response['DescribeListenersResult'] = @results
end
when 'DescribeListenersResponse'
@response['DescribeListenersResult'] = @results
end end
end end
end end

View file

@ -14,6 +14,15 @@ DESCRIBE_LISTENERS_RESULT = <<-EOF
<member> <member>
<Type>forward</Type> <Type>forward</Type>
<TargetGroupArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067</TargetGroupArn> <TargetGroupArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067</TargetGroupArn>
<RedirectConfig>
<Protocol>HTTPS</Protocol>
<Port>443</Port>
<Path>\#{path}</Path>
<Query>\#{query}</Query>
<Host>\#{host}</Host>
<StatusCode>HTTP_301</StatusCode>
<Type>redirect</Type>
</RedirectConfig>
</member> </member>
</DefaultActions> </DefaultActions>
<Certificates> <Certificates>

View file

@ -30,12 +30,18 @@ class AWS
'CreateLoadBalancerResult' => {'LoadBalancers' => [LOAD_BALANCER], 'NextMarker' => Fog::Nullable::String} 'CreateLoadBalancerResult' => {'LoadBalancers' => [LOAD_BALANCER], 'NextMarker' => Fog::Nullable::String}
}) })
LISTENER_DEFAULT_ACTIONS = [{
"Type" => String,
"TargetGroupArn" => String,
"RedirectConfig" => Fog::Nullable::Hash
}]
LISTENER = { LISTENER = {
"LoadBalancerArn" => String, "LoadBalancerArn" => String,
"Protocol" => String, "Protocol" => String,
"Port" => String, "Port" => String,
"ListenerArn" => String, "ListenerArn" => String,
"DefaultActions" => [{"Type" => String, "TargetGroupArn" => String}], "DefaultActions" => LISTENER_DEFAULT_ACTIONS,
"Certificates" => [{"CertificateArn" => String}] "Certificates" => [{"CertificateArn" => String}]
} }