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

FR: Include openapi2jsonschema.py script in docker image #79

Open
mjpieters opened this issue Sep 27, 2021 · 5 comments
Open

FR: Include openapi2jsonschema.py script in docker image #79

mjpieters opened this issue Sep 27, 2021 · 5 comments

Comments

@mjpieters
Copy link

I'd love to use the docker image to validate helm charts in our projects, but we use a lot of CRDs. Some recent issues we had with our charts could have been caught much earlier if we had validated the charts against CRD schemas.

Those CRDs do have OpenAPI yaml definitions online, converting these (and caching the result) in a GH action for use with kubeconform would be ideal; your existing openapi2jsonschema.py script would allow us to do so all in one place if only it was included in the docker image.

Would you be able to update your Dockerfile to include it? Either as /openapi2jsonschema or /scripts/openapi2jsonschema.py, I don't much care. It would require that your alpine image includes Python 3 and pyyaml, of course.

My alternative right now is to use

curl -s https://raw.githubusercontent.com/yannh/kubeconform/v0.4.12/scripts/openapi2jsonschema.py > openapi2jsonschema
chmod +x openapi2jsonschema
python3 -m pip install pyyaml
./openapi2jsonschema ...

which is rather fragile as it either requires a version pin, or risks breaking if you ever moved the script or changed the requirements.

@yannh
Copy link
Owner

yannh commented Sep 27, 2021

And I was thinking about moving the script from /scripts to /openapi2jsonschema yesterday and was wondering whether people were doing that ;) I can provide a Docker image, yes, does it matter if its a different one than for kubeconform? They both have quite different requirements. Note that if you converted the CRDs once and checked those into version control, that could speed up your CI a bit, but it depends on your requirements :)

@mjpieters
Copy link
Author

I'd be fine with a separate Docker image :-)

As for the resulting schema files: I'd use the GitHub cache action to cache the conversion result rather than commit to the repo.

@slamdev
Copy link

slamdev commented Nov 10, 2021

it would be nice to have an official docker image. I am using this for now

FROM python:3.9.7-alpine3.14

ENV FILENAME_FORMAT='{kind}-{group}-{version}'

WORKDIR /opt

RUN wget -O /tmp/openapi2jsonschema https://raw.githubusercontent.com/yannh/kubeconform/v0.4.12/scripts/openapi2jsonschema.py \
 && chmod +x /tmp/openapi2jsonschema \
 && python3 -m pip install pyyaml

ENTRYPOINT ["/tmp/openapi2jsonschema"]
docker build -t openapi2jsonschema .
docker run -v "$(pwd)/generated:/opt" openapi2jsonschema "http://...."

@james-callahan
Copy link

@yannh I'd still love to see this happen.

@james-callahan
Copy link

@yannh ping?

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

4 participants