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

fix: place the config file in XDG_CONFIG_HOME instead of HOME #467

Merged
merged 1 commit into from
Mar 17, 2021

Conversation

rkpattnaik780
Copy link
Contributor

Description

Place the config file in $XDG_CONFIG_HOME if it exists, otherwise place it in $HOME/.config.

Fixes #442

Verification Steps

  1. Login by running the command go run ./cmd/rhoas login.
  2. Run echo $XDG_HOME_CONFIG.
  3. If you get a path, run nano $XDG_HOME_CONFIG/.rhoascli.json, you should be able to see the config file.
  4. If echo $XDG_HOME_CONFIG returns empty string, running nano $HOME/.config/.rhoascli.json should open the config file.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer

@rkpattnaik780 rkpattnaik780 requested a review from wtrocki March 17, 2021 06:40
Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

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

I'm not big fan of using small utility packages with go, however this works and does the job so it looks like we can merge it

Will leave to our team lead to approve tommorow

@rkpattnaik780
Copy link
Contributor Author

The package was mentioned here.
Alternatively we could make some changes to the package's UserConfig method:

func (d *dirs) UserConfig() string {
	baseDir := os.Getenv("XDG_CONFIG_HOME")
	if baseDir == "" {
		baseDir = filepath.Join(os.Getenv("HOME"), ".config")
	}

	return filepath.Join(baseDir, d.name)
}

Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

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

Verified all good to merge

@rkpattnaik780 rkpattnaik780 merged commit 4a999f2 into main Mar 17, 2021
@rkpattnaik780 rkpattnaik780 deleted the xdg_config branch March 17, 2021 10:55
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.

The CLI config should be located in the $XDG_CONFIG_HOME if present
2 participants