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

Change config file to use toml like(=). Also remove viper because ya... #45

Merged
merged 2 commits into from
Sep 25, 2016

Conversation

bcaldwell
Copy link
Owner

new file format:
github_user = benjamincaldwell
source_dir = /Users/benjamincaldwell

@karanthukral

"source_dir": "/",
"gitlab_url": "gitlab.somwhere.com",
"gitlab_user": "gitlab_user",
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we move this outside the test so that we can reuse?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Idk. I think it will only really be used by this test. If other tests need it, then we can move it out then

return ioutil.WriteFile(fileName, []byte(r), 0644)
}

func ReadTomlLike(fileName string) (map[string]string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this simply accessible to parser.go? Interesting

Copy link
Owner Author

Choose a reason for hiding this comment

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

any file can see anything declared in the same package including inside other files.

func ReadTomlLike(fileName string) (map[string]string, error) {
m := make(map[string]string)
if _, err := os.Stat(fileName); err == nil {
r, err := regexp.Compile(`^([^\s#]+)\s*=\s*([^\s]+)$`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this for?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Figured it out!

func ReadTomlLike(fileName string) (map[string]string, error) {
m := make(map[string]string)
if _, err := os.Stat(fileName); err == nil {
r, err := regexp.Compile(`^([^\s#]+)\s*=\s*([^\s]+)$`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this for?

Copy link
Owner Author

Choose a reason for hiding this comment

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

regex to parse key=value.


func ReadTomlLike(fileName string) (map[string]string, error) {
m := make(map[string]string)
if _, err := os.Stat(fileName); err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this describe just the structure or also return the contents? Can't we simply use read?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think this just checks if it exists.

@karanthukral
Copy link
Collaborator

Couple of questions.. Should add some comments but looks good otherwise

@bcaldwell bcaldwell merged commit b48b888 into master Sep 25, 2016
@bcaldwell bcaldwell deleted the remove-viper branch December 29, 2016 00:27
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.

2 participants