Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Indenting container blocks in template leads to erroneous updates #1082

Closed
squaremo opened this issue May 17, 2018 · 2 comments
Closed

Indenting container blocks in template leads to erroneous updates #1082

squaremo opened this issue May 17, 2018 · 2 comments

Comments

@squaremo
Copy link
Member

If you indent the container blocks in a YAML like this:

containers:
  - name: foo
    image: foo:v1
  - name: bar
    image: bar:v1

then releasing, e.g., foo:v2 will update the image field in all the containers. The cause is that the regexp that breaks the spec up into containers does not account for the extra indentation, and treats the whole list of containers as one block; then, the replacement is done with "replace all".

Just changing the "replace all" with "replace" wouldn't help, because it would replace the first occurrence which might still be incorrect. Doing the replacement with the old image would be better, but might still fail to replace anything.

The only real solution (while staying with regexps) is to correctly separate the container blocks.

@2opremio
Copy link
Contributor

2opremio commented May 21, 2018

To be clear, in the problematic example above, this is mitigated by changing indentation to:

containers:
- name: foo
   image: foo:v1
- name: bar
   image: bar:v1

i.e:

--- a.yaml	2018-05-21 10:00:18.000000000 +0200
+++ b.yaml	2018-05-21 10:00:24.000000000 +0200
@@ -1,5 +1,5 @@
 containers:
-  - name: foo
-    image: foo:v1
-  - name: bar
-    image: bar:v1
+- name: foo
+  image: foo:v1
+- name: bar
+  image: bar:v1

@squaremo
Copy link
Member Author

squaremo commented Jun 5, 2018

This is fixed in #976 -- hooray! (kubeyaml will reindent your blocks the first time it updates the file, if you have them as in the example, but importantly, it won't completely mangle everything.)

@squaremo squaremo closed this as completed Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants