dstandish edited a comment on pull request #13209:
URL: https://github.com/apache/airflow/pull/13209#issuecomment-792881023
@mik-laj @ianstanton after taking another look at this i thought that
adding the namedtuple in this case was maybe a little overkill / confusing
because the elements are never accessed it's just a way constructing a key in
the dict for the URL lookup, given the two components -- api version and kind.
can you please take a look and let me know what you think of this perhaps
simpler (though less explicit) alternative.
and maybe you have a better suggestion.
```python
crd_lookup = {
'keda.sh/v1alpha1::ScaledObject':
'https://raw.githubusercontent.com/kedacore/keda/v2.0.0/config/crd/bases/keda.sh_scaledobjects.yaml',
}
...
def get_schema_crd(api_version, kind):
url = crd_lookup.get(f"{api_version}::{kind}")
if not url:
return None
response = requests.get(url)
yaml_schema = response.content.decode('utf-8')
schema = yaml.safe_load(StringIO(yaml_schema))
return schema
```
so i'm just joining the two components with `::` to make a string that's
pretty straightforward to understand so that we don't need the extra K8sObject
namedtuple. Also leaving the key as a regular tuple does work but end up much
uglier with line breaks.
i'm gonna just go ahead and add this in a second commit and request review
and go from there
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]