-
Notifications
You must be signed in to change notification settings - Fork 252
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
Adding opm CLI #96
Adding opm CLI #96
Conversation
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.
Wow, looking really great! I jotted down some thoughts I had:
cmd/cli/registryserver.go
Outdated
return nil | ||
}, | ||
|
||
RunE: runRegistryServerCmdFunc, |
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.
Another option is to call runOpmRegistryServeCmdFunc
instead and drop the definition of runRegistryServerCmdFunc
.
cmd/cli/opmregistry.go
Outdated
) | ||
|
||
// NewOpmRegistryCmd returns the appregistry-server command | ||
func NewOpmRegistryCmd() *cobra.Command { |
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 about NewRegistryCmd
instead?
Makefile
Outdated
MOD_FLAGS := $(shell (go version | grep -q -E "1\.(11|12)") && echo -mod=vendor) | ||
CMDS := $(addprefix bin/, $(shell go list $(MOD_FLAGS) ./cmd/... | xargs -I{} basename {})) | ||
CMDS := $(addprefix bin/, $(shell go list $(MOD_FLAGS) ./cmd/... | grep -Fv "github.com/operator-framework/operator-registry/cmd/cli" |xargs -I{} basename {})) |
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.
If we keep the command declarations in separate top level packages, we don't need to do this right?
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 mean put this in pkg
instead of cmd
?
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 mean cmd/initializer
, cmd/registry
, cmd/opm
, and forgo extracting the commands out to cmd/cli
-- but it seems like everyone has a different opinion on this, so feel free to ignore.
|
||
func main() { | ||
rootCmd := &cobra.Command{ | ||
Use: "opm", |
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.
😄
@gallettilance I made a separate PR (#98) to address the foreign key issues; can you remove it from this one so that tests are passing? |
c9357f3
to
49d80f5
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.
Had a few nits, otherwise this is looking good.
Makefile
Outdated
@@ -1,5 +1,5 @@ | |||
MOD_FLAGS := $(shell (go version | grep -q -E "1\.(11|12)") && echo -mod=vendor) | |||
CMDS := $(addprefix bin/, $(shell go list $(MOD_FLAGS) ./cmd/... | xargs -I{} basename {})) | |||
CMDS := $(addprefix bin/, $(shell go list $(MOD_FLAGS) ./cmd/... | grep -v opm/... | xargs -I{} basename {})) |
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.
Do we want to continue to use go list
like this? Maybe we should just explicitly list the things we build rather than rely on using this command and ignoring part of the result? Or at least should we have a heuristic for determining it (like only look at the packages in the root of ./cmd/
?
@dinhxuanvu Any thoughts on this? I know you most likely have a similar problem with the bundle build command you are adding.
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.
Good point. Curious to see what @dinhxuanvu 's opinion is
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.
So the plan for me is to separate the functional code of my bundle PR to have it as a package living under /pkg
and the cobra command code (the rest) will live under /opm/bundle/...
and it will consume the bundle package.
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.
Why do we want to omit opm
from the build?
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.
@dinhxuanvu I thought we wanted to expose the bundle build as a command that wasn't built as part of any of our existing utilities? and then we create another pr against operator-sdk that consumed that cobra thing? We can create our own test utility that can also use that cobra thing but we won't publish it, just use it to test. but I was expecting it to NOT be part of opm
.
@ecordell I think he just meant that he doesn't want the subcommand packages to be part of the list of things that should be called by go build
. Those packages don't have main.go
files so the command that's in the makefile now will throw an error.
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 think this will do what we want:
CMDS := $(addprefix bin/, $(shell ls ./cmd))
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.
@kevinrizza You are correct. The ultimate usage for bundle library would be on SDK side. The users won't use bundle commands as a part of opm
binary. I'm planning to add bundle commands with hidden
flag on cobra. So we know they are there and available for internal use but they won't show up in the list of available commands.
cmd/opm/main.go
Outdated
rootCmd := &cobra.Command{ | ||
Use: "opm", | ||
Short: "operator package manager", | ||
Long: "Top level CLI for operator-registry", |
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.
Is this long description accurate anymore?
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.
addressed
cmd/opm/registry/cmd.go
Outdated
func NewOpmRegistryCmd() *cobra.Command { | ||
rootCmd := &cobra.Command{ | ||
Use: "registry", | ||
Short: "registry", |
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 think you want Short
to have a slightly longer description that defines what it actually does. Otherwise --help
won't really tell you anything.
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.
addressed
cmd/opm/registry/serve.go
Outdated
func newRegistryServeCmd() *cobra.Command { | ||
rootCmd := &cobra.Command{ | ||
Use: "serve", | ||
Short: "serve", |
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 comment as above about Short
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.
addressed
1501048
to
8bf56ad
Compare
8bf56ad
to
958896d
Compare
/lgtm /retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ecordell, gallettilance 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 |
Description of the change:
Adding a new cli to operator-registry called
opm
. It can add bundles to a database, delete packages from that db and serve its contents at a specified host and port.Having built the binaries, a user can run the old binaries
or can use the new cli that supports (and will support) our new operator bundle format. Here is an example flow:
Build the database (or add to an existing one) using
Remove operators from an existing db using
Serve the db using (can optionally specify a host and port)
Implemented here
In this PR we are adding the
opm
cli and a sub-commandregistry
. Theregistry
command itself has a subcommand calledserve
which serves the contents of an operator-registry database (created from an index image, using bundles in the new format, etc - note that how to create and modify that database will be in a follow up PR)Motivation for the change:
This is a first step toward creating new commands to interface with operator-registry as part of its corresponding epic.
Reviewer Checklist
/docs