Skip to content

Commit

Permalink
fix(BREAKING): rename webdav/ --> lib/ (#36)
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
  • Loading branch information
hacdias authored Nov 10, 2019
1 parent 3ef86e8 commit 72d8e39
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
50 changes: 25 additions & 25 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
"strconv"
"strings"

"github.com/hacdias/webdav/v2/webdav"
"github.com/hacdias/webdav/v3/lib"
"github.com/spf13/pflag"
v "github.com/spf13/viper"
wd "golang.org/x/net/webdav"
"golang.org/x/net/webdav"
)

func parseRules(raw []interface{}) []*webdav.Rule {
rules := []*webdav.Rule{}
func parseRules(raw []interface{}) []*lib.Rule {
rules := []*lib.Rule{}

for _, v := range raw {
if r, ok := v.(map[interface{}]interface{}); ok {
rule := &webdav.Rule{
rule := &lib.Rule{
Regex: false,
Allow: false,
Path: "",
Expand Down Expand Up @@ -65,7 +65,7 @@ func loadFromEnv(v string) (string, error) {
return v, nil
}

func parseUsers(raw []interface{}, c *webdav.Config) {
func parseUsers(raw []interface{}, c *lib.Config) {
var err error
for _, v := range raw {
if u, ok := v.(map[interface{}]interface{}); ok {
Expand Down Expand Up @@ -93,7 +93,7 @@ func parseUsers(raw []interface{}, c *webdav.Config) {
checkErr(err)
}

user := &webdav.User{
user := &lib.User{
Username: username,
Password: password,
Scope: c.User.Scope,
Expand All @@ -113,19 +113,19 @@ func parseUsers(raw []interface{}, c *webdav.Config) {
user.Rules = parseRules(rules)
}

user.Handler = &wd.Handler{
Prefix: c.User.Handler.Prefix,
FileSystem: wd.Dir(user.Scope),
LockSystem: wd.NewMemLS(),
user.Handler = &webdav.Handler{
Prefix: c.User.Handler.Prefix,
FileSystem: webdav.Dir(user.Scope),
LockSystem: webdav.NewMemLS(),
}

c.Users[username] = user
}
}
}

func parseCors(cfg map[string]interface{}, c *webdav.Config) {
cors := webdav.CorsCfg{
func parseCors(cfg map[string]interface{}, c *lib.Config) {
cors := lib.CorsCfg{
Enabled: cfg["enabled"].(bool),
Credentials: cfg["credentials"].(bool),
}
Expand Down Expand Up @@ -156,32 +156,32 @@ func corsProperty(property string, cfg map[string]interface{}) []string {

if len(items) == 0 {
return def
} else {
return items
}

return items
}

return def
}

func readConfig(flags *pflag.FlagSet) *webdav.Config {
cfg := &webdav.Config{
User: &webdav.User{
func readConfig(flags *pflag.FlagSet) *lib.Config {
cfg := &lib.Config{
User: &lib.User{
Scope: getOpt(flags, "scope"),
Modify: getOptB(flags, "modify"),
Rules: []*webdav.Rule{},
Handler: &wd.Handler{
Prefix: getOpt(flags, "prefix"),
FileSystem: wd.Dir(getOpt(flags, "scope")),
LockSystem: wd.NewMemLS(),
Rules: []*lib.Rule{},
Handler: &webdav.Handler{
Prefix: getOpt(flags, "prefix"),
FileSystem: webdav.Dir(getOpt(flags, "scope")),
LockSystem: webdav.NewMemLS(),
},
},
Auth: getOptB(flags, "auth"),
Cors: webdav.CorsCfg{
Cors: lib.CorsCfg{
Enabled: false,
Credentials: false,
},
Users: map[string]*webdav.User{},
Users: map[string]*lib.User{},
}

rawRules := v.Get("rules")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/hacdias/webdav/v2
module github.com/hacdias/webdav/v3

go 1.12

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hacdias/webdav v1.4.1 h1:yhR4dgKr3JUfgDhFO2nWTq3HiYA37Sk/kaud/bRx1io=
github.com/hacdias/webdav/v2 v2.0.1 h1:Dm21dHGijWGOY8q/KkMPSXPMPK4xVTe5WqWE1hMJTnY=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
Expand Down
2 changes: 1 addition & 1 deletion webdav/user.go → lib/user.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package webdav
package lib

import (
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion webdav/utils.go → lib/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package webdav
package lib

import (
"strings"
Expand Down
2 changes: 1 addition & 1 deletion webdav/webdav.go → lib/webdav.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package webdav
package lib

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"runtime"

"github.com/hacdias/webdav/v2/cmd"
"github.com/hacdias/webdav/v3/cmd"
)

func main() {
Expand Down

0 comments on commit 72d8e39

Please sign in to comment.