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 support for ListType, ListMapKeys, MapType and StructType #347

Merged
merged 3 commits into from
Dec 19, 2019

Conversation

apelisse
Copy link

@apelisse apelisse commented Oct 21, 2019

These two new markers allow support for associative lists and sets.

Fixes kubernetes-sigs/controller-runtime#638

This is clearly not done for many reasons:

  • Needs better documentation of many things
  • Needs additional validation logic

I think we can move with just these new markers and work on other markers when they are available in k/k: kubernetes/kubernetes#84113

@k8s-ci-robot
Copy link
Contributor

Welcome @apelisse!

It looks like this is your first PR to kubernetes-sigs/controller-tools 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-tools has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 21, 2019
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 21, 2019
@apelisse
Copy link
Author

cc @DirectXMan12

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

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

a few nits inline

}

// +controllertools:marker:generateHelp:category="CRD topology"
// ListType specifies the type of list. A list can be:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: split in their own paragraph

Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

specifies data structure the list represents (map, set, atomic).

a list may be....

// +controllertools:marker:generateHelp:category="CRD topology"
// ListType specifies the type of list. A list can be:
// - a "map": it needs to have a key field, which will be used to build an
// associative list.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe give examples from k8s

// ToplogyMarkers list topology markers (i.e. markers that specify if a
// list is an associative-list or a set, or if a map is atomic or not).
var TopologyMarkers = []*definitionWithHelp{
must(markers.MakeDefinition("listType", markers.DescribesField, ListType(""))),
Copy link
Contributor

Choose a reason for hiding this comment

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

list:type
list:key
??

Copy link
Author

Choose a reason for hiding this comment

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

too late :-/


func (l ListType) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error {
if schema.Type != "array" {
return fmt.Errorf("must apply uniqueitems to an array")
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: uniqueitems?

@apelisse apelisse changed the title WIP: ✨ Add support for ListType and ListMapKeys ✨ Add support for ListType and ListMapKeys Oct 21, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 21, 2019
@apelisse
Copy link
Author

I think I fixed everything, thanks!

@apelisse
Copy link
Author

apelisse commented Nov 4, 2019

I think it'd be great to implement mapType and structType on top of these two here. mapType and structType are two different "markers", but they should generate the same XKubernetesMapType openapi extension.

@mariantalla

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

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

tiny nit, but we might just want to do that in a follow-up

AllDefinitions = append(AllDefinitions, TopologyMarkers...)
}

// +controllertools:marker:generateHelp:category="CRD topology"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: #345 (comment)

(but let's not block on that)

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2019
@apelisse
Copy link
Author

@mariantalla Do we miss structType?
@DirectXMan12 PTAL!
@apelisse I probably need to rebase and remove the merge commit

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2019
@apelisse
Copy link
Author

Rebased and squashed some commits

@apelisse
Copy link
Author

rebased/squashed and fixed a few minor nits. @mariantalla can you make sure I didn't butcher your code? :-o

@apelisse apelisse changed the title ✨ Add support for ListType and ListMapKeys ✨ Add support for ListType, ListMapKeys, MapType and StructType Dec 19, 2019
@apelisse
Copy link
Author

/retest

@DirectXMan12
Copy link
Contributor

EDIT: tweaked docs to show up nicely in HTML form (list items need to be blank-line-separated or they'll be merged into the same line by the docs generator)

EDIT: made sure that generated help was actually used for the added markers

@DirectXMan12
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 19, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, DirectXMan12

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 19, 2019
Antoine Pelisse and others added 3 commits December 19, 2019 14:38
These two new markers allow support for associative lists and sets.
This adds support for x-kubernetes-map-type, which controls how to merge
maps in server-side apply.
It maps to x-kubernetes-map-type in the openapi schema, similar to the
mapType marker.
@apelisse
Copy link
Author

Fixed that typo that was making CI unhappy, can you re-apply lgtm @DirectXMan12?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for server-side apply markers
4 participants