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

enhance structs to support iteration, bracket accessor, ... #208

Open
4 tasks
cppforlife opened this issue Sep 25, 2020 · 2 comments
Open
4 tasks

enhance structs to support iteration, bracket accessor, ... #208

cppforlife opened this issue Sep 25, 2020 · 2 comments
Labels
enhancement This issue is a feature request in progress Work has begun by a community member or a maintainer; this issue may be included in a future release

Comments

@cppforlife
Copy link
Contributor

currently we use struct package provided by starlark. it seems that it lacks few things that would make it friendlier to use (especially for case of data.values).

@cppforlife cppforlife added the enhancement This issue is a feature request label Sep 25, 2020
@pivotaljohn pivotaljohn added the in progress Work has begun by a community member or a maintainer; this issue may be included in a future release label Oct 5, 2020
@jtigger
Copy link
Contributor

jtigger commented Oct 5, 2020

Started working on this.
Thought I was done when struct.encode() was working as described in this issue.
However, while writing up corresponding docs, discovered that struct.make() is an entirely different code-path.
Will address that bit too.

@stealthybox
Copy link

stealthybox commented Mar 22, 2021

Just noting here that iterating over maps for this use-case does appear to work properly with ytt 0.31.0.

#@data/values
---
env:
    KUBE_SECRET: my-registry-token  #! does not yet exist -- will be created in the same Namespace
    SYNC_PERIOD: 3600  #! tokens expire; refresh faster than that
---
#! ... abbreviated

        env:
        #@ for k in data.values.env:
        - name: #@ str(k)
          value: #@ str(data.values.env[k])
        #@ end

This is common with config for k8s Deployments.

I'm not knowledgeable whether maps and structs are similar or related in Starlark, and there may be other technicalities that mean they are not fully iterable yet.

Either way, this wasn't clear from these examples:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a feature request in progress Work has begun by a community member or a maintainer; this issue may be included in a future release
Projects
Status: To Triage
Development

No branches or pull requests

4 participants