-
Notifications
You must be signed in to change notification settings - Fork 18
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 domain list command #3
add domain list command #3
Conversation
Welcome @ZhuangYuZY! It looks like this is your first PR to knative-sandbox/kn-plugin-admin 🎉 |
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, this feature makes totally sense. Find my review comments below.
func DomainListHandlers(h hprinters.PrintHandler) { | ||
kDomainColumnDefinitions := []metav1beta1.TableColumnDefinition{ | ||
{Name: "Custom-Domain", Type: "string", Description: "Name of Knative custom domain.", Priority: 1}, | ||
{Name: "Selector", Type: "string", Description: "Selector of the Knative custom domain.", Priority: 1}, |
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.
{Name: "Selector", Type: "string", Description: "Selector of the Knative custom domain.", Priority: 1}, | |
{Name: "Selector", Type: "string", Description: "Selector for Knative custom domains.", Priority: 1}, |
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.
agree, code changed. Thank you.
parts := strings.Split(strings.ReplaceAll(strings.TrimSpace(selector), ":", "="), "\n") | ||
selectorForPrint := "" | ||
for i, v := range parts { | ||
if i == 0 && strings.Compare(v, "selector=") != 0 { |
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.
Maybe better use StartsWith
instead of Compare ? Compare looks a bit strange in this context and is not easy to understand.
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.
But maybe I just don't understand this special case for i=0. Could you please elaborate a bit on the reasoning for this handling ?
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.
Agree, code changed, and also add some comment. Thank you.
input string | ||
output string | ||
}{ | ||
{"normal case with one selector key value", "selector:\n key1: value1\n", "key1=value1; "}, |
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.
Could we also trim the final ;
+ the trailing space ? I think this looks more streamlined
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.
You are right. Code changed. Thank you.
@@ -0,0 +1,64 @@ | |||
// Copyright © 2019 The Knative Authors |
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.
@ZhuangYuZY I think the license should be 2020.
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.
agree, code change.
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.
Hi @ZhuangYuZY , looks like this one is missed?
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.
Hi @zhanggbj , In Conversation, the file is outdated. Please check "Files changed" tab. I already made the change of 2019 --> 2020. Thank you.
@@ -0,0 +1,41 @@ | |||
// Copyright © 2019 The Knative Authors | |||
// |
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.
Same as above
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.
agree, code changed. 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.
Same as above.
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.
Hi @zhanggbj , In Conversation, the file is outdated. Please check "Files changed" tab. I already made the change of 2019 --> 2020. Thank you.
pkg/command/domain/list.go
Outdated
domainListFlags := flags.NewListPrintFlags(DomainListHandlers) | ||
domainListCommand := &cobra.Command{ | ||
Use: "list", | ||
Short: "List custom domain", |
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.
Same as above, I think we can use domain instead of custom domain here.
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.
How about this one, what do you think? Thanks!
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.
Hi @zhanggbj , In Conversation, the file is outdated. Please check "Files changed" tab. Thank you.
@ZhuangYuZY Thanks for the PR! I just left some minor comments. Thanks! |
Thank you all, I will address your comment next week. |
/approve |
pkg/command/domain/list.go
Outdated
|
||
"github.com/spf13/cobra" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"knative.dev/client-contrib/plugins/admin/pkg" |
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.
Hi @ZhuangYuZY
Same situation with this new issue #11, would you please help to update the import path, otherwise it will break. Thanks!
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.
fixed. Thank you.
pkg/command/domain/list_test.go
Outdated
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
k8sfake "k8s.io/client-go/kubernetes/fake" | ||
"knative.dev/client-contrib/plugins/admin/pkg" |
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.
same as above
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.
fixed. Thank you.
pkg/command/domain/list_test.go
Outdated
"knative.dev/client-contrib/plugins/admin/pkg" | ||
"knative.dev/client/pkg/util" | ||
|
||
"knative.dev/client-contrib/plugins/admin/pkg/testutil" |
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.
same as above
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.
fixed. Thank you.
@ZhuangYuZY Sorry for requesting changes again, there's an issue filed today #11, would you please help to update the import path here? Thanks! |
@zhanggbj import path fixed. Thank you. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zhanggbj, ZhuangYuZY 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 |
/lgtm @ZhuangYuZY Thanks for the PR! Merging it |
For issue knative/client-contrib#30