expand relative path ~/.config/vikunja to $HOME/.config/vikunja #146

Merged
konrad merged 2 commits from funkythings/api:master into master 2020-02-29 19:51:47 +00:00
Contributor

Description

viper doesn't expand ~ by default, resulting in malformed config path:

... Config File "config" Not Found in "[... /opt/vikunja/~/.config/vikunja]"

According to this issue however, env variable expansion works, which allows for AddConfigPath("$HOME/.config/vikunja"), with one exception: Doesn't work on windows. Works on Linux, but vikunja has to work on Windows, too? I'm confused because there a windows download on your file server, but all paths are clearly only linux compatible. See #147: a windows compatible version (Can't actually test on windows machine)

For a portable version, AddConfigPath(path.Join(os.UserHomeDir(), ".config", "vikunja").String()) or similar will have to be used.

Tested successfully on Ubuntu 18.04 64 bit

Checklist

  • I added or improved tests
  • I pushed new or updated dependencies to the repo using go mod vendor
  • I added or improved docs for my feature
    • Swagger (including make do-the-swag)
    • Error codes
    • New config options

I am not sure what the makefile does when running make build and how go manages dependencies, but I did not touch mod.go, while it has changed (on local computer for now, can push if necessary) with this diff:

diff --git a/go.mod b/go.mod
index 636aad4..6a43051 100644
--- a/go.mod
+++ b/go.mod
@@ -38,7 +38,6 @@ require (
 	github.com/go-testfixtures/testfixtures/v3 v3.1.1
 	github.com/go-xorm/core v0.6.2 // indirect
 	github.com/go-xorm/xorm v0.7.9 // indirect
-	github.com/gogo/protobuf v1.2.0 // indirect
 	github.com/golang/protobuf v1.3.2 // indirect
 	github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc
 	github.com/imdario/mergo v0.3.7
@@ -54,8 +53,6 @@ require (
 	github.com/mattn/go-sqlite3 v2.0.3+incompatible
 	github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
 	github.com/olekukonko/tablewriter v0.0.1
-	github.com/onsi/ginkgo v1.7.0 // indirect
-	github.com/onsi/gomega v1.4.3 // indirect
 	github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
 	github.com/pelletier/go-toml v1.4.0 // indirect
 	github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829

Should I push this change as well?

# Description `viper` doesn't expand `~` by default, resulting in malformed config path: ```bash ... Config File "config" Not Found in "[... /opt/vikunja/~/.config/vikunja]" ``` According to [this issue](https://github.com/spf13/viper/issues/282) however, env variable expansion works, which allows for `AddConfigPath("$HOME/.config/vikunja")`, **with one exception**: Doesn't work on windows. Works on Linux, but vikunja has to work on Windows, too? I'm confused because there a windows download on your file server, but all paths are clearly only linux compatible. See #147: a windows compatible version (Can't actually test on windows machine) For a portable version, `AddConfigPath(path.Join(os.UserHomeDir(), ".config", "vikunja").String())` or similar will have to be used. Tested successfully on Ubuntu 18.04 64 bit # Checklist * [ ] I added or improved tests * [ ] I pushed new or updated dependencies to the repo using `go mod vendor` * [ ] I added or improved docs for my feature * [ ] Swagger (including `make do-the-swag`) * [ ] Error codes * [ ] New config options I am not sure what the makefile does when running `make build` and how go manages dependencies, but I did not touch `mod.go`, while it has changed (on local computer for now, can push if necessary) with this diff: ```bash diff --git a/go.mod b/go.mod index 636aad4..6a43051 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,6 @@ require ( github.com/go-testfixtures/testfixtures/v3 v3.1.1 github.com/go-xorm/core v0.6.2 // indirect github.com/go-xorm/xorm v0.7.9 // indirect - github.com/gogo/protobuf v1.2.0 // indirect github.com/golang/protobuf v1.3.2 // indirect github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc github.com/imdario/mergo v0.3.7 @@ -54,8 +53,6 @@ require ( github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 github.com/olekukonko/tablewriter v0.0.1 - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/pelletier/go-toml v1.4.0 // indirect github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 ``` Should I push this change as well?
Owner

I'm confused because there a windows download on your file server, but all paths are clearly only linux compatible

Yes, that is something that needs to be fixed.

> I'm confused because there a windows download on your file server, but all paths are clearly only linux compatible Yes, that is something that needs to be fixed.
Owner

I am not sure what the makefile does when running make build and how go manages dependencies, but I did not touch mod.go, while it has changed (on local computer for now, can push if necessary) with this diff

It's interesting it changed, but should be fine. You did not change any dependency usage.

> I am not sure what the makefile does when running make build and how go manages dependencies, but I did not touch mod.go, while it has changed (on local computer for now, can push if necessary) with this diff It's interesting it changed, but should be fine. You did not change any dependency usage.
konrad approved these changes 2020-02-28 20:59:04 +00:00
Owner

This is still marked as WIP, can I merge this?

This is still marked as WIP, can I merge this?
funkythings changed title from WIP: expand relative path ~/.config/vikunja to $HOME/.config/vikunja to expand relative path ~/.config/vikunja to $HOME/.config/vikunja 2020-02-29 10:28:56 +00:00
Author
Contributor

Ran go mod tidy && go mod vendor on both branches (this pull and #147) and committed the results

Ran `go mod tidy && go mod vendor` on both branches (this pull and #147) and committed the results
konrad approved these changes 2020-02-29 19:51:27 +00:00
konrad left a comment
Owner

Awesome, thanks!

Awesome, thanks!
konrad closed this pull request 2020-02-29 19:51:47 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#146
No description provided.