Skip to content

Commit

Permalink
mv back to the original place the config interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin82 committed Aug 23, 2019
1 parent b98c1fa commit 6066ecc
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 26 deletions.
11 changes: 5 additions & 6 deletions cmd/mmock/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
"path/filepath"
"strings"

"github.com/jmartin82/mmock/internal/config"
"github.com/jmartin82/mmock/internal/config/parser"
"github.com/jmartin82/mmock/internal/console"
"github.com/jmartin82/mmock/internal/fs"
"github.com/jmartin82/mmock/internal/fs/parser"
"github.com/jmartin82/mmock/internal/server"
"github.com/jmartin82/mmock/internal/statistics"
"github.com/jmartin82/mmock/pkg/config"
"github.com/jmartin82/mmock/pkg/match"
"github.com/jmartin82/mmock/pkg/match/payload"
"github.com/jmartin82/mmock/pkg/mock"
Expand Down Expand Up @@ -96,16 +95,16 @@ func getMapping(path string) config.Mapping {
log.Fatalln(ErrNotFoundPath.Error())
}

fsMapper := fs.NewFileSystemMapper()
fsMapper := config.NewFileSystemMapper()
fsMapper.AddParser(parser.JSONReader{})
fsMapper.AddParser(parser.YAMLReader{})

fsUpdate := make(chan struct{})

watcher := fs.NewFileWatcher(path, fsUpdate)
watcher := config.NewFileWatcher(path, fsUpdate)
watcher.Bind()

return fs.NewConfigMapping(path, fsMapper, fsUpdate)
return config.NewConfigMapping(path, fsMapper, fsUpdate)
}

func getRouter(mapping config.Mapping, checker match.Matcher) *server.Router {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fs
package config

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fs
package config

import (
"errors"
Expand Down
12 changes: 10 additions & 2 deletions internal/fs/mapping.go → internal/config/mapping.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package fs
package config

import (
"errors"
"github.com/jmartin82/mmock/pkg/mock"
"log"
"os"
"path"
"path/filepath"
"sort"
"strings"
"sync"

"github.com/jmartin82/mmock/pkg/mock"
)

var ErrFilePathIsNotUnderConfigPath = errors.New("File path is not under config path")
var ErrMockDoesntExist = errors.New("Definition doesn't exist")

type Mapping interface {
Set(URI string, mock mock.Definition) error
Delete(URI string) error
Get(URI string) (mock.Definition, bool)
List() []mock.Definition
}

//PrioritySort mock array sorted by priority
type PrioritySort []mock.Definition

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fs
package config

import (
"github.com/jmartin82/mmock/pkg/mock"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/fs/watcher.go → internal/config/watcher.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fs
package config

import (
"log"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fs
package config

import (
"io/ioutil"
Expand Down
2 changes: 1 addition & 1 deletion internal/console/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"

assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/jmartin82/mmock/pkg/config"
"github.com/jmartin82/mmock/internal/config"
"github.com/jmartin82/mmock/pkg/match"
"github.com/jmartin82/mmock/pkg/mock"

Expand Down
3 changes: 1 addition & 2 deletions internal/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"bytes"
"encoding/gob"

"github.com/jmartin82/mmock/pkg/config"

"log"

"github.com/jmartin82/mmock/pkg/mock"
"github.com/jmartin82/mmock/internal/config"

"github.com/jmartin82/mmock/pkg/match"
)
Expand Down
10 changes: 0 additions & 10 deletions pkg/config/mapping.go

This file was deleted.

0 comments on commit 6066ecc

Please sign in to comment.