Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi2jsonschema.py fails for AlertmanagerConfig #103

Closed
pSub opened this issue Apr 5, 2022 · 1 comment
Closed

openapi2jsonschema.py fails for AlertmanagerConfig #103

pSub opened this issue Apr 5, 2022 · 1 comment

Comments

@pSub
Copy link

pSub commented Apr 5, 2022

I tried to integrate kubeconform into the CI workflow of an internal project. On the intial run

helm template . | kubeconform

it had trouble finding the schemas for

  • ExternalSecret
  • AlertmanagerConfig
  • PrometheusRule
  • ServiceMonitors

I followed the advice in #51 (comment) to generate a schema using openapi2jsonschema.py from the OpenAPI-Specs provided for AlertmanagerConfig, PrometheusRule and ServiceMonitors.

It worked for ServiceMonitors and PrometheusRule but failed for AlertmanagerConfig with the following error:

convert-crd_1  | Traceback (most recent call last):
convert-crd_1  |   File "/apps/convert/openapi2jsonschema.py", line 123, in <module>
convert-crd_1  |     for y in yaml.load_all(f, Loader=yaml.SafeLoader):
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/__init__.py", line 93, in load_all
convert-crd_1  |     yield loader.get_data()
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 45, in get_data
convert-crd_1  |     return self.construct_document(self.get_node())
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 60, in construct_document
convert-crd_1  |     for dummy in generator:
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 408, in construct_yaml_seq
convert-crd_1  |     data.extend(self.construct_sequence(node))
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 129, in construct_sequence
convert-crd_1  |     return [self.construct_object(child, deep=deep)
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 129, in <listcomp>
convert-crd_1  |     return [self.construct_object(child, deep=deep)
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 100, in construct_object
convert-crd_1  |     data = constructor(self, node)
convert-crd_1  |   File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 427, in construct_undefined
convert-crd_1  |     raise ConstructorError(None, None,
convert-crd_1  | yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:value'
convert-crd_1  |   in "<file>", line 3916, column 29

https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml

eyarz pushed a commit to eyarz/kubeconform that referenced this issue Apr 5, 2022
Equal sign (=) was not parsed properly by pyyaml.
Added constructor to parse equal sign as string.
Related issue: yannh#103
@eyarz
Copy link
Contributor

eyarz commented Apr 5, 2022

I submitted a PR to fix that.
In the meanwhile, you can this version of JSON Schema that I have created from your YAML:
https://gist.github.com/eyarz/c2c5665a877491f7fc0e84176fff8011

yannh pushed a commit that referenced this issue Apr 6, 2022
Equal sign (=) was not parsed properly by pyyaml.
Added constructor to parse equal sign as string.
Related issue: #103
@yannh yannh closed this as completed Apr 11, 2022
yannh pushed a commit that referenced this issue Oct 16, 2022
Equal sign (=) was not parsed properly by pyyaml.
Added constructor to parse equal sign as string.
Related issue: #103
yannh pushed a commit that referenced this issue Oct 16, 2022
Equal sign (=) was not parsed properly by pyyaml.
Added constructor to parse equal sign as string.
Related issue: #103
yannh pushed a commit that referenced this issue Nov 10, 2022
* add constructor to handle equal sign (=)

Equal sign (=) was not parsed properly by pyyaml.
Added constructor to parse equal sign as string.
Related issue: #103

* Update Readme.md
yannh pushed a commit that referenced this issue Nov 10, 2022
* add constructor to handle equal sign (=)

Equal sign (=) was not parsed properly by pyyaml.
Added constructor to parse equal sign as string.
Related issue: #103

* Update Readme.md

* Update Readme.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants