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

Final YAML file doesn't correctly escape keys #15

Closed
iazel opened this issue May 5, 2017 · 4 comments
Closed

Final YAML file doesn't correctly escape keys #15

iazel opened this issue May 5, 2017 · 4 comments
Labels

Comments

@iazel
Copy link

iazel commented May 5, 2017

OS: Ubuntu 16.04
ktmpl: 0.7.0
kubernetes: 1.6.0

Hi, it seems that yaml keys starting with a dot . aren't quoted and this can cause problem with kubernetes (and it did indeed!)
Given this sample template file:

kind: "Template"
apiVersion: "v1"
metadata:
  name: "namespace-template"
labels:
  template: "namespace-template"
objects:
  - kind: Secret
    apiVersion: v1
    type: kubernetes.io/dockercfg
    metadata:
      name: docker-registry
      namespace: $(NAMESPACE)
    data:
      '.dockercfg': whatever
parameters:
  - name: "NAMESPACE"
    value: ""
    required: true
    parameterType: string

Will result in:

---
apiVersion: v1
data: 
  .dockercfg: "whatever"
kind: Secret
metadata: 
  name: "docker-registry"
  namespace: default
type: kubernetes.io/dockercfg

And then if you try to kubernetes apply the generated file, it will complain that something is wrong which will also cause a corruption (at least that what it seems like if you try to restart minikube afterwards).

Hope it was useful :)

@iazel
Copy link
Author

iazel commented May 5, 2017

Ops, it seems like it's a yaml-rust issue, but I think is still nice to be aware of :P

@iazel iazel closed this as completed May 5, 2017
@jimmycuadra
Copy link
Contributor

Is there an open issue on yaml-rust for this? In either case, I'm happy to leave this issue open to at least remind us to update our yaml-rust dependency when the bug is fixed.

@jimmycuadra jimmycuadra reopened this May 5, 2017
@jimmycuadra jimmycuadra added the bug label May 5, 2017
@iazel
Copy link
Author

iazel commented May 6, 2017

I plan to do a PR for this issue on yaml-rust today :)

iazel pushed a commit to iazel/yaml-rust that referenced this issue May 6, 2017
To understand why we want to do this, please refer to this issue on ktmpl repository (a way to have templates for kubernetes):
InQuicker/ktmpl#15

The problem applies only to string used as keys, but given that the emitters right now doesn't differentiate the two cases for string, I think is better to do it also for values instead of introducing branching and/or flag variables (can't think of cleaner solution for now).
@jimmycuadra
Copy link
Contributor

This is fixed in the latest release: https://github.com/jimmycuadra/ktmpl/releases/tag/0.8.0

I don't have access to this repo anymore, so please close the issue if it's solved for you. Thanks!

@iazel iazel closed this as completed Aug 9, 2018
fralalonde pushed a commit to fralalonde/strict-yaml-rust that referenced this issue Dec 18, 2018
To understand why we want to do this, please refer to this issue on ktmpl repository (a way to have templates for kubernetes):
InQuicker/ktmpl#15

The problem applies only to string used as keys, but given that the emitters right now doesn't differentiate the two cases for string, I think is better to do it also for values instead of introducing branching and/or flag variables (can't think of cleaner solution for now).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants