-
Notifications
You must be signed in to change notification settings - Fork 577
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
[ENG-121] rpk: add rpk connect
as a managed plugin
#23117
Conversation
/dt |
out.MaybeDie(err, "unable to parse flags: %v", err) | ||
connect, pluginExists := plugin.ListPlugins(fs, plugin.UserPaths()).Find("connect") | ||
var pluginPath string | ||
if !pluginExists { | ||
path, err := installConnect(cmd.Context(), fs, "latest") | ||
out.MaybeDie(err, "unable to install Redpanda Connect: %v", err) | ||
pluginPath = path | ||
} |
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.
Don't we only want to install the plugin if a person uses rpk connect <something else>
? As in, don't force install a plugin if a person just does rpk connect -h
?
Also, if we do install, here we probably want to print some message like, "connect plugin not found, downloading" etcetc
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.
Connect can be run without any subcommand.
If you run rpk connect
it starts a service, that's the main difference with byoc and that's why I chose to install it even for a --help
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 @Jeffail added rpk connect run
. Can we block rpk connect -c
/ hijack it to not start the service, and rely entirely on subcommands?
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.
Changed how it works, now:
When running without connect
being installed:
$ rpk connect
<Help text of the rpk bits: install, uninstall and upgrade>
$ rpk connect --help
<same as above>
$ rpk connect --version
cannot get connect version: rpk connect is not installed; run 'rpk connect install'
<Help text>
$ rpk connect -c foo...
-c flag is not supported by this command; run 'rpk connect run' instead
If connect is installed, we will pass the flags to redpanda connect and they will work properly
@@ -106,6 +106,9 @@ func StripFlags(args []string, fs *pflag.FlagSet, long []string, short []string) | |||
if f == nil || !strip { | |||
inFlag = len(kv) == 1 | |||
keep = append(keep, arg) // either we are keeping this flag, or it is not in our flag set so we cannot strip it | |||
if i+1 < len(args) && strings.HasPrefix(args[i+1], "-") { | |||
inFlag = false |
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? I think this is trying to detect the case of a bool flag, --verbose --anotherthing=whatever
.
However if the first flag is --foo -bar
, can't -bar
be the value for --foo
?
I think the logic you want here is IF the flag exists, then check if the flag is a bool flag. If so, THEN we can do this logic.
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? I think this is trying to detect the case of a bool flag, --verbose --anotherthing=whatever.
Yes, that's correct. I've added a new comment.
However if the first flag is --foo -bar, can't -bar be the value for --foo?
Yes, it can be.
I think the logic you want here is IF the flag exists, then check if the flag is a bool flag. If so, THEN we can do this logic.
No, it can't be.
At this point, we know that the flag does not exist in rpk, we check this a couple of lines above. We cannot check if the flag is boolean because it's an unknown flag to rpk.
This flag is not used at the moment but it was missing the shorthand parsing.
This commit fixes a bug where if we were parsing a boolean long flag (let's say: --version), we will end up keeping the next argument after the flag, even if it was not needed.
We supported JSON and XML, now we add YAML.
5754156
to
5dbd5c1
Compare
new failures in https://buildkite.com/redpanda/redpanda/builds/54125#0191c9eb-0513-415b-8ea6-1ece0e09bea1:
new failures in https://buildkite.com/redpanda/redpanda/builds/54125#0191ca00-e812-425c-9639-0a07b0639654:
|
5dbd5c1
to
c81147d
Compare
c81147d
to
07f774d
Compare
This change means that from now on, connect will be managed by rpk, so, if a user tries to run `rpk connect <...>` for the first time, rpk will download, install and execute the plugin (connect). It also introduces 3 new commands to `rpk conenct` that live in rpk: install, uninstall, and upgrade.
07f774d
to
b3e9211
Compare
This PR introduces the required changes to have
rpk connect
as a managed plugin. The main behavior change is that from now on, rpk will try to downloadconnect
when running for the first time, similar to what we do withrpk cloud byoc
.It also introduces 3 new commands to rpk connect:
install
,uninstall
,upgrade
.Fixes https://github.com/redpanda-data/devex/issues/45
Usage
Most common use case:
^ That's it, it will download the connect plugin on the fly and then execute the command.
rpk won't update connect automatically unless you run rpk connect upgrade.
Manual Process
Install
Upgrade:
rpk only upgrades to latest, for specific versions use
rpk connect install
.Uninstall:
Backports Required
Release Notes
Improvements
rpk connect install
,rpk connect upgrade
, andrpk connect uninstall
, manual ways to managerpk connect
versioning.