You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect the import to occur first, the anchor to be found, and the alias to resolve it.
It works when I copy the contents of the anchor file into the file containing the alias, so I wonder if this has to do with the validation occurring before the import.
The reason why we are wanting to do this is because we want to manage the values of the anchors by a different team via CODEOWNERS, whereas the aliases are set into a specific ordered list in a file maintained by our internal team.
The scope of YAML anchors is tied to the file boundary. This is consistent with every YAML parser out there. I don't believe this is something we can solve easily while relying on the mainstream YAML parsers.
The reason why we are wanting to do this is because we want to manage the values of the anchors by a different team via CODEOWNERS, whereas the aliases are set into a specific ordered list in a file maintained by our internal team.
We need to enforce what specific fields can be set by the non-privileged team, which can include values for a particular object key that is in a list of objects.
If the non-privileged team is providing the context with an import, we would need a way to ensure the specific import is specified in the file they are allowed to manage.
I thought it would be easier to simply import their file and then use the things from their file where we need them. However, I can appreciate that a) for yaml anchors, you need to parse the yaml, thus this isn't possible (I was thinking you'd resolve the imports first, but it makes sense you are parsing the yaml before importing), and b) Go templates might work if we can enforce that their file imports our file.
So, if I put the context in an import block for the non-privileged team to use, can I write an OPA policy that indicates which file must be imported for that specific context?
If so, I still think it would be easier to maintain if I didn't have to write policy and could govern it by the order of imports, but at least it might solve the use case.
I haven't tested this, and if for some reason the .Files.Get is not exposed, please open a separate issue to address that. Also, we suggest against using too much Go templating. It's really intended to be used as an escape hatch.
Beyond this, we don't have plans to implement some hack specifically addressing cross-file YAML anchors.
Activity
osterman commentedon Apr 4, 2023
The scope of YAML anchors is tied to the file boundary. This is consistent with every YAML parser out there. I don't believe this is something we can solve easily while relying on the mainstream YAML parsers.
osterman commentedon Apr 4, 2023
Have you you looked into the following:
hypnotisttom commentedon Apr 4, 2023
Thanks Erik.
We're definitely using OPA.
Regarding the Go templates...
We need to enforce what specific fields can be set by the non-privileged team, which can include values for a particular object key that is in a list of objects.
If the non-privileged team is providing the context with an import, we would need a way to ensure the specific import is specified in the file they are allowed to manage.
I thought it would be easier to simply import their file and then use the things from their file where we need them. However, I can appreciate that a) for yaml anchors, you need to parse the yaml, thus this isn't possible (I was thinking you'd resolve the imports first, but it makes sense you are parsing the yaml before importing), and b) Go templates might work if we can enforce that their file imports our file.
So, if I put the context in an import block for the non-privileged team to use, can I write an OPA policy that indicates which file must be imported for that specific context?
If so, I still think it would be easier to maintain if I didn't have to write policy and could govern it by the order of imports, but at least it might solve the use case.
Thanks,
Tom
osterman commentedon Feb 3, 2024
hypnotisttom we've introduced support for Sprig functions (some time ago) in go templates. So you should be able to do something like this.
Then where you need to use it, include it as content that gets injected before processing of the file as YAML, similar as to how Helm works, et al.
I haven't tested this, and if for some reason the
.Files.Getis not exposed, please open a separate issue to address that. Also, we suggest against using too much Go templating. It's really intended to be used as an escape hatch.Beyond this, we don't have plans to implement some hack specifically addressing cross-file YAML anchors.
fix(security): bump brotli, klauspost/compress, otel, follow-redirect…
refactor: resolve lint debt in config, exec and plugin packages (clou…