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

Add dhall-kubernetes support for "schemas" #84

Merged
merged 4 commits into from
Nov 18, 2019

Conversation

Gabriella439
Copy link
Contributor

For lack of a better term, I'm calling the { Type = …, default = … }
record that the record completion operator expects a "schema". This
change adds dhall-kubernetes support for auto-generating these schemas
for ease of use with the new :: operator.

See the included example for how this would be used

For lack of a better term, I'm calling the `{ Type = …, default = … }`
record that the record completion operator expects a "schema".  This
change adds `dhall-kubernetes` support for auto-generating these schemas
for ease of use with the new `::` operator.

See the included example for how this would be used
@arianvp
Copy link
Member

arianvp commented Oct 19, 2019

Great stuff Gabriel!

}
, template = kubernetes.PodTemplateSpec::{
, metadata = kubernetes.ObjectMeta::{
, name = name
Copy link
Member

Choose a reason for hiding this comment

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

This is one of the places where I think you can ommit the metadata.name attribute
This is a manifestation of #8 (comment) I think the ground rule is that only toplevel objects need name, any template objects can (and must?) omit it instead.

I think if you explicitly set metadata.name here, really weird things might happen. Every pod will have the same name, e.g. there will never be more than 1 pod created eventhough the daemonset wants to create more than 1.

Also I think you must set template.selector otherwise the pods that the daemonset will create will not associate with the daemonset (See https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/)
It used to be the case that if you left out selector that it would be implicitly created, but I think that behaviour was removed recently. At least for Deployment; maybe not for daemonset.

I'm poking @akshaymankar here just to be sure.

Copy link
Member

@arianvp arianvp Oct 19, 2019

Choose a reason for hiding this comment

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

This is a bug that we should fix. name should not be a required attribute of ObjectMeta. The bug issue is #8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I only added the name field because the type required it

For reference, this is based off of: https://github.com/helm/charts/blob/550096fcda27d7637a7a066240c61a4c6cb61f21/stable/aws-iam-authenticator/templates/daemonset.yaml

Copy link
Member

@arianvp arianvp Oct 19, 2019

Choose a reason for hiding this comment

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

Ah yeh that chart uses an older version of the DaemonSet API. Ours requires the selector: https://github.com/dhall-lang/dhall-kubernetes/blob/master/types/io.k8s.api.apps.v1.DaemonSetSpec.dhall so your example will hopefully give you a nice type error! (Woohoo dhall types!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arianvp: The example type-checks because the default record for DaemonSetSpec defines an empty selector field

Copy link
Member

Choose a reason for hiding this comment

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

Ahh yes. I remember now. We have a bug open for this as well :) #78

Choose a reason for hiding this comment

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

I think if you explicitly set metadata.name here, really weird things might happen.

I checked with a daemonset, nothing weird happened, the controller just ignored the name field while creating pods. But it might confuse somebody reading a config.

Also I think you must set template.selector

This is true, if you don't set it, it is a validation error, but only for daemonsets. Not sure if this should be a type error given the OpenAPI spec doesn't say anything about it.

arianvp added a commit that referenced this pull request Oct 19, 2019
It is only required for top-level objects .  (E.g. `Deployment`, `Pod`, `DaemonSet`) but it is Optional when it is part of a compond object
(e.g. `PodTemplateSpec` inside a `Deployment` or `DaemonSet`)


See #8 (comment)
and #84 (comment)
@amarrella
Copy link
Collaborator

Hi :) This PR would be great to use for us but I was waiting for it to be merged to master before starting using it in https://github.com/EarnestResearch/dhall-packages . Do you think this is the final state this will be done in master? If yes, I could risk starting using this branch as the syntax is much better with schemas :)

@Gabriella439
Copy link
Contributor Author

At this point I think we should just merge this and if there are any additional changes they should be made as additional pull requests because I don't see a concrete action item from reviewers. If I don't hear otherwise I'm going to merge tomorrow

@Gabriella439 Gabriella439 merged commit fee24c0 into master Nov 18, 2019
@Gabriella439 Gabriella439 deleted the gabriel/schema_support_2 branch November 18, 2019 16:22
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

Successfully merging this pull request may close these issues.

4 participants