3 D\@s8dZddlZddlmZddlmZGdddeZdS)a Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. N)CloudFormationLintRule) RuleMatchc@s0eZdZdZdZdZdZdZddgZdd Z d S) Selectz"Check if Select values are correctZE1017zSelect validation of parametersz'Making sure the function not is of listzghttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-select.htmlZ functionsselectcCs6g}|jd}dddddddg}x|D]}|d}|d d}t|trt|d kr|d }|d } t|trt|d krx|jD]6\} } | dkrd } |jt|| jdj t t |qWnXt|t j s y t|Wn<tk rd} |jt|| jdj t t |YnXt| trt| d krxn| jD]:\} } | |krDd} |jt|| jdj t t |qDWn&d} |jt|| jdj t t |n2t| tsd} |jt|| jdj t t |n&d} |jt|| jdj t t |q(d} |jt|| jdj t t |q(W|S)zCheck CloudFormation Selectz Fn::Select Fn::FindInMapz Fn::GetAttz Fn::GetAZszFn::Ifz Fn::SplitzFn::CidrRefNrzHSelect index should be an Integer or a function Ref or FindInMap for {0}/zKSelect index should be an Integer or a function of Ref or FindInMap for {0}z-Select should use a supported function of {0}z, z+Select should be an array of values for {0}z-Select should be a list of 2 elements for {0}r )rr)Zsearch_deep_keys isinstancelistlendictitemsappendrformatjoinmapstrsix integer_typesint ValueError)selfZcfnmatchesZ select_objsZsupported_functionsZ select_objZselect_value_objtreeZ index_objZ list_of_objsZ index_key_messagekeyr x/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/functions/Select.pymatchsf     " "  $  z Select.matchN) __name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsr"r r r r!rsr)r&rZcfnlintrrrr r r r!s