Skip to content

Add CREDHUB_HOME env variable to override default home - #134

Open
ionphractal wants to merge 1 commit into
cloudfoundry:mainfrom
ionphractal:add-credhub-home-env
Open

Add CREDHUB_HOME env variable to override default home#134
ionphractal wants to merge 1 commit into
cloudfoundry:mainfrom
ionphractal:add-credhub-home-env

Conversation

@ionphractal

Copy link
Copy Markdown

Like the cf cli (CF_HOME), it is sometimes of advantage to be able to set a different home to be able to run credhub commands against different servers within one user.

For example if you run cronjobs under the same user, the context (.credhub config) would be diluted/overwritten by a later running script, causing unwanted results.

This PR adds CREDHUB_HOME for both linux and windows versions.

@hsinn0

hsinn0 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Created an internal Issue (TNZ-129716) to track this.

@hsinn0 hsinn0 left a comment

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.

Please make sure compile & test passes in Windows.

Comment thread config/config_win.go
return home
}

home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")

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.

Ran this through an AI tool, and it says that this will be a compile error:

config/config_win.go:17:7: no new variables on left side of :=

For re-declaration of 'home' in the same scope.

Comment thread config/config_win_test.go
os.Setenv("USERPROFILE", `C:\Users\original-user`)
os.Setenv("CREDHUB_HOME", `C:\custom\credhub\home`)

Expect(config.ConfigDir()).To(Equal(`C:\custom\credhub\home\.credhub`))

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.

AI analysis:
Because path.Join uses /, config.ConfigDir() returns C:\custom\credhub\home/.credhub, which will cause the test assertion to fail.

@github-project-automation github-project-automation Bot moved this from Inbox to Waiting for Changes | Open for Contribution in Foundational Infrastructure Working Group Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting for Changes | Open for Contribution

Development

Successfully merging this pull request may close these issues.

2 participants