← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:feature/ec2-ds-warn into cloud-init:master

 



>> +Platforms = _PoorMansEnum(
>> +    ALIYUN="AliYun",
>> +    GENUINE_AWS="GenuineAWS",
>> +    UNKNOWN="Unknown",
>> +)
>
>This seems unnecessarily clever.  Why not just:
>
>  class Platforms:
>    ALIYUN = 1
>    GENUINE_AWS = 2
>    UNKNOWN = 3
>
>Then you can still do things like:
>
>  return EC2.Platforms.ALIYUN
>

That's a fair point. And that's what I started with. I got clever when wanting/needing to allow configuration in datasource config. 

Then, the strings provided from config has to compare to the 'enum' values. 

See below in the change.

Thanks for the review. I do mostly agree


>Or:
>
>  if self.cloud_platform == Platforms.UNKNOWN
>
>> +
>> +LOOKALIKE_DEFAULT = {
>> +    'behavior': 'skip',
>> +    'platform': Platforms.UNKNOWN,
>> +    'sleep': 10,
>> +}
>> +
>>  
>>  class DataSourceEc2(sources.DataSource):
>>      # Default metadata urls that will be used if none are provided

-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/316033
Your team cloud init development team is requested to review the proposed merge of ~smoser/cloud-init:feature/ec2-ds-warn into cloud-init:master.


References