Skip to content

cli: merge encode-uri into convert-url#164561

Open
kev-cao wants to merge 1 commit intocockroachdb:masterfrom
kev-cao:cli/convert-url
Open

cli: merge encode-uri into convert-url#164561
kev-cao wants to merge 1 commit intocockroachdb:masterfrom
kev-cao:cli/convert-url

Conversation

@kev-cao
Copy link
Contributor

@kev-cao kev-cao commented Feb 27, 2026

This commit merges the cockroach encode-uri command into the cockroach convert-url command so that we have a unified interface for generating connection URLs.

Resolves: #154384

Release note (cli): The cockroach encode-uri command has been merged into the cockroach convert-url command.

@kev-cao kev-cao requested review from a team as code owners February 27, 2026 23:36
@trunk-io
Copy link
Contributor

trunk-io bot commented Feb 27, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@kev-cao kev-cao requested review from a team, andrew-r-thomas, msbutler and shailendra-patel and removed request for a team February 27, 2026 23:36
Comment on lines +162 to +164
if options := opts.Get("options"); !strings.Contains(options, "-ccluster=") {
opts.Set("options", "-ccluster=system")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does overwrite any existing options that may have been set (e.g. results_buffer_size). Unfortunately, Golang's encoding of url.Values encodes spaces as + instead of %20, but we expect the options to be separated with %20.

We could do a bit of replacing here on values.Encode to get the encoding correct, but not sure if it's worth it. In any case, I think this would be a separate PR.

Comment on lines +561 to +562
ldr2="$(roachprod ssh drt-ldr2:1 -- ./cockroach convert-url --inline --ca-cert ./certs/ca.crt --key ./certs/client.root.key --cert ./certs/client.root.crt --database ycsb --username root --url {pgurl:1} | tail -1)"
ldr1="$(roachprod ssh drt-ldr1:1 -- ./cockroach convert-url --inline --ca-cert ./certs/ca.crt --key ./certs/client.root.key --cert ./certs/client.root.crt --database ycsb --username root --url {pgurl:1} | tail -1)"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shailendra-patel Wanted to make sure these changes work with the drt scripts — the new CLI interface does fix the bug with postgresql://postgres:// popping up, which is nice.

fmt.Println(u.ToJDBC())
fmt.Println()

fmt.Printf("# Connection URL for %[1]sCRDB%[2]s streams (%[1]sPhysical/Logical Cluster Replication%[2]s):\n", yc, rc)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment, we're only using these URLs for PCR/LDR, but maybe the language here could be more general so that we don't have to come back and update it later? Welcoming any ideas for wording here.

yc := cp[ttycolor.Yellow]
rc := cp[ttycolor.Reset]

crdbURL, err := u.ToCRDB(convertCtx.sslInline)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@msbutler Should the inline option be necessary here? I think it's required for all PCR/LDR streams anyway.

Although setting --inline does make the command look up those files and read from them, which means the command errors if those files aren't there. Perhaps having it behind the option gives the user a bit more flexibility (i.e. when they don't care about these URLs)

@dt
Copy link
Contributor

dt commented Mar 4, 2026

What does the old cockroach encode-uri do after this change? Should it be aliased to convert-url and/or print a notice to use convert-url instead?

@kev-cao
Copy link
Contributor Author

kev-cao commented Mar 5, 2026

@dt It was deleted here, but perhaps we should just leave it and put up a deprecation notice to be deleted in the next . That way its current behavior is preserved but we let users know it'll be deleted in the next regular release.

@dt
Copy link
Contributor

dt commented Mar 5, 2026

I think we should at the very least leave a stub behind to tell you to use convert-url otherwise it's just a confusing invalid argument error. Keeping it around with a notice, or just proxying through to the new one (with a notice) feels friendlier.

@kev-cao kev-cao requested a review from dt March 5, 2026 18:49
This commit merges the `cockroach encode-uri` command into the
`cockroach convert-url` command so that we have a unified interface for
generating connection URLs.

Resolves: cockroachdb#154384

Release note (cli): The `cockroach encode-uri` command has been merged
into the `cockroach convert-url` command.
Copy link
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

one drive by comment. will provide a closer review in the morning.

Short: "encode a CRDB connection URL",
Args: cobra.ExactArgs(1),
RunE: clierrorplus.MaybeDecorateError(encodeURI),
Deprecated: "please use convert-url instead, as encode-uri will be removed in a future release.\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can you update the commit message and release note to reflect that we are deprecating this, and have unified on convert-url. i think we should also call out explicitly in the release note that PCR/LDR docs need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

c2c: converge on convert-url instead of encode-uri

4 participants