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

Add support to (not) initialize kn config file #1472

Merged
merged 1 commit into from
Nov 2, 2021
Merged

Add support to (not) initialize kn config file #1472

merged 1 commit into from
Nov 2, 2021

Conversation

boaz0
Copy link
Contributor

@boaz0 boaz0 commented Oct 4, 2021

Description

Add support to initialize kn config file or to skip it.
Make a default config file with the newest settings if it doesn't exist.

Changes

Reference

Related #1232

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Oct 4, 2021
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@boaz0: 0 warnings.

In response to this:

Description

Add support to initialize kn config file or to skip it.

Changes

  • Add --init flag
  • Add --no-init flag
  • By default we read the config file and if it doesn't exist create it
  • Use viper to create the config file.

Reference

Fixes #1232

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/test-infra repository.

@knative-prow-robot
Copy link
Contributor

Hi @boaz0. Thanks for your PR.

I'm waiting for a knative 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/test-infra repository.

@knative-prow-robot knative-prow-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 4, 2021
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

/ok-to-test
Thanks for submission. Left one comment and one question: why would this initialization not done automatically if the file is not present or cannot be loaded?

pkg/kn/config/config_test.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot 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 4, 2021
CHANGELOG.adoc Outdated
@@ -16,9 +16,14 @@
|===
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add a new ## Unreleased table to start collecting changes for the next release?

pkg/kn/config/config.go Outdated Show resolved Hide resolved
pkg/kn/config/config.go Outdated Show resolved Hide resolved
pkg/kn/config/config.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2021
@boaz0
Copy link
Contributor Author

boaz0 commented Oct 6, 2021

Thanks @dsimansk I will look at it more (+ rebase my code) and address your comments.

@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 24, 2021
@codecov
Copy link

codecov bot commented Oct 24, 2021

Codecov Report

Merging #1472 (4b1da32) into main (d8d0ee1) will decrease coverage by 0.03%.
The diff coverage is 14.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1472      +/-   ##
==========================================
- Coverage   79.32%   79.28%   -0.04%     
==========================================
  Files         162      162              
  Lines        8501     8516      +15     
==========================================
+ Hits         6743     6752       +9     
- Misses       1076     1081       +5     
- Partials      682      683       +1     
Impacted Files Coverage Δ
pkg/kn/config/config.go 52.94% <14.28%> (-4.64%) ⬇️
pkg/errors/errors.go 100.00% <0.00%> (ø)
pkg/kn/commands/source/list_types.go 56.86% <0.00%> (ø)
pkg/kn/commands/channel/list_types.go 64.70% <0.00%> (ø)
...kg/kn/commands/service/configuration_edit_flags.go 80.47% <0.00%> (+0.23%) ⬆️
pkg/kn/flags/podspec.go 77.05% <0.00%> (+0.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8d0ee1...4b1da32. Read the comment docs.

@boaz0
Copy link
Contributor Author

boaz0 commented Oct 25, 2021

Ummm... I think pull-knative-client-integration-tests failure isn't related to the change (I see timeout error).
Also, I ran coverage on my computer and from the go tool cover output I see that must of was covered so I have no idea why the codecov/patch gives me only 41.17% coverage 🤷‍♂️

pkg/kn/config/config.go Outdated Show resolved Hide resolved
@dsimansk
Copy link
Contributor

Ummm... I think pull-knative-client-integration-tests failure isn't related to the change (I see timeout error). Also, I ran coverage on my computer and from the go tool cover output I see that must of was covered so I have no idea why the codecov/patch gives me only 41.17% coverage man_shrugging

The reported coverage is calculated by Codecov standards that doesn't match go tool numbers usually. If you navigate through Details you can see the annotated diff with missing coverage. Those annotations are also added to PR's diff view.

@dsimansk
Copy link
Contributor

Per our chat with @boaz0 I've suggested the following approach to the config init:

  • No new init/no-init flags (easy to add hard to remove later due to deprecation policy :))
  • Create the file if not present
  • populate the file with commented-out example config only
  • Fail silently if there's write permission issue etc.

@maximilien @navidshaikh @rhuss @itsmurugappan please state any objections to the above.

@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2021
pkg/kn/config/config.go Outdated Show resolved Hide resolved
pkg/kn/config/config.go Outdated Show resolved Hide resolved
pkg/kn/config/config.go Outdated Show resolved Hide resolved
pkg/kn/config/config.go Outdated Show resolved Hide resolved
pkg/kn/config/config.go Outdated Show resolved Hide resolved
If the config file doesn't exist create one with default settings.
I used the settings that are given in this link:
https://github.com/knative/client/blob/main/docs/README.md#options

Signed-off-by: Boaz Shuster <[email protected]>
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/config/config.go 73.6% 72.3% -1.3

@dsimansk
Copy link
Contributor

dsimansk commented Nov 1, 2021

/retest

1 similar comment
@rhuss
Copy link
Contributor

rhuss commented Nov 2, 2021

/retest

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

Thanks !

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 2, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: boaz0, rhuss

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-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2021
@knative-prow-robot knative-prow-robot merged commit 09d48d5 into knative:main Nov 2, 2021
dsimansk pushed a commit to dsimansk/client that referenced this pull request Nov 2, 2021
If the config file doesn't exist create one with default settings.
I used the settings that are given in this link:
https://github.com/knative/client/blob/main/docs/README.md#options

Signed-off-by: Boaz Shuster <[email protected]>
@boaz0 boaz0 deleted the closes_1232 branch November 2, 2021 12:18
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. cla: yes Indicates the PR's author has signed the CLA. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants