Skip to content
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

refactor: simplify conf path management #2325

Merged
merged 2 commits into from
Aug 24, 2023
Merged

refactor: simplify conf path management #2325

merged 2 commits into from
Aug 24, 2023

Conversation

cgrinds
Copy link
Collaborator

@cgrinds cgrinds commented Aug 23, 2023

No description provided.

Hardikl
Hardikl previously approved these changes Aug 24, 2023
// Path joins a set of path elems into a single path.
// The final path will be relative to the HARVEST_CONF environment variable
// or ./ when the environment variable is not set
func Path(elem ...string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

See if below makes sense. This will avoid HasSuffix check and provide a clean output path if elem has a relative path.

func Path(elem ...string) string {
	home := os.Getenv("HARVEST_CONF")
	if home == "" {
		return filepath.Join(elem...)
	}
	allPaths := append([]string{home}, elem...)
	return filepath.Join(allPaths...)
}

@cgrinds cgrinds merged commit 0ef91a6 into main Aug 24, 2023
9 checks passed
@cgrinds cgrinds deleted the cbg-path branch August 24, 2023 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants