Skip to content

cli: fix default certs-dir#87450

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:fix-default-certs
Sep 7, 2022
Merged

cli: fix default certs-dir#87450
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:fix-default-certs

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Sep 6, 2022

fixes #87191

#82020 accidentally broke
the logic for the certs-dir defaulting to ${HOME}/.cockroach-certs/

No release note since this bug was not released.

Release note: None

Release justification: low risk bug fix to new functionality.

@rafiss rafiss requested a review from knz September 6, 2022 20:26
@rafiss rafiss requested a review from a team as a code owner September 6, 2022 20:26
@rafiss rafiss requested a review from a team September 6, 2022 20:26
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Sep 6, 2022

I'm not sure where to test this. do the tcl tests have a ${HOME} directory?

// MakeLocator initializes a Locator.
func MakeLocator(certsDir string) Locator {
return Locator{certsDir: certsDir}
return Locator{certsDir: os.ExpandEnv(certsDir)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't seem right. The expansion should be done by the shell, not crdb.

Where is this $HOME default defined?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh I found it - base/config.go: DefaultCertsDirectory = "${HOME}/.cockroach-certs"

@knz
Copy link
Copy Markdown
Contributor

knz commented Sep 7, 2022

The proper fix is to change the base/config.go file, something like this:

var DefaultCertsDirectory = os.ExpandEnv(...)

or alternatively, keep the constant as-is, but un-export it, then define a new function GetDefaultCertsDirectory that does the expansion.

What's important is to only apply the expansion on the default, but not on the string provided by the user on the command line.

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Sep 7, 2022

What's important is to only apply the expansion on the default, but not on the string provided by the user on the command line.

Why is that desired? That would be a regression (or at least, a backwards incompatible change) from the behavior of v22.1.

@knz
Copy link
Copy Markdown
Contributor

knz commented Sep 7, 2022

That behavior was a misdesign, as discussed in #81298.
Note that when this came out, the doc team reviewed the docs and confirmed we had not documented the previous behaviour.

@knz
Copy link
Copy Markdown
Contributor

knz commented Sep 7, 2022

Also, the bug your PR fixes here was an oversight in #81298 and so would like to apologize for the inconvenience.

@rafiss rafiss requested review from a team as code owners September 7, 2022 16:27
@rafiss rafiss requested a review from knz September 7, 2022 16:27
cockroachdb#82020 accidentally broke
the logic for the certs-dir defaulting to ${HOME}/.cockroach-certs/

No release note since this was not released.

Release note: None

Release justification: low risk bug fix to new functionality.
@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Sep 7, 2022

tftr!

bors r=knz

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 7, 2022

Build succeeded:

@craig craig bot merged commit 76a5f63 into cockroachdb:master Sep 7, 2022
@rafiss rafiss deleted the fix-default-certs branch September 21, 2022 19:17
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.

Cockroach CLI commands not using default location for --certs-dir

3 participants