mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 05:08:22 +00:00
* fix(deps): update module github.com/petergtz/pegomock/v3 to v4 in go.mod * remove pegomock generate m option, which is not support after v4 * make regen-mocks * replace pegomock v4 primitive eq/matchers * convert pegomock v4 Eq/Any matchers * remove custom models.Repo matcher * pegomock v4 cannot use result method args ref https://github.com/petergtz/pegomock/issues/123 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
41 lines
857 B
Go
41 lines
857 B
Go
package models
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
//go:generate pegomock generate --package mocks -o mocks/mock_filepath.go FilePath
|
|
|
|
type FilePath interface {
|
|
NotExists() bool
|
|
Join(elem ...string) FilePath
|
|
Symlink(newname string) (FilePath, error)
|
|
Resolve() string
|
|
}
|
|
|
|
type LocalFilePath string
|
|
|
|
func (fp LocalFilePath) NotExists() bool {
|
|
_, err := os.Stat(string(fp))
|
|
|
|
return os.IsNotExist(err)
|
|
}
|
|
|
|
func (fp LocalFilePath) Join(elem ...string) FilePath {
|
|
pathComponents := []string{}
|
|
|
|
pathComponents = append(pathComponents, string(fp))
|
|
pathComponents = append(pathComponents, elem...)
|
|
|
|
return LocalFilePath(filepath.Join(pathComponents...))
|
|
}
|
|
|
|
func (fp LocalFilePath) Symlink(newname string) (FilePath, error) {
|
|
return LocalFilePath(newname), os.Symlink(fp.Resolve(), newname)
|
|
}
|
|
|
|
func (fp LocalFilePath) Resolve() string {
|
|
return string(fp)
|
|
}
|