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

[data/values] Make '---' in values.yaml optional #167

Closed
jessehu opened this issue Jul 10, 2020 · 10 comments
Closed

[data/values] Make '---' in values.yaml optional #167

jessehu opened this issue Jul 10, 2020 · 10 comments
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution

Comments

@jessehu
Copy link

jessehu commented Jul 10, 2020

Is the '---' in values.yaml required? We hit an issue related to '---' and yq (see mikefarah/yq#351).

#@data/values
---
key: value

Without '---', ytt gives this error. But '---' is optional per yaml spec.

ytt: Error: Expected YAML document to be annotated with data/values but was *yamlmeta.MapItem

@cppforlife
Copy link
Contributor

Is the '---' in values.yaml required?

it's required because @data/values annotation is associated with a document. if it was removed there would be no way to add @data/values to the document.

@cppforlife cppforlife added the discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution label Jul 10, 2020
@jessehu
Copy link
Author

jessehu commented Jul 10, 2020

So can ytt adds '---' implicitly for a values.yaml if it's not there?

@cppforlife
Copy link
Contributor

ytt knows that yaml document is data values is by finding documents with that annotation. file name itself (values.yml) isnt indicative that it contains data values.

@jessehu
Copy link
Author

jessehu commented Jul 11, 2020

Hi @cppforlife, I meant when ytt reads a file my-data-values.yaml and finds #@data/values at the beginning, can ytt implictly adds --- if there is no such line --- after #@data/values? yaml spec doesn't require --- at the beginning of a file. It's interesting that current ytt requires --- exists in the data values yaml , but doesn't require --- exists in other ytt templates yaml file.

@cppforlife
Copy link
Contributor

can ytt implictly adds --- if there is no such line --- after #@data/values

something like this?

#@data/values
foo: blah
other: another

we could make it wrong however from more of a purist ytt perspective this isnt "conceptually valid" since @data/values annotation is only apply to foo: blah instead of both of the kvs. this would be pretty significant step away from an understanding that a user might have about how annotations work.

@jessehu
Copy link
Author

jessehu commented Jul 13, 2020

I see what you meant. Does foo: blah with the annotation #@data/values make any sense to ytt ? If not, there is no ambiguity. Then why not ytt interprets the following valid yaml file

#@data/values
foo: blah
other: another

as

#@data/values
---
foo: blah
other: another

@cppforlife
Copy link
Contributor

If not, there is no ambiguity. Then why not ytt interprets the following valid yaml file

there is no ambiguity in this case, but it goes against all other cases how annotations are set up in ytt (annotation never is applied to a parent node. only to self or children).

it also seems that this is driven by a deficiencies in other tools. mikefarah/yq#351 (comment) seems to indicate that yq doesnt understand documents at all.

@jessehu
Copy link
Author

jessehu commented Jul 13, 2020

We can put aside yq. One of the principle of ytt is that Works directly with YAML structures, not text, but it dosen't work with this valid yaml file:

#@data/values
foo: blah
other: another

@ewrenn8
Copy link
Contributor

ewrenn8 commented Jul 14, 2020

ytt assigns the annotations to the following yaml node, which in this case is the map entry foo. Your example above would be the same as saying:

---
#@data/values
foo:blah
other: another

To apply the annotation to the implied document start would not make much sense. For example, users would expect:

#@yaml/map-key-override
foo: bar

to translate to

---
#@yaml/map-key-override
foo: bar

not

#@yaml/map-key-override
---
foo: bar

@cppforlife
Copy link
Contributor

given above explanation from eli, ill close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution
Projects
None yet
Development

No branches or pull requests

3 participants