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

fix: validate presence of flags and args in file patch command #1342

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

Prashansa-K
Copy link
Contributor

The command intends to patch input files either via selector-value flags or patch file arguments. The change ensures that at least one of these is present, but not both at the same time. Till now, the command accepted patches from flags and patch files at the same time, but ignored the patches passed via flags. This was a confusing behaviour for customers.

Fix #1130

@rspurgeon I have created a new issue for patch file validation here.
We can discuss its feasibility and usecase there. For this particular issue (#1130), I felt erroring out with a proper reasoning given to user should be the best way to move forward.

@Prashansa-K Prashansa-K requested a review from GGabriele July 18, 2024 05:14
@Prashansa-K Prashansa-K force-pushed the fix/patch-cmd-usage-error branch from 4cc9b6b to 47ab479 Compare July 18, 2024 05:17
@Prashansa-K
Copy link
Contributor Author

Here's the command in action:
Screenshot 2024-07-18 at 10 46 17 AM

Copy link
Collaborator

@GGabriele GGabriele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me!

Nit: can you please make sure commit messages follow the convention even for body length? e.g. The body of your message should not contain lines longer than 72 characters

This makes everything more readable.

For example:

commit a0388610ea9dc259e14c205e85811aac8bd7ed10
Author: Gabriele Gerbino <gabrielegerbino@gmail.com>
Date:   Fri Mar 15 12:57:02 2024 +0100

    fix: do not fetch kong version when running `validate`

    decK used to fetch the running Kong version in order to gate
    route regex patterns validation. This is problematic in
    the case users don't have access to the `/` endpoint, which
    is the one used to fetch the version of the runtime.

    This commit removes the need of fetching the Kong version
    entirely by relying on the `_format_version` field from the
    config file instead.

vs.

commit 47ab479635509980b1ba7ca6b42e5e28bc443789
Author: Prashansa Kulshrestha <prashkulshrestha@gmail.com>
Date:   Thu Jul 18 10:47:17 2024 +0530

    fix: validate presence of flags and args in file patch command

    The command intends to patch input files either via selector-value flags or patch file arguments. The change ensures that at least one of these is present, but not both at the same time. Till now, the command accepted patches from flags and patch files at the same time, but igno
red the patches passed via flags. This was a confusing behaviour for customers.

    Fix #1130

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 22.43%. Comparing base (0cdef1e) to head (cbe47e0).

Files Patch % Lines
cmd/file_patch.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1342      +/-   ##
==========================================
+ Coverage   22.39%   22.43%   +0.04%     
==========================================
  Files          54       54              
  Lines        4515     4520       +5     
==========================================
+ Hits         1011     1014       +3     
- Misses       3404     3407       +3     
+ Partials      100       99       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The command intends to patch input files either via selector-value flags or patch file arguments.
The change ensures that at least one of these is present, but not both at the same time.
Till now, the command accepted patches from flags and patch files at the same time,
but ignored the patches passed via flags. This was a confusing behaviour for customers.

Fix #1130
@Prashansa-K Prashansa-K force-pushed the fix/patch-cmd-usage-error branch from 062612c to cbe47e0 Compare July 18, 2024 05:50
@Prashansa-K
Copy link
Contributor Author

Updated the commit message.

@Prashansa-K Prashansa-K merged commit 4b632fd into main Jul 18, 2024
41 checks passed
@Prashansa-K Prashansa-K deleted the fix/patch-cmd-usage-error branch July 18, 2024 06:09
@Prashansa-K Prashansa-K self-assigned this Jul 22, 2024
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.

Selector CLI flag on file patch and file add-plugin not working when using a patch/plugin YAML file
3 participants