Skip to content

Conversation

michaelvl
Copy link
Contributor

@michaelvl michaelvl commented Aug 27, 2023

This PR adds a test-case for kpt pkg get/update that reproduce the issue reported in #4012

Note: Since this is a failing test-case it could be considered to disable the final and failing assertion until the problem have been resolved

This PR adds a Kptfile to dataset1 and dataset2 for the sub package mysql. The change between dataset1 and dataset2 are:

$ diff internal/testutil/testdata/dataset1/mysql/Kptfile internal/testutil/testdata/dataset2/mysql/Kptfile
6c6
<   description: kpt package for mysql
---
>   description: mysql package
12a13,16
>     - image: gcr.io/kpt-fn/set-labels:v0.2.0
>       configMap:
>         fruit: apple
>       name: set fruit label

The test-case basically does a kpt pkg get mysql@dataset1 followed by a kpt pkg update mysql@dataset2 and verifies the content of Kptfile. The issue from #4012 thus results in a test-case failure with the following diff between the local Kptfile vs dataset2 (i.e. the local version have 'removals' compared to dataset2 because the local Kptfile is not properly updated to dataset2):

Diff:
--- Expected
+++ Actual
@@ -19,3 +19,3 @@
 info:
-  description: mysql package
+  description: kpt package for mysql
 pipeline:
@@ -28,6 +28,2 @@
       configMap:
-        fruit: apple
-      name: set fruit label
-    - image: gcr.io/kpt-fn/set-labels:v0.2.0
-      configMap:
         color: orange

Note, a copy of the Kptfile from dataset2 have also been added to dataset4 and dataset5 since these are 'clones' of dataset2.

This PR also correct an issue in testutil.AssertKptfile related to sequence-nodes (this new test-case seems to be the first use of sequence-nodes in Kptfiles). The issue is, that kptfileutil.WriteFile() use encoder option yaml.WideSequenceStyle, while the encoding used in testutil.AssertKptfile is a compact encoding. Without this correction, the test-case would fail with additional whitespace differences, e.g. (this is the initial pkg get verification of dataset1 that fails):

Diff:
--- Expected
+++ Actual
@@ -22,10 +22,10 @@
   mutators:
-  - image: gcr.io/kpt-fn/set-namespace:v0.4.1
-    configMap:
-      namespace: example-ns
-    name: set namespace
-  - image: gcr.io/kpt-fn/set-labels:v0.2.0
-    configMap:
-      color: orange
-    name: set color label
+    - image: gcr.io/kpt-fn/set-namespace:v0.4.1
+      configMap:
+        namespace: example-ns
+      name: set namespace
+    - image: gcr.io/kpt-fn/set-labels:v0.2.0
+      configMap:
+        color: orange
+      name: set color label

@michaelvl michaelvl requested a review from a team as a code owner August 27, 2023 06:47
@michaelvl michaelvl requested a review from natasha41575 August 27, 2023 06:47
@michaelvl michaelvl changed the title Bug/pkg update not updating kptfile Test case for issue 4012 pkg update not updating kptfile Aug 29, 2023
Copy link

netlify bot commented Aug 15, 2025

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 51320d7
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/689ef507e9ac77000816baf9
😎 Deploy Preview https://deploy-preview-4030--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Successfully merging this pull request may close these issues.

2 participants