Compare commits

..

6 Commits

Author SHA1 Message Date
94bcb0087f Fix typo in pipeline
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-02-01 06:53:23 +01:00
12e9c72463 More detailed coverage in pipeline
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-02-01 06:52:20 +01:00
cc4835f224 Remove wsl linter
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-01-27 11:48:49 +01:00
9d9bb3f0ac Tidy go.mod
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-01-27 11:47:43 +01:00
daa6ad4278 Update dependencies
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-01-27 11:46:32 +01:00
cc4e61f981 Add gofumpt linter
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-01-27 11:36:16 +01:00
10 changed files with 18 additions and 15 deletions

View File

@ -24,10 +24,10 @@ linters:
- ireturn - ireturn
- gocritic - gocritic
- whitespace - whitespace
- wsl
- stylecheck - stylecheck
- exportloopref - exportloopref
- godot - godot
- gofumpt
linters-settings: linters-settings:
gomnd: gomnd:

View File

@ -4,7 +4,8 @@ pipeline:
commands: commands:
- go build -o gpaste-client ./cmd/client/client.go - go build -o gpaste-client ./cmd/client/client.go
- go build -o gpaste-server ./cmd/server/server.go - go build -o gpaste-server ./cmd/server/server.go
- go test -cover ./... - go test -cover -coverprofile="/tmp/cover.out" ./...
- go tool cover -func="/tmp/cover.out"
- go vet ./... - go vet ./...
when: when:
branch: master branch: master

View File

@ -13,6 +13,7 @@ type RequestAPILogin struct {
type ResponseAPILogin struct { type ResponseAPILogin struct {
Token string `json:"token"` Token string `json:"token"`
} }
type ResponseAPIFilePost struct { type ResponseAPIFilePost struct {
Message string `json:"message"` Message string `json:"message"`
Files []ResponseAPIFilePostFiles `json:"files"` Files []ResponseAPIFilePostFiles `json:"files"`

View File

@ -58,7 +58,6 @@ func (as *AuthService) ValidateToken(rawToken string) (*Claims, error) {
token, err := jwt.ParseWithClaims(rawToken, claims, func(t *jwt.Token) (interface{}, error) { token, err := jwt.ParseWithClaims(rawToken, claims, func(t *jwt.Token) (interface{}, error) {
return as.hmacSecret, nil return as.hmacSecret, nil
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -31,6 +31,7 @@ func (c *Client) WriteConfigToWriter(w io.Writer) error {
encoder := json.NewEncoder(w) encoder := json.NewEncoder(w)
return encoder.Encode(c) return encoder.Encode(c)
} }
func (c *Client) WriteConfig() error { func (c *Client) WriteConfig() error {
dir := configdir.LocalConfig("gpaste") dir := configdir.LocalConfig("gpaste")
// Ensure dir exists // Ensure dir exists

View File

@ -23,6 +23,7 @@ func NewFSFileStore(dir string) (*FSFileStore, error) {
return s, err return s, err
} }
func (s *FSFileStore) Store(f *File) error { func (s *FSFileStore) Store(f *File) error {
defer f.Body.Close() defer f.Body.Close()

10
go.mod
View File

@ -2,19 +2,17 @@ module git.t-juice.club/torjus/gpaste
go 1.17 go 1.17
require github.com/google/uuid v1.3.0
require github.com/go-chi/chi/v5 v5.0.7
require ( require (
github.com/go-chi/chi/v5 v5.0.7
github.com/golang-jwt/jwt v3.2.2+incompatible github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/go-cmp v0.5.6 github.com/google/go-cmp v0.5.7
github.com/google/uuid v1.3.0
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
github.com/pelletier/go-toml v1.9.4 github.com/pelletier/go-toml v1.9.4
github.com/urfave/cli/v2 v2.3.0 github.com/urfave/cli/v2 v2.3.0
go.etcd.io/bbolt v1.3.6 go.etcd.io/bbolt v1.3.6
go.uber.org/zap v1.20.0 go.uber.org/zap v1.20.0
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
) )

8
go.sum
View File

@ -11,8 +11,8 @@ github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU= github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU=
@ -51,8 +51,8 @@ go.uber.org/zap v1.20.0 h1:N4oPlghZwYG55MlU6LXk/Zp00FVNE9X9wrYO8CEs4lc=
go.uber.org/zap v1.20.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= go.uber.org/zap v1.20.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI= golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8 h1:kACShD3qhmr/3rLmg1yXyt+N4HcwutKyPRB93s54TIU=
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=

View File

@ -15,7 +15,7 @@ type BoltUserStore struct {
} }
func NewBoltUserStore(path string) (*BoltUserStore, error) { func NewBoltUserStore(path string) (*BoltUserStore, error) {
db, err := bbolt.Open(path, 0666, nil) // nolint: gomnd db, err := bbolt.Open(path, 0o666, nil) // nolint: gomnd
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -45,7 +45,6 @@ func (s *BoltUserStore) Get(username string) (*User, error) {
} }
return nil return nil
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -72,6 +71,7 @@ func (s *BoltUserStore) Delete(username string) error {
return bkt.Delete([]byte(username)) return bkt.Delete([]byte(username))
}) })
} }
func (s *BoltUserStore) List() ([]string, error) { func (s *BoltUserStore) List() ([]string, error) {
var ids []string var ids []string

View File

@ -15,6 +15,7 @@ type MemoryUserStore struct {
func NewMemoryUserStore() *MemoryUserStore { func NewMemoryUserStore() *MemoryUserStore {
return &MemoryUserStore{users: make(map[string]*User)} return &MemoryUserStore{users: make(map[string]*User)}
} }
func (s *MemoryUserStore) Get(username string) (*User, error) { func (s *MemoryUserStore) Get(username string) (*User, error) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()
@ -45,6 +46,7 @@ func (s *MemoryUserStore) Delete(username string) error {
return nil return nil
} }
func (s *MemoryUserStore) List() ([]string, error) { func (s *MemoryUserStore) List() ([]string, error) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()