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

Generator can not properly handle keys/values with operand characters (ie $) #307

Open
tyler-adam opened this issue Apr 18, 2023 · 2 comments

Comments

@tyler-adam
Copy link
Contributor

In the process of trying to create a jsonnet-lib for the Azure Service Operator v2, I discovered that they label one of their attributes $propertyBag. By doing this, the generator trips over itself. Here is an example of the output (trimmed for visibility):

66:11-12 Expected token OPERATOR but got "$": {
    <trimmed>
    '#workspaceCapping':: d.obj(help="\"Storage version of v1api20210601.WorkspaceCapping The daily volume cap for ingestion.\""),
    workspaceCapping: {
      '#with$PropertyBag':: d.fn(help="\"PropertyBag is an unordered set of stashed information that used for properties not directly supported by storage resources, allowing for full fidelity round trip conversions\"", args=[d.arg(name="$propertyBag", type=d.T.object)]),
      with$PropertyBag($propertyBag): { spec+: { workspaceCapping+: { $propertyBag: $propertyBag } } },
      '#with$PropertyBagMixin':: d.fn(help="\"PropertyBag is an unordered set of stashed information that used for properties not directly supported by storage resources, allowing for full fidelity round trip conversions\"\n\n**Note:** This function appends passed data to existing values", args=[d.arg(name="$propertyBag", type=d.T.object)]),
      with$PropertyBagMixin($propertyBag): { spec+: { workspaceCapping+: { $propertyBag+: $propertyBag } } },
      '#withDailyQuotaGb':: d.fn(help="", args=[d.arg(name="dailyQuotaGb", type=d.T.number)]),
      withDailyQuotaGb(dailyQuotaGb): { spec+: { workspaceCapping+: { dailyQuotaGb: dailyQuotaGb } } }
    }
  },
  '#mixin': "ignore",
  mixin: self
}
make: *** [Makefile:55: libs/azure-service-operator] Error 1

There should to be a way for k8s-gen to be aware of invalid characters and fix them however necessary (wrapping keys in quotes, etc - stripping them from variable names).

@tyler-adam tyler-adam changed the title Generator can not properly handle keys with operand characters (ie $) Generator can not properly handle keys/values with operand characters (ie $) Apr 18, 2023
@Duologic
Copy link
Member

Thanks for the report.

For maintainers: this was discussed and verified on Slack, would be an interesting fix.

@xvzf
Copy link
Member

xvzf commented Jun 24, 2023

I've noticed the same issue for the Aiven operator, where . are included as a field name, expecting something like:

myConfig:
  field.name: "myname"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants