Feature: Protect existing workflow files from accidental overwrites.#3407
Feature: Protect existing workflow files from accidental overwrites.#3407twoGiants wants to merge 1 commit intoknative:mainfrom
Conversation
c7ebe59 to
ab5ed8f
Compare
ab5ed8f to
8162643
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3407 +/- ##
==========================================
- Coverage 54.60% 54.56% -0.04%
==========================================
Files 179 179
Lines 20228 20282 +54
==========================================
+ Hits 11045 11067 +22
- Misses 8011 8044 +33
+ Partials 1172 1171 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8162643 to
8109c29
Compare
|
/cc @gauron99 @matejvasek @lkingland The PR is ready for review. Please read the description about the logging. |
|
/lgtm |
The codecov tool is poorly configured or am I missing something? It's flagging the |
8109c29 to
6fb5f5e
Compare
|
New changes are detected. LGTM label has been removed. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: twoGiants The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
cmd/ci/config.go
Outdated
| func resolveWorkflowName() string { | ||
| workflowName := viper.GetString(WorkflowNameFlag) | ||
| if workflowName != DefaultWorkflowName && workflowName != "" { | ||
| return workflowName | ||
| } | ||
|
|
||
| useRemoteBuild := viper.GetBool(UseRemoteBuildFlag) | ||
| if useRemoteBuild { | ||
| return DefaultRemoteBuildWorkflowName | ||
| } | ||
|
|
||
| return DefaultWorkflowName | ||
| } |
There was a problem hiding this comment.
So if I understand this right, if a user explicitly sets workflow-name="Func Deploy" (the default value), the function treats it as if no custom name was provided because of the workflowName != DefaultWorkflowName check. This means with --remote --workflow-name="Func Deploy", we'd get "Remote Func Deploy" instead of their explicitly requested "Func Deploy"?
Something like this might help:
workflowNameChanged := cmd.Flags().Changed(WorkflowNameFlag)
There was a problem hiding this comment.
Yes, good catch! I was also unsure about this one. Thank you. Will correct it 😸 👍
There was a problem hiding this comment.
I am setting the default during resolution, the I don't need to pass down cobra.Command. Is that ok too?
There was a problem hiding this comment.
After talking to David I got a small primer about how default values are set and it's probably best to evaluate the cmd.Flags().Changed(WorkflowNameFlag) and do what you proposed Luke 😺
6fb5f5e to
09b4258
Compare
09b4258 to
332f403
Compare
9487908 to
b055aaa
Compare
The `func config ci` command previously overwrote existing workflow
files silently, risking loss of user customizations.
Now the command checks if a workflow file exists before writing and
returns an error unless the `--force` flag is specified. When --force
is used and a file exists, a warning is logged.
Remote builds now use a distinct default workflow name ("Remote Func
Deploy") to avoid conflicts, while explicit --workflow-name values
are always preserved regardless of --remote flag.
Issue knative#3256
Signed-off-by: Stanislav Jakuschevskij <sjakusch@redhat.com>
b055aaa to
ffadf68
Compare
Changes
--forceflag to explicitly allow overwriting existing workflow files--forceis used to overwrite existing workflows/kind enhancement
Relates to #3256
Release Note
Docs