-
Notifications
You must be signed in to change notification settings - Fork 263
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
Allow configuration sink prefixes #676
Conversation
1e8f0f3
to
f8cff8a
Compare
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.
Thanks Daisy ! One remark wrt/ error handling and I wonder where this method is supposed to be used ? I would add the usage of ConfigSinkPrefixes
also to this PR
pkg/kn/core/root.go
Outdated
|
||
// set the Cfg.SinkPrefixes from viper if sink is configured | ||
if viper.IsSet("sink") { | ||
viper.UnmarshalKey("sink", &commands.Cfg.SinkPrefixes) |
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.
what happens with errors, e.g. when the user misconfigured it ? I think we should propagat an error message which as much context as posisble so that its easy to fix.
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 added error handling in the new version.
f8cff8a
to
31fdff4
Compare
Thank you for your review. I added the usage of sink prefix configuration in |
31fdff4
to
dc301ff
Compare
/test pull-knative-client-integration-tests |
3 similar comments
/test pull-knative-client-integration-tests |
/test pull-knative-client-integration-tests |
/test pull-knative-client-integration-tests |
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.
@daisy-ycguo looks good to me with some minor request to move the error upwards and not just printing it.
Also, could you please add to CHANGELOG.adoc ?
@navidshaikh as I will be on PTO next week, could you please take over this PR ? Its ok from my side except for the issue mentioned above.. thx !
pkg/kn/core/root.go
Outdated
if viper.IsSet("sink") { | ||
err := viper.UnmarshalKey("sink", &commands.Cfg.SinkPrefixes) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Unable to parse sink prefixes configuration: %v .\n", err) |
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.
can we propagate this up to the top level (i.e. let this method return an error), and then stop ? Otherwise it would just continue, but I think we should deal this misconfiguration as an error. If possible, you should also add the configuration file (could maybe be obtained from viper
) and the cake on the ice would be the line number (if it's easy to detect).
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.
raise an error in the new version. Line number is not easy to detected. But I include the error message returned from viper.UnmarshalKey
in the final error message, together with the config file information.
1f21538
to
c503c4b
Compare
@navidshaikh I upload a new version based on Roland's feedback. Will you help to continue the review when you are available ? |
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.
build tests failing,
Added some suggestions and requested for adding a note about predefined prefixes in kn can be overridden by values in configuration file.
IMO, we should add some e2e tests here (we've plugin e2e tests setup here test/e2e/plugins_test.go )
docs/README.md
Outdated
|
||
1. `pluginsDir` which is the same as the persistent flag `--plugins-dir` and specifies the kn plugins directory. It defaults to: `~/.kn/plugins`. By using the persistent flag (when you issue a command) or by specifying the value in the `kn` config, a user can select which directory to find `kn` plugins. It can be any directory that is visible to the user. | ||
|
||
2. `lookupPluginsInPath` which is the same as the persistent flag `--lookup-plugins-in-path` and specficies if `kn` should look for plugins anywhere in the specified `PATH` environment variable. This is a boolean configuration option and the default value is `false`. | ||
|
||
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`. | ||
3. `sink` defines your prefix to refer to Kubernetes resources which are described by APIGroup, Version and KIND. Then a `sink` object could be described as `<prefix>:<object name>` in `kn` command lines. |
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.
3. `sink` defines your prefix to refer to Kubernetes resources which are described by APIGroup, Version and KIND. Then a `sink` object could be described as `<prefix>:<object name>` in `kn` command lines. | |
3. `sink` defines your prefix to refer to Kubernetes addressable resources. To configure a sink prefix, define following in the config file: |
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.
done
docs/README.md
Outdated
|
||
1. `pluginsDir` which is the same as the persistent flag `--plugins-dir` and specifies the kn plugins directory. It defaults to: `~/.kn/plugins`. By using the persistent flag (when you issue a command) or by specifying the value in the `kn` config, a user can select which directory to find `kn` plugins. It can be any directory that is visible to the user. | ||
|
||
2. `lookupPluginsInPath` which is the same as the persistent flag `--lookup-plugins-in-path` and specficies if `kn` should look for plugins anywhere in the specified `PATH` environment variable. This is a boolean configuration option and the default value is `false`. | ||
|
||
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`. | ||
3. `sink` defines your prefix to refer to Kubernetes resources which are described by APIGroup, Version and KIND. Then a `sink` object could be described as `<prefix>:<object name>` in `kn` command lines. | ||
1. `prefix` is the prefix you want to describe your sink objects. `svc`, `service`, and `broker` are predefined prefixes in `kn`. |
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.
1. `prefix` is the prefix you want to describe your sink objects. `svc`, `service`, and `broker` are predefined prefixes in `kn`. | |
1. `prefix`: Prefix you want to describe your sink as. `service` or `svc` (`serving.knative.dev/v1`) and `broker` (`eventing.knative.dev/v1alpha1`) are predefined prefixes in `kn`. These predefined prefixes can be overridden by values in configuration file. |
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.
done.
docs/README.md
Outdated
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`. | ||
3. `sink` defines your prefix to refer to Kubernetes resources which are described by APIGroup, Version and KIND. Then a `sink` object could be described as `<prefix>:<object name>` in `kn` command lines. | ||
1. `prefix` is the prefix you want to describe your sink objects. `svc`, `service`, and `broker` are predefined prefixes in `kn`. | ||
2. `group` is the APIGroup of Kubernetes resources. |
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.
2. `group` is the APIGroup of Kubernetes resources. | |
2. `group`: The APIGroup of Kubernetes resource. |
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.
done
docs/README.md
Outdated
3. `sink` defines your prefix to refer to Kubernetes resources which are described by APIGroup, Version and KIND. Then a `sink` object could be described as `<prefix>:<object name>` in `kn` command lines. | ||
1. `prefix` is the prefix you want to describe your sink objects. `svc`, `service`, and `broker` are predefined prefixes in `kn`. | ||
2. `group` is the APIGroup of Kubernetes resources. | ||
3. `version` is the version of Kubernetes resources. |
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.
3. `version` is the version of Kubernetes resources. | |
3. `version`: The version of Kubernetes resources. |
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.
done.
docs/README.md
Outdated
1. `prefix` is the prefix you want to describe your sink objects. `svc`, `service`, and `broker` are predefined prefixes in `kn`. | ||
2. `group` is the APIGroup of Kubernetes resources. | ||
3. `version` is the version of Kubernetes resources. | ||
4. `resource` is the plural name of Kubernetes resources. |
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.
4. `resource` is the plural name of Kubernetes resources. | |
4. `resource`: The plural name of Kubernetes resources (for example: services). |
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.
done.
docs/README.md
Outdated
3. `version` is the version of Kubernetes resources. | ||
4. `resource` is the plural name of Kubernetes resources. | ||
|
||
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`. It also defines a sink prefix `myprefix` which refer to `brokers` in `eventing.knative.dev/v1alpha1`. With this configuration, you could use `myprefix:default` to describe Broker `default` in `kn` command lines. |
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.
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`. It also defines a sink prefix `myprefix` which refer to `brokers` in `eventing.knative.dev/v1alpha1`. With this configuration, you could use `myprefix:default` to describe Broker `default` in `kn` command lines. | |
For example, the following `kn` config will look for `kn` plugins in the user's `PATH` and also execute plugin in `~/.kn/plugins`. | |
It also defines a sink prefix `myprefix` which refers to `brokers` in `eventing.knative.dev/v1alpha1`. With this configuration, you can use `myprefix:default` to describe a Broker `default` in `kn` command line. |
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.
thanks. fixed in the new version.
c503c4b
to
f44b920
Compare
build tests failing on unrelated change for MD linting here
|
/retest |
/retest panic: test timed out after 30m0s |
f44b920
to
3b6915f
Compare
f01501b
to
60186f2
Compare
60186f2
to
4b9cf7c
Compare
The following is the coverage report on the affected files.
|
@navidshaikh tests pass. please have a second review. Thank you. |
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.
/lgtm
/approve
Thanks!
test.cronJobSourceDelete(t, r, "testcronjobsource0") | ||
} | ||
|
||
func (test *e2eTest) cronJobSourceCreateWithConfig(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, config string) { |
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.
Since CronJob source is deprecated and will be removed, I'd defer to use it for any new work/tests. As we'll need to re-work this later. Fine for now, but for any subsequent tests, lets use other sources.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: daisy-ycguo, navidshaikh 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 |
Fixes #571
Proposed Changes
test
andhello
, which map tobroker
ineventing.knative.dev/v1alpha1
andservice
inserving.knative.dev/v1
accordingly.