mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-02 22:17:10 +08:00

* Use normalizer as stream source Renamed 'writer' service to 'normalizer' and dropped Cassandra facilities from it. Extracted the common dependencies to 'mainflux' package for easier sharing. Fixed the API docs and unified environment variables. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Use docker build arguments to specify build Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Remove cassandra libraries Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Update go-kit version to 0.6.0 Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix manager configuration Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Refactor docker-compose Merged individual compose files and dropped external links. Remove CoAP container since it is not referenced from NginX config at the moment. Update port mapping in compose and nginx.conf. Dropped bin scripts. Updated service documentation. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Drop content-type check Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Implement users data access layer in PostgreSQL Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Bump version to 0.1.0 Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Use go-kit logger everywhere (except CoAP) Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Improve factory methods naming Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Implement clients data access layer on PostgreSQL Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Make tests stateless All tests are refactored to use map-based table-driven tests. No cross-tests dependencies is present anymore. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Remove gitignore Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix nginx proxying Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Mark client-user FK explicit Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Update API documentation Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Update channel model Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Add channel PostgreSQL repository tests Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Implement PostgreSQL channels DAO Replaced update queries with raw SQL. Explicitly defined M2M table due to difficulties of ensuring the referential integrity through GORM. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Expose connection endpoints Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix swagger docs and remove DB logging Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix nested query remarks Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Add unique indices Signed-off-by: Dejan Mijic <dejan@mainflux.com>
86 lines
2.2 KiB
Go
86 lines
2.2 KiB
Go
package pathdriver
|
|
|
|
import (
|
|
"path/filepath"
|
|
)
|
|
|
|
// PathDriver provides all of the path manipulation functions in a common
|
|
// interface. The context should call these and never use the `filepath`
|
|
// package or any other package to manipulate paths.
|
|
type PathDriver interface {
|
|
Join(paths ...string) string
|
|
IsAbs(path string) bool
|
|
Rel(base, target string) (string, error)
|
|
Base(path string) string
|
|
Dir(path string) string
|
|
Clean(path string) string
|
|
Split(path string) (dir, file string)
|
|
Separator() byte
|
|
Abs(path string) (string, error)
|
|
Walk(string, filepath.WalkFunc) error
|
|
FromSlash(path string) string
|
|
ToSlash(path string) string
|
|
Match(pattern, name string) (matched bool, err error)
|
|
}
|
|
|
|
// pathDriver is a simple default implementation calls the filepath package.
|
|
type pathDriver struct{}
|
|
|
|
// LocalPathDriver is the exported pathDriver struct for convenience.
|
|
var LocalPathDriver PathDriver = &pathDriver{}
|
|
|
|
func (*pathDriver) Join(paths ...string) string {
|
|
return filepath.Join(paths...)
|
|
}
|
|
|
|
func (*pathDriver) IsAbs(path string) bool {
|
|
return filepath.IsAbs(path)
|
|
}
|
|
|
|
func (*pathDriver) Rel(base, target string) (string, error) {
|
|
return filepath.Rel(base, target)
|
|
}
|
|
|
|
func (*pathDriver) Base(path string) string {
|
|
return filepath.Base(path)
|
|
}
|
|
|
|
func (*pathDriver) Dir(path string) string {
|
|
return filepath.Dir(path)
|
|
}
|
|
|
|
func (*pathDriver) Clean(path string) string {
|
|
return filepath.Clean(path)
|
|
}
|
|
|
|
func (*pathDriver) Split(path string) (dir, file string) {
|
|
return filepath.Split(path)
|
|
}
|
|
|
|
func (*pathDriver) Separator() byte {
|
|
return filepath.Separator
|
|
}
|
|
|
|
func (*pathDriver) Abs(path string) (string, error) {
|
|
return filepath.Abs(path)
|
|
}
|
|
|
|
// Note that filepath.Walk calls os.Stat, so if the context wants to
|
|
// to call Driver.Stat() for Walk, they need to create a new struct that
|
|
// overrides this method.
|
|
func (*pathDriver) Walk(root string, walkFn filepath.WalkFunc) error {
|
|
return filepath.Walk(root, walkFn)
|
|
}
|
|
|
|
func (*pathDriver) FromSlash(path string) string {
|
|
return filepath.FromSlash(path)
|
|
}
|
|
|
|
func (*pathDriver) ToSlash(path string) string {
|
|
return filepath.ToSlash(path)
|
|
}
|
|
|
|
func (*pathDriver) Match(pattern, name string) (bool, error) {
|
|
return filepath.Match(pattern, name)
|
|
}
|