Skip to content

support maps in marker marker parsing - #329

Merged
k8s-ci-robot merged 2 commits into
kubernetes-sigs:masterfrom
DirectXMan12:prototype/object-parsing
Sep 30, 2019
Merged

k8s-ci-robot merged 2 commits into
kubernetes-sigs:masterfrom
DirectXMan12:prototype/object-parsing

Conversation

@DirectXMan12

@DirectXMan12 DirectXMan12 commented Sep 27, 2019 •

Copy link
Copy Markdown
Contributor

Maps in markers always have string keys, and may have any argument type, including
nested maps, slices, etc.
"Guessed" maps are always non-uniform (i.e. key of AnyType), since
they're frequently used to represent objects in JSON form.

They syntax looks like:

//+this:is:a:map={"text": "abc", len: 33}

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 27, 2019
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12

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

The pull request process is described here

Details 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 Sep 27, 2019
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 27, 2019
@DirectXMan12

Copy link
Copy Markdown
Contributor Author

/hold

this is partial -- whether we merge this depends on how it works with #323

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2019
@DirectXMan12

DirectXMan12 commented Sep 27, 2019 •

Copy link
Copy Markdown
Contributor Author

There's one caveat: we'll never "guess" an empty map to be a map (we depend on the presence of <string>: to guess maps). I think this is okay for now, but if anyone sees a way around it lmk (hence why go requires type signatures, and JSON uses square brackets vs curly braces, but that ship has sailed now).

Maps in markers always have string keys, and may have any value type.
"Guessed" maps are always non-uniform (i.e. key of AnyType), since
they're frequently used to represent objects in JSON form.
This supports changing field names in anonymous markers, meaning you can
have a marker like

```
//+default=<any>
```

map to a struct

```
type Default struct {
        Value interface{}
}
```

by changing the definition up a bit.

This supports when you need to make an any-type definition and also
implement methods on it, like for defaulting.
@marun

marun commented Sep 27, 2019

Copy link
Copy Markdown
Contributor

I've rebased #323 on this PR and it works like a charm. LGTM

@marun

marun commented Sep 30, 2019

Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 30, 2019
@marun

marun commented Sep 30, 2019

Copy link
Copy Markdown
Contributor

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 30, 2019
@k8s-ci-robot
k8s-ci-robot merged commit 64b0534 into kubernetes-sigs:master Sep 30, 2019
@DirectXMan12
DirectXMan12 deleted the prototype/object-parsing branch September 30, 2019 21:41
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.

3 participants