Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

feature: Initialize kn admin plugin #2

Merged
merged 2 commits into from
Apr 20, 2020

Conversation

zhanggbj
Copy link

Hi All,

This kn-admin plugin is designed to help administrators or operators better manage a Knative platform installation with kn CLI.

This is an initial commit. More details in the proposal: https://docs.google.com/document/d/1oD5P4WQZs39GIr_4ezcURgRCuUx8dXrcCi3N7GKmp5c/edit#

Thanks!

@knative-prow-robot
Copy link

Welcome @zhanggbj! It looks like this is your first PR to knative/client-contrib 🎉

@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 18, 2020
@knative-prow-robot
Copy link

Hi @zhanggbj. 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 the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 18, 2020
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.

Thanks a lot ! It's a crazy busy week for me (and next week I have PTO :(, so I hope I can bring it forward this week still.

sorry for the delay ...

@zhanggbj
Copy link
Author

@rhuss
Don't worry, take your time:-)

@rhuss
Copy link
Contributor

rhuss commented Feb 23, 2020

@zhanggbj sorry, I couldn't make it before my PTO (and I'm heading now off to the Alpes with little connectivity). I will be back the first week in March and get your PRs merged then is on the top of my priority list.

Apologies, and have a nice week !

@maximilien
Copy link
Contributor

/ok-to-test

@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 Feb 25, 2020
@maximilien
Copy link
Contributor

Hi, @zhanggbj, so all the tests are failing :(

I’ll leave some comments as well. But please fix this ^^^ first. Thanks.

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.

Hi, @zhanggbj, thanks for the contribution. However, few things TODO:

  1. Please address comments
  2. Add unit tests
  3. Try to at least add one e2e test if possible. OK to have that as a separate PR
  4. Since this PR has the dependency (1000s of files). It would be easier to have two PRs. But OK with one if that simple for you
  5. Ensure all UTs are passing

plugins/kn-admin/README.md Outdated Show resolved Hide resolved
plugins/kn-admin/README.md Outdated Show resolved Hide resolved
plugins/kn-admin/README.md Outdated Show resolved Hide resolved
plugins/kn-admin/README.md Outdated Show resolved Hide resolved
plugins/kn-admin/README.md Outdated Show resolved Hide resolved
plugins/kn-admin/cmd/private-registry/private-registry.go Outdated Show resolved Hide resolved
plugins/kn-admin/cmd/private-registry/private-registry.go Outdated Show resolved Hide resolved
plugins/kn-admin/main.go Outdated Show resolved Hide resolved
plugins/kn-admin/hack/build.sh Outdated Show resolved Hide resolved
plugins/kn-admin/core/root.go Outdated Show resolved Hide resolved
@knative-prow-robot
Copy link

knative-prow-robot commented Mar 3, 2020

@zhanggbj: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-knative-client-contrib-go-coverage ee9b4cc link /test pull-knative-client-contrib-go-coverage

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@zhanggbj
Copy link
Author

zhanggbj commented Mar 3, 2020

@maximilien Thank you for you review!

I've address your most of your comments and left one comment (add version in next PR), would you please help to take a review, thx!

I check the test failure, looks like it doesn't relate do plugin code, it cannot find the proper test file to execute. For e.g.

+ ./test/presubmit-tests.sh --integration-tests
./test/presubmit-tests.sh: line 37: ./test/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh: No such file or directory
./test/presubmit-tests.sh: line 40: main: command not found
+ EXIT_VALUE=127
+ set +o xtrace

@maximilien
Copy link
Contributor

Hi, @zhanggbj I think you need to add the test files in your PR. Doing that too for my PR #4.

I guess which ever gets merged first will have these files set and we can resolve conflicts in subsequent PRs.

Please do that and get all green and I will do a final pass. Thanks.

go.mod Outdated
@@ -0,0 +1,14 @@
module github.com/knative/client-contrib
Copy link
Contributor

Choose a reason for hiding this comment

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

there should be no top-level go.mod but each individual plugin uses its own dependency tree. the same is true for the vendor/ dir. See the comments to #5 for the reasoning and how I suggest to progress.

Copy link
Author

Choose a reason for hiding this comment

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

@rhuss sure, I'm working on it, will move vendor to the admin own structure and resubmit.

@rhuss
Copy link
Contributor

rhuss commented Apr 7, 2020

/retest

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Apr 12, 2020
@zhanggbj zhanggbj changed the title Initialize kn admin plugin feature: Initialize kn admin plugin Apr 12, 2020
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@rhuss
Copy link
Contributor

rhuss commented Apr 14, 2020

The following users are mentioned in OWNERS file(s) but are not members of the knative org.

Once all users have been added as members of the org, you can trigger verification by writing /verify-owners in a comment.

  • zhanggbj

    • OWNERS

@zhanggbj I asked the Knative admins to add you to the GitHub orga

@zhanggbj
Copy link
Author

zhanggbj commented Apr 14, 2020

Hi @rhuss @maximilien,
I've restructured kn-admin to align with the hello plugin, including folders/vendors/Reame/LICENSE/etc. would you please help to take a review? Thanks!

This is an initial PR for kn-admin and I still have a lot of TODOs in my list. I'll raise new PRs for review later as this already got a little bit hard to review:-)

@@ -4,6 +4,7 @@ approvers:
- rhuss
- maximilien
- navidshaikh
- zhanggbj
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether we could add a OWNERS fils within the plugins/admin directory ? I think this would be nice as it highlights the responsibilities and point-of-contact better.

I think prow supports this, let me check ...

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good to me. Thanks a lot and I've joined Knative org.

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.

Thanks a lot ! (also for your patience ;-)

Here's a first round of comments concerning UX aspects. In generall it looks good to me so far, except that I would think a bit more about the commands / option naming.

plugins/admin/README.adoc Show resolved Hide resolved
plugins/admin/README.adoc Show resolved Hide resolved
plugins/admin/README.adoc Show resolved Hide resolved
plugins/admin/README.adoc Outdated Show resolved Hide resolved
plugins/admin/README.adoc Outdated Show resolved Hide resolved
plugins/admin/README.adoc Show resolved Hide resolved
plugins/admin/README.adoc Show resolved Hide resolved
plugins/admin/README.adoc Outdated Show resolved Hide resolved
plugins/admin/README.adoc Outdated Show resolved Hide resolved
plugins/admin/core/root.go Outdated Show resolved Hide resolved
@rhuss
Copy link
Contributor

rhuss commented Apr 15, 2020

@zhanggbj btw, I would be happy to already commit the PR and then we can continue to work on it later.

Gong Zhang added 2 commits April 19, 2020 19:20
- Added kn-admin plugin
- Added domain set
- Added private registry enable
- To align with hello example plugin, restruct and add missing part
- Add admin plugin maintainer in OWNERS
}

// scanMantissa scans the mantissa beginning from the rune. It returns the next
// non decimal rune. It's used to determine wheter it's a fraction or exponent.
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// non decimal rune. It's used to determine wheter it's a fraction or exponent.
// non decimal rune. It's used to determine whether it's a fraction or exponent.

}

// scanMantissa scans the mantissa beginning from the rune. It returns the next
// non decimal rune. It's used to determine wheter it's a fraction or exponent.
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// non decimal rune. It's used to determine wheter it's a fraction or exponent.
// non decimal rune. It's used to determine whether it's a fraction or exponent.

// filesystems saying so.
// It will call Lstat if the filesystem iself is, or it delegates to, the os filesystem.
// Else it will call Stat.
// In addtion to the FileInfo, it will return a boolean telling whether Lstat was called or not.
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// In addtion to the FileInfo, it will return a boolean telling whether Lstat was called or not.
// In addition to the FileInfo, it will return a boolean telling whether Lstat was called or not.

I really wanted a very straightforward library that could seamlessly do
the following things.

1. Replace all the println, printf, etc statements thoughout my code with
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
1. Replace all the println, printf, etc statements thoughout my code with
1. Replace all the println, printf, etc statements throughout my code with

}
}

// StrictDomainName limits the set of permissable ASCII characters to those
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// StrictDomainName limits the set of permissable ASCII characters to those
// StrictDomainName limits the set of permissible ASCII characters to those

@@ -0,0 +1,801 @@
// Copyright 2014 Unknwon
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// Copyright 2014 Unknwon
// Copyright 2014 Unknown

@@ -0,0 +1,526 @@
// Copyright 2015 Unknwon
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// Copyright 2015 Unknwon
// Copyright 2015 Unknown


// NOTE: Iterate and increase `currentPeekSize` until
// the size of the parser buffer is found.
// TODO(unknwon): When Golang 1.10 is the lowest version supported, replace with `parserBufferSize := p.buf.Size()`.
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// TODO(unknwon): When Golang 1.10 is the lowest version supported, replace with `parserBufferSize := p.buf.Size()`.
// TODO(unknown): When Golang 1.10 is the lowest version supported, replace with `parserBufferSize := p.buf.Size()`.

@@ -0,0 +1,256 @@
// Copyright 2014 Unknwon
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// Copyright 2014 Unknwon
// Copyright 2014 Unknown

@@ -0,0 +1,603 @@
// Copyright 2014 Unknwon
Copy link
Member

Choose a reason for hiding this comment

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

Found potential misspelling(s):

Suggested change
// Copyright 2014 Unknwon
// Copyright 2014 Unknown

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

// we need to un-flatten the ast enough to decode
newNode := &ast.ObjectItem{
Keys: []*ast.ObjectKey{
&ast.ObjectKey{
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
&ast.ObjectKey{
{

Comment on lines +4 to +5
"os"
"log"
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
"os"
"log"

import (
"os"
"log"
"io/ioutil"
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
"io/ioutil"
"io/ioutil"
"log"
"os"

// ErrorLogger is used to print out error, can be set to writer other than stderr
var ErrorLogger = log.New(os.Stderr, "", 0)

// InfoLogger is used to print informational message, default to off
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
// InfoLogger is used to print informational message, default to off
// InfoLogger is used to print informational message, default to off
var InfoLogger = log.New(ioutil.Discard, "", 0)


import (
"context"
"fmt"
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
"fmt"
"fmt"
"reflect"

return yaml_INT_TAG, uintv
}
} else if strings.HasPrefix(plain, "-0b") {
intv, err := strconv.ParseInt("-" + plain[3:], 2, 64)
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
intv, err := strconv.ParseInt("-" + plain[3:], 2, 64)
intv, err := strconv.ParseInt("-"+plain[3:], 2, 64)

var ai, bi int
var an, bn int64
if ar[i] == '0' || br[i] == '0' {
for j := i-1; j >= 0 && unicode.IsDigit(ar[j]); j-- {
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
for j := i-1; j >= 0 && unicode.IsDigit(ar[j]); j-- {
for j := i - 1; j >= 0 && unicode.IsDigit(ar[j]); j-- {

func (meta *ObjectMeta) SetDeletionTimestamp(deletionTimestamp *Time) {
meta.DeletionTimestamp = deletionTimestamp
}
func (meta *ObjectMeta) GetDeletionGracePeriodSeconds() *int64 { return meta.DeletionGracePeriodSeconds }
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
func (meta *ObjectMeta) GetDeletionGracePeriodSeconds() *int64 { return meta.DeletionGracePeriodSeconds }
func (meta *ObjectMeta) GetDeletionGracePeriodSeconds() *int64 {
return meta.DeletionGracePeriodSeconds
}

Comment on lines +60 to +66
func (n nothingSelector) Matches(_ Fields) bool { return false }
func (n nothingSelector) Empty() bool { return false }
func (n nothingSelector) String() string { return "" }
func (n nothingSelector) Requirements() Requirements { return nil }
func (n nothingSelector) DeepCopySelector() Selector { return n }
func (n nothingSelector) RequiresExactMatch(field string) (value string, found bool) { return "", false }
func (n nothingSelector) Transform(fn TransformFunc) (Selector, error) { return n, nil }
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
func (n nothingSelector) Matches(_ Fields) bool { return false }
func (n nothingSelector) Empty() bool { return false }
func (n nothingSelector) String() string { return "" }
func (n nothingSelector) Requirements() Requirements { return nil }
func (n nothingSelector) DeepCopySelector() Selector { return n }
func (n nothingSelector) RequiresExactMatch(field string) (value string, found bool) { return "", false }
func (n nothingSelector) Transform(fn TransformFunc) (Selector, error) { return n, nil }
func (n nothingSelector) Matches(_ Fields) bool { return false }
func (n nothingSelector) Empty() bool { return false }
func (n nothingSelector) String() string { return "" }
func (n nothingSelector) Requirements() Requirements { return nil }
func (n nothingSelector) DeepCopySelector() Selector { return n }
func (n nothingSelector) RequiresExactMatch(field string) (value string, found bool) {
return "", false
}
func (n nothingSelector) Transform(fn TransformFunc) (Selector, error) { return n, nil }

Comment on lines +71 to +77
func (n nothingSelector) Matches(_ Labels) bool { return false }
func (n nothingSelector) Empty() bool { return false }
func (n nothingSelector) String() string { return "" }
func (n nothingSelector) Add(_ ...Requirement) Selector { return n }
func (n nothingSelector) Requirements() (Requirements, bool) { return nil, false }
func (n nothingSelector) DeepCopySelector() Selector { return n }
func (n nothingSelector) RequiresExactMatch(label string) (value string, found bool) { return "", false }
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
func (n nothingSelector) Matches(_ Labels) bool { return false }
func (n nothingSelector) Empty() bool { return false }
func (n nothingSelector) String() string { return "" }
func (n nothingSelector) Add(_ ...Requirement) Selector { return n }
func (n nothingSelector) Requirements() (Requirements, bool) { return nil, false }
func (n nothingSelector) DeepCopySelector() Selector { return n }
func (n nothingSelector) RequiresExactMatch(label string) (value string, found bool) { return "", false }
func (n nothingSelector) Matches(_ Labels) bool { return false }
func (n nothingSelector) Empty() bool { return false }
func (n nothingSelector) String() string { return "" }
func (n nothingSelector) Add(_ ...Requirement) Selector { return n }
func (n nothingSelector) Requirements() (Requirements, bool) { return nil, false }
func (n nothingSelector) DeepCopySelector() Selector { return n }
func (n nothingSelector) RequiresExactMatch(label string) (value string, found bool) {
return "", false
}

@zhanggbj
Copy link
Author

@rhuss
I've addressed all your comments and would you please help to take a look? Thanks!
And this is an initial PR, i think there're still a lot of todos for new subcommand and for existed domain and registry CRUD actions, and we can discuss later after this PR is merged and easy for collaboration.

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.

Thanks a lot ! Congrats to the first plugin merged ever to knative/client-contrib ;-) 👏

Let's continue to work on it to provide even more features. Also, I'm going to open an issue to collect more ideas for what might be interesting to add, so if we have kind of a complete overview we can align the command structure, too.

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 20, 2020
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Apr 20, 2020
@knative-prow-robot knative-prow-robot merged commit 79925ae into knative:master Apr 20, 2020
zhangtbj pushed a commit to zhangtbj/client-contrib that referenced this pull request Apr 28, 2020
* Initialize kn-admin plugin

- Added kn-admin plugin
- Added domain set
- Added private registry enable

* Restruct kn-admin plugin

- To align with hello example plugin, restruct and add missing part
- Add admin plugin maintainer in OWNERS
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants