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

dhall-openapi: make metadata optional for "inner" k8s types #2128

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

WillSewell
Copy link
Collaborator

@WillSewell WillSewell commented Jan 6, 2021

The metadata field is required for all top level resources
according to
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata.

However for "inner" types this is not the case. For example
io.k8s.api.batch.v1beta1.JobTemplateSpec has a metadata field,
but it is not required. The example in the official k8s docs does
not include this field:
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#example.

I searched the kubernetes 1.17 OpenAPI spec for "inner" types
that include a metadata field with:

curl -s https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.17/api/openapi-spec/swagger.json | jq '.definitions | with_entries(select(.value.properties.apiVersion == null and .value.properties.metadata != null))'

It came up with:

  • io.k8s.api.batch.v1beta1.JobTemplateSpec
  • io.k8s.api.batch.v2alpha1.JobTemplateSpec
  • io.k8s.api.core.v1.PodTemplateSpec

The pod spec template example in
https://kubernetes.io/docs/concepts/workloads/pods/
also does not include a metadata field.

This PR adds special cases to these types to make these fields
optional.

In general I think a nicer solution would be
dhall-lang/dhall-kubernetes#8 (comment).

@WillSewell
Copy link
Collaborator Author

Thanks for reviewing @muff1nman. I'm conscious that this will lead to a breaking change in the dhall generated in dhall-kubernetes. Do you see this being a problem given release branches are not being used in that repository?

@Gabriella439
Copy link
Collaborator

@WillSewell: We don't have release branches in dhall-kubernetes, but we do have release tags. If you want, I can cut a new release tag before we incorporate this change

Either way, I think this is totally fine to merge

Copy link
Collaborator

@Gabriella439 Gabriella439 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just cut a 5.0.0 release for dhall-kubernetes so this should be good to go

The `metadata` field is required for all top level resources
according to
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata.

However for "inner" types this is not the case. For example
`io.k8s.api.batch.v1beta1.JobTemplateSpec` has a `metadata` field,
but it is not required. The example in the official k8s docs does
not include this field:
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#example.

I searched the kubernetes 1.17 OpenAPI spec for "inner" types
that include a `metadata` field with:

```
curl -s https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.17/api/openapi-spec/swagger.json | jq '.definitions | with_entries(select(.value.properties.apiVersion == null and .value.properties.metadata != null))'
```

It came up with:

* io.k8s.api.batch.v1beta1.JobTemplateSpec
* io.k8s.api.batch.v2alpha1.JobTemplateSpec
* io.k8s.api.core.v1.PodTemplateSpec

The pod spec template example in
https://kubernetes.io/docs/concepts/workloads/pods/
also does not include a `metadata` field.

This PR adds special cases to these types to make these fields
optional.
@WillSewell WillSewell force-pushed the openapi-optional-metadata branch from 84c06c2 to 10fc1ce Compare January 8, 2021 10:59
@mergify mergify bot merged commit eb77c42 into dhall-lang:master Jan 8, 2021
@WillSewell WillSewell deleted the openapi-optional-metadata branch January 8, 2021 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants