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 ForwardConfig in listeners parser

This commit is contained in:
KevinLoiseau 2019-11-26 16:12:56 +01:00
parent f195b59528
commit eea4e0fa45
No known key found for this signature in database
GPG key ID: 709159A779B96CC3
3 changed files with 66 additions and 9 deletions

View file

@ -7,7 +7,10 @@ module Fog
reset_listener
@default_action = {}
@certificate = {}
@redirect_config = {}
@config = {}
@target_groups = []
@target_group = {}
@target_group_stickiness_config = {}
@results = { 'Listeners' => [] }
@response = { 'DescribeListenersResult' => {}, 'ResponseMetadata' => {} }
end
@ -23,6 +26,10 @@ module Fog
@in_default_actions = true
when 'Certificates'
@in_certificates = true
when 'TargetGroups'
@in_target_groups = true
when 'TargetGroupStickinessConfig'
@in_target_group_stickiness_config = true
end
end
@ -30,17 +37,42 @@ module Fog
if @in_default_actions
case name
when 'member'
if @in_target_groups
@target_groups << @target_group
@target_group = {}
else
@listener['DefaultActions'] << @default_action
@default_action = {}
when 'Type', 'TargetGroupArn'
end
when 'TargetGroupArn'
if @in_target_groups
@target_group[name] = value
else
@default_action[name] = value
end
when 'Weight'
@target_group[name] = value
when 'Type'
@default_action[name] = value
when 'Path', 'Protocol', 'Port', 'Query', 'Host', 'StatusCode'
@redirect_config[name] = value
when 'RedirectConfig'
@default_action[name] = @redirect_config
@redirect_config = {}
@config[name] = value
when 'RedirectConfig', 'ForwardConfig'
@default_action[name] = @config
@config = {}
when 'DurationSeconds', 'Enabled'
@target_group_stickiness_config[name] = value
when 'DefaultActions'
@in_default_actions = false
when 'TargetGroupStickinessConfig'
if @in_target_group_stickiness_config
@config['TargetGroupStickinessConfig'] = @target_group_stickiness_config
@in_target_group_stickiness_config = false
@target_group_stickiness_config = {}
end
when 'TargetGroups'
@config['TargetGroups'] = @target_groups
@in_target_groups = false
@target_groups = []
end
else
case name

View file

@ -31,6 +31,30 @@ DESCRIBE_LISTENERS_RESULT = <<-EOF
</member>
</Certificates>
</member>
<member>
<LoadBalancerArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188</LoadBalancerArn>
<Protocol>HTTPS</Protocol>
<Port>80</Port>
<ListenerArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2</ListenerArn>
<DefaultActions>
<member>
<Type>forward</Type>
<TargetGroupArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067</TargetGroupArn>
<ForwardConfig>
<TargetGroupStickinessConfig><Enable>true</Enable></TargetGroupStickinessConfig>
<TargetGroups>
<Weight>1</Weight>
<TargetGroupArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067</TargetGroupArn>
</TargetGroups>
</ForwardConfig>
</member>
</DefaultActions>
<Certificates>
<member>
<CertificateArn>arn:aws:elasticloadbalancing:us-west-2:123456789012:certificate/56d36256-1245-40d6-916e-6f5a95e2b4c6</CertificateArn>
</member>
</Certificates>
</member>
</Listeners>
</DescribeListenersResult>
<ResponseMetadata>

View file

@ -33,7 +33,8 @@ class AWS
LISTENER_DEFAULT_ACTIONS = [{
"Type" => String,
"TargetGroupArn" => String,
"RedirectConfig" => Fog::Nullable::Hash
"RedirectConfig" => Fog::Nullable::Hash,
"ForwardConfig" => Fog::Nullable::Hash
}]
LISTENER = {