-
Notifications
You must be signed in to change notification settings - Fork 29
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
Define a way how to undefine an attribute #14
Comments
Or shall we the special |
I faced it in the selinux [1] repo where there is attribute test defined in the root. I need to remove it for the beakerlib library. I would not mess up with any reserved value. I would use the existing +, - notation but without a value. So
would mean to remove the attribute regardless the value(s). |
So this would mean to use the special
This could be shorter than listing all attributes on separate line:
And we could also have something like forget all inherited values:
Finally, to give some more examples, why the prefix could be useful:
In this way we could reference (and graft) other fmf (sub)trees. What do you think? |
Maybe instead of undefining we could also use replacing with an empty value However I would prefer syntax closer to the already used. Both might be implemented though. |
Le'ts move this forward. Just ran into a use case where this would be super-needed: In the selinux tests namespace, there are tests in the root directory and thus it is not possible to store the |
but the test should be a leaf, not a node so I guess this should not happen. Like you need to create an extra leaf at the root to define a test, needn't you? |
I like the 'multiline' approach here. It is analogous to how the properties are (re)defined, thus IMHO it is slightly more legible for the user than a 'singleline' approach. It might be test-: or -test: or, how about: test: undef ? |
The selinux main.fmf in the root of the repo defines |
The problem I see with this is that it's not possible to undefine all attributes, e.g. starting from the scratch. Which would be very useful for the above-mentioned use case as well. |
test: undef and / or undef: all ? |
I see. I think we talked about the possibility to explicitly set the object type. That would help in the contradictory cases. I could not find if there's a issue for that already, probably not. If there's some keyword going to be used, there needs to be also a way how to use that keyword litelarly. I mean we need to define difference like this: |
If |
Looks like a nice smiley as well! :-) Pity that the
But it would be quite elegant ;-) |
bloody yaml |
it may be misleading but just |
Hello, have you considered the existing Strategic merge patch format in Kubernetes that allow incremental updates of YAML/JSON data structures? https://stupefied-goodall-e282f7.netlify.app/contributors/devel/strategic-merge-patch/ I can provide some examples of how it would look like, if you provide example pairs of original and updated YAML. |
To remove an attribute entirely, it would look like this:
(Kubernetes strategic merge patch is an extension of JSON Merge Patch (http://erosb.github.io/post/json-patch-vs-merge-patch/), which allows to use
To add a key to the dictionary, preserving the former keys:
I suspect that here |
To undefine all the attributes, can't you simply replace the dict by an empty one? i.e.
combined with just |
@psss I don't get it - I thought that unless |
@pcahyna Problem is that currently you can't remove attribute. All you can do in child nodes is to change the value, you can't delete the key. Say my main.fmf in the root of the repo sets |
Personally I like |
Generally, the problem is that you may have the key without any value, meaning
Normally, in one repository, it is ok to have the tructure designed so it is not necessary to remove anything. But once you want to be able to load some sub-structure then it might be worth it. |
I understand this point - what was it a reply to? |
As @sopos pointed out, empty value is actually translated to |
Sure, but the current specification doesn't require it and frankly, if there is ever a need to assign any semantic to the key presence you can do the same outcome with boolean. So I think about that just as a hypothetical problem.
For me |
@lukaszachy, you said
but if you specify that |
The proposed solution for undefining a single key using Thus I would propose to choose a syntax which does not limit values or key naming. Except for Do not inherit from parent:
Undefine selected keys:
Graft a local branch:
Graft a remote tree:
For possible operation names we can get some inspiration from links provided by @pcahyna:
Thoughts? |
I like this proposal even though
|
Personally I do not like much just Currently I'm not sure if there is a consensus on removing individual attribures. As @lukaszachy noted |
I think you should first agree on the semantics before discussing the syntax. There are two possible semantics for deleting something:
/:
remove: [test] fall in this category. (Kubernetes strategic merge patch has I have a question about the intended semantics of dict:
a: x
b: y
c: z I would be able to use dict-:
b:
c: to the dict above would result in dict being just dict:
a: x correct? dict:
b-:
c-: ? Hmm, perhaps not, because |
Not sure about handling inside dict attributes, but list items work.
results in
|
How about (again) using special keyword undef? It is short, simple and very intuitive - being used for exactly that in several programming languages. It may be used either as: undef: x,y, z or x: undef Being a keyword, if anyone needs undef as a value, it's enough to wrap it in poarentheses: a: 'undef' and it does not block the user from having Null as a value. The x-: approch is nice, but I'm afraid the - sign will be just too easy to overlook. |
I thought that fmf was a layer above YAML... but your proposal is incompatible with YAML, because in YAML |
I'm just trying to emphasize the fact that Then, the remaining questions would be "how to wipe a full list, e.g. require", and "how to do a full cleanup (all attributes at the level)". Moreover, I can imagine a request to be able to remove all but some specific attribute(s). This is something which may be a problem with the |
I am probably missing something, but I thought that unless you add the |
By default, everything is inherited and you can replace attributes by defining them again or you can modify them (lists) by the The list described in #14 (comment) may come from the parent fmf node.
Note that a need for presence of the |
@sopos thanks, so what I was missing was that nodes are treated differently from other dicts. Nodes behave (in terms of the strategic merge patch standard) as if |
Right, the |
the problem is that currently dict-:
b:
c: would be equivalent to dict:
b-:
c-: ? /parent-:
test: assuming that the
You can simply set the list to an empty list, no?
If you don't want to introduce a new special attribute like the Kubernetes strategic merge patch's |
Another use case this should cover: repository with tests, in root's main.fmf are contact and component attributes (common to all tests). However I'd like to have also plan (for CI of tests) defined - currently there is no way where to place plan.fmf so that root's main.fmf is ignored and thus each plan has contact/component attributes which make tmt plan lint to fail. Note that if I have to choose between failing So ideally I'd have way how to undefine attribute in plan.fmf or mark plan.fmf to stop inheriting from its parents (in this case root main.fmf) |
definitely +1 for a possibility to cut off the inheritance completely - sometimes it is simply necessary |
I've suggested as side effect to use some special mark in my PR: #159 so example maye explain it: test: runtest.sh
/test1:
name: this is test
/plans:
test!: None (This is not important what will be there)
/tier1:
summary; This is plan tier1 so it is clear how to do it, just you have to add some one more layer, before your definition with undefined node. what is probably fine. it is not so often case to need to undefine some values. and theoretically I can imagine also some syntax, what will remove all items from inheritance, something like: test: runtest.sh
/plans!:
/tier1:
summary: this is tier1 so that /plan! causes last occurence of metadata in this node, and do not pass them to childrens. This may be little bit nonintuitive, as someone may expect that items are removed on this level, not in childrens, but could be described well. ConclusionWhy this idea is clean is: Syntax is that |
After some time I'd say I'm voting for |
I like my idea :-) with |
I think that is more confusing to the user and one would need to be more careful when copying fmf files between roots (hint: need to remember to check .fmf dir for configuration) If I want to cut inheritance in the node I want to express it in that node itself. |
I understand, but this is exactly users often does, copy .fmf dir and do not call fmf init, and there are not useful info. I can imagine it will check the info there e.g. current git repo and in case it does not match, raise WARN to user, to avoid this behaviour, as in fiuture there could be more info and this copying is bad idea. and in your cases I understand that this info is close to node, but when I get some fmf data of somebody and I do not know about that it is hard to understand why it behaves in another way than I expect. and it is simplier to do |
As the first step for the special `fmf` directives let's allow to completely disable inheriting data from parent which is currently the most desired use case. Fix #14.
Agreed. This currently seems to be the best way. By using this special case of empty node name for |
It would be useful to be able to undefine an inherited attribute. For example having an extra directory with helper files which should not be considered as tests. Perhaps something like this?
The text was updated successfully, but these errors were encountered: