Skip to content

Conversation

@intojhanurag
Copy link
Contributor

@intojhanurag intojhanurag commented Oct 17, 2025

This PR fixes the --path flag in the func create command. Previously, cfg.Path was empty when using --path because the path computation happened after the confirm check, causing initialization failure

Before

image

After

Screenshot 2025-10-18 014515

@knative-prow knative-prow bot requested review from dsimansk and nainaz October 17, 2025 20:34
@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 17, 2025
@knative-prow
Copy link

knative-prow bot commented Oct 17, 2025

Hi @intojhanurag. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.07%. Comparing base (71a1f6a) to head (764a87d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cmd/create.go 83.33% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3113      +/-   ##
==========================================
+ Coverage   58.32%   59.07%   +0.75%     
==========================================
  Files         134      134              
  Lines       17350    17364      +14     
==========================================
+ Hits        10119    10258     +139     
+ Misses       6292     6137     -155     
- Partials      939      969      +30     
Flag Coverage Δ
e2e-tests 40.25% <83.33%> (+1.37%) ⬆️
integration-tests 53.84% <83.33%> (+1.66%) ⬆️
unit-tests 46.22% <83.33%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@intojhanurag
Copy link
Contributor Author

Hey @gauron99 , It is ready for review.

Copy link
Contributor

@gauron99 gauron99 left a comment

Choose a reason for hiding this comment

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

thanks for the contribution! I added a few questions/suggestions

cmd/create.go Outdated
// Retain positional [path] for backward compatibility (warned later).
cmd.Flags().StringP("path", "p", ".", "Path to the function project directory (default: current directory) ($FUNC_PATH)")

// Bind the --path flag to viper so it can be read in newCreateConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to bind this to read later? we are not binding other flags and we still read them in createConfig.

Copy link
Contributor Author

@intojhanurag intojhanurag Oct 18, 2025

Choose a reason for hiding this comment

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

I initially tried reading --path without binding it to viper, but viper.GetString("path") returned empty, And with binding it is working🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

OK I see it. There is a bindEnv function thats being called. You should be able to add path as one of the arguments there and that binds all those flags i mentioned.

@gauron99 gauron99 self-assigned this Oct 18, 2025
@gauron99
Copy link
Contributor

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 18, 2025
@intojhanurag
Copy link
Contributor Author

Hey @gauron99, let me know if any changes are needed. I'm not sure why one of the tests is failing.

cmd/create.go Outdated
// Retain positional [path] for backward compatibility (warned later).
cmd.Flags().StringP("path", "p", ".", "Path to the function project directory (default: current directory) ($FUNC_PATH)")

// Bind the --path flag to viper so it can be read in newCreateConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

OK I see it. There is a bindEnv function thats being called. You should be able to add path as one of the arguments there and that binds all those flags i mentioned.

cmd/create.go Outdated
$ {{.Name}} create -l go -t cloudevents myfunc
`,
SuggestFor: []string{"vreate", "creaet", "craete", "new"},
PreRunE: bindEnv("language", "template", "repository", "confirm", "verbose"),
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to add path here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense , thanks :)

@gauron99
Copy link
Contributor

gauron99 commented Oct 18, 2025

Hey @gauron99, let me know if any changes are needed. I'm not sure why one of the tests is failing.

@intojhanurag looks like a flake, I will re-run if it fails again

@knative-prow knative-prow bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 18, 2025
@gauron99
Copy link
Contributor

Thanks!

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2025
@knative-prow
Copy link

knative-prow bot commented Oct 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, intojhanurag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 18, 2025
@knative-prow knative-prow bot merged commit a4cd23c into knative:main Oct 18, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants