-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(resource): don't use -f
when patch file is provided
#13317
fix(resource): don't use -f
when patch file is provided
#13317
Conversation
- `-f` and `-p` are mutually exclusive, regardless of `strategy` - we can replace both with `--patch-file` instead Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Ah, the example tests actually take care of this. Unfortunately they are failing:
The error lacks some detail though:
and there are no logs in CI because only the |
Here's the error running locally:
In other words, Also noting that the |
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
--patch-file
for patch
es-f
when patch file is provided
- effectively, they are supposed to be two different files, one is just a header (`-f`) that contains `name` and `kind` (etc) and the other is a patch file - in our case though, only one manifest is provided, so use it as both, assuming that it includes a header - and refactor and fix some other logic - JSON patch can fail unmarshaling, as it can be an array instead of a map - fix pointer issues (classic) Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
name: "strategic -f --patch-file", | ||
patchType: "strategic", | ||
appendFileFlag: true, | ||
manifestPath: "../../examples/hello-world.yaml", // any YAML with a `kind` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather this (and the other manifestPath
s under test here) were specific to the test suite, not overloading other files which have their own purpose. The effect of changing or deleting one of these (albeit unlikely) and seeing this test failing would be very surprising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but the existing tests already did that, so I did not change that test behavior in this PR. Changing that seemed to require a more substantial refactor, as we don't have a testdata
dir for unit tests (this requires a file to read in) or much use of full manifests in units, so I deferred that for the purposes of this fix PR.
I could make a separate PR for that, but we'd have to think of a strategy to apply more generically to these types of unit tests that a need a testdata
dir or similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's reasonable.
Signed-off-by: Anton Gilgur <4970083+agilgur5@users.noreply.github.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com> Signed-off-by: Anton Gilgur <4970083+agilgur5@users.noreply.github.com> (cherry picked from commit 5d8ee22)
Fixes #13279 per #13279 (reply in thread)
Fixes #11248 and Supersedes #11249
Motivation
When using
kubectl patch
:-p
and provide akind
andname
inflags
. You cannot use-f
in this case.-p
and-f
-f
is expected to have a header containing thekind
andname
(and potentially more)-p
is the patch fileModifications
-f
if there areflags
and akind
is provided in the manifest--patch-file
instead of-p
, no need to stringify--patch-file
has existed since at least k8s 1.20. we import thekubectl
package though, so it only depends on the version we use ingo.mod
)test-examples
E2E suiteVerification
Unit tests and E2E tests (the examples are tested)