Skip to content

Refactor config#153

Merged
kytrinyx merged 2 commits intomasterfrom
refactor-config
Jan 19, 2015
Merged

Refactor config#153
kytrinyx merged 2 commits intomasterfrom
refactor-config

Conversation

@kytrinyx
Copy link
Copy Markdown
Member

We only ever do three things from the outside:

  1. Load an existing config, falling back to defaults if it doesn't exist.
  2. Update values on a config.
  3. Write the config to disc.

Everything else is details.

In order to be able to set a fake homeDir on this, the New function delegates to a separate load function. This also allows us to avoid potential race conditions in the tests by not setting ENV variables.

Comment thread config/config.go
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 name does a much better job of communicating what it does. 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, everything seemed a bit tangled before. Or perhaps: both tangled and fragmented. This time around I've kept larger chunks. I think fewer abstractions will be easier to manage.

We only ever do three things from the outside:

1. Load an existing config, falling back to defaults if it doesn't exist.
2. Update values on a config.
3. Write the config to disc.

Everything else is details.

In order to be able to set a fake homeDir on this, the New function
delegates to a separate load function. This also allows us to avoid
potential race conditions in the tests by not setting ENV variables.
@Tonkpils
Copy link
Copy Markdown
Contributor

This looks good to me, it definitely improves readability and its easier to understand whats going on. 👍

@kytrinyx
Copy link
Copy Markdown
Member Author

OK, cool. Merging.

kytrinyx added a commit that referenced this pull request Jan 19, 2015
@kytrinyx kytrinyx merged commit e6672ec into master Jan 19, 2015
@kytrinyx kytrinyx deleted the refactor-config branch January 19, 2015 16:36
lcowell pushed a commit to lcowell/cli that referenced this pull request Jan 25, 2015
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.

3 participants