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
@default_action = {}
@certificate = {}
@redirect_config = {}
@results = { 'Listeners' => [] }
@response = { 'DescribeListenersResult' => {}, 'ResponseMetadata' => {} }
end
@ -26,12 +27,25 @@ module Fog
end
def end_element(name)
if @in_default_actions
case name
when 'member'
if @in_default_actions
@listener['DefaultActions'] << @default_action
@default_action = {}
elsif @in_certificates
when 'Type', 'TargetGroupArn'
@default_action[name] = value
when 'Path', 'Protocol', 'Port', 'Query', 'Host', 'StatusCode'
@redirect_config[name] = value
when 'RedirectConfig'
@default_action[name] = @redirect_config
@redirect_config = {}
when 'DefaultActions'
@in_default_actions = false
end
else
case name
when 'member'
if @in_certificates
@listener['Certificates'] << @certificate
@certificate = {}
else
@ -40,13 +54,8 @@ module Fog
end
when 'LoadBalancerArn', 'Protocol', 'Port', 'ListenerArn'
@listener[name] = value
when 'Type', 'TargetGroupArn'
@default_action[name] = value
when 'CertificateArn'
@certificate[name] = value
when 'DefaultActions'
@in_default_actions = false
when 'Certificates'
@in_certificates = false
@ -65,3 +74,4 @@ module Fog
end
end
end
end

View file

@ -14,6 +14,15 @@ DESCRIBE_LISTENERS_RESULT = <<-EOF
<member>
<Type>forward</Type>
<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>
</DefaultActions>
<Certificates>

View file

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