From b3f1f558b30fa776dc6e5d9543146effa282acd2 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 17 Sep 2019 12:10:48 +0200 Subject: [PATCH] vendor: remove configdir Close #940 --- Gopkg.lock | 9 - vendor/github.com/shibukawa/configdir/LICENSE | 21 --- .../github.com/shibukawa/configdir/config.go | 160 ------------------ .../shibukawa/configdir/config_darwin.go | 8 - .../shibukawa/configdir/config_windows.go | 8 - .../shibukawa/configdir/config_xdg.go | 34 ---- 6 files changed, 240 deletions(-) delete mode 100644 vendor/github.com/shibukawa/configdir/LICENSE delete mode 100644 vendor/github.com/shibukawa/configdir/config.go delete mode 100644 vendor/github.com/shibukawa/configdir/config_darwin.go delete mode 100644 vendor/github.com/shibukawa/configdir/config_windows.go delete mode 100644 vendor/github.com/shibukawa/configdir/config_xdg.go diff --git a/Gopkg.lock b/Gopkg.lock index 955039335a0..ea8ea015d74 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -452,14 +452,6 @@ pruneopts = "NUT" revision = "a683aaf2d516deecd70cad0c72e3ca773ecfcef0" -[[projects]] - branch = "master" - digest = "1:41618aee8828e62dfe62d44f579c06892d0e98907d1c6d5bcd83bfe8536ec5a3" - name = "github.com/shibukawa/configdir" - packages = ["."] - pruneopts = "NUT" - revision = "e180dbdc8da04c4fa04272e875ce64949f38bd3e" - [[projects]] branch = "master" digest = "1:88925026dc080b29f50bc9c917224dac3d4fa1df614df38429c3b373130c9a56" @@ -712,7 +704,6 @@ "github.com/pkg/errors", "github.com/pmezard/go-difflib/difflib", "github.com/serenize/snaker", - "github.com/shibukawa/configdir", "github.com/sirupsen/logrus", "github.com/sirupsen/logrus/hooks/test", "github.com/spf13/afero", diff --git a/vendor/github.com/shibukawa/configdir/LICENSE b/vendor/github.com/shibukawa/configdir/LICENSE deleted file mode 100644 index b20af456a19..00000000000 --- a/vendor/github.com/shibukawa/configdir/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 shibukawa - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/shibukawa/configdir/config.go b/vendor/github.com/shibukawa/configdir/config.go deleted file mode 100644 index 8a20e54b59a..00000000000 --- a/vendor/github.com/shibukawa/configdir/config.go +++ /dev/null @@ -1,160 +0,0 @@ -// configdir provides access to configuration folder in each platforms. -// -// System wide configuration folders: -// -// - Windows: %PROGRAMDATA% (C:\ProgramData) -// - Linux/BSDs: ${XDG_CONFIG_DIRS} (/etc/xdg) -// - MacOSX: "/Library/Application Support" -// -// User wide configuration folders: -// -// - Windows: %APPDATA% (C:\Users\\AppData\Roaming) -// - Linux/BSDs: ${XDG_CONFIG_HOME} (${HOME}/.config) -// - MacOSX: "${HOME}/Library/Application Support" -// -// User wide cache folders: -// -// - Windows: %LOCALAPPDATA% (C:\Users\\AppData\Local) -// - Linux/BSDs: ${XDG_CACHE_HOME} (${HOME}/.cache) -// - MacOSX: "${HOME}/Library/Caches" -// -// configdir returns paths inside the above folders. - -package configdir - -import ( - "io/ioutil" - "os" - "path/filepath" -) - -type ConfigType int - -const ( - System ConfigType = iota - Global - All - Existing - Local - Cache -) - -// Config represents each folder -type Config struct { - Path string - Type ConfigType -} - -func (c Config) Open(fileName string) (*os.File, error) { - return os.Open(filepath.Join(c.Path, fileName)) -} - -func (c Config) Create(fileName string) (*os.File, error) { - err := c.CreateParentDir(fileName) - if err != nil { - return nil, err - } - return os.Create(filepath.Join(c.Path, fileName)) -} - -func (c Config) ReadFile(fileName string) ([]byte, error) { - return ioutil.ReadFile(filepath.Join(c.Path, fileName)) -} - -// CreateParentDir creates the parent directory of fileName inside c. fileName -// is a relative path inside c, containing zero or more path separators. -func (c Config) CreateParentDir(fileName string) error { - return os.MkdirAll(filepath.Dir(filepath.Join(c.Path, fileName)), 0755) -} - -func (c Config) WriteFile(fileName string, data []byte) error { - err := c.CreateParentDir(fileName) - if err != nil { - return err - } - return ioutil.WriteFile(filepath.Join(c.Path, fileName), data, 0644) -} - -func (c Config) MkdirAll() error { - return os.MkdirAll(c.Path, 0755) -} - -func (c Config) Exists(fileName string) bool { - _, err := os.Stat(filepath.Join(c.Path, fileName)) - return !os.IsNotExist(err) -} - -// ConfigDir keeps setting for querying folders. -type ConfigDir struct { - VendorName string - ApplicationName string - LocalPath string -} - -func New(vendorName, applicationName string) ConfigDir { - return ConfigDir{ - VendorName: vendorName, - ApplicationName: applicationName, - } -} - -func (c ConfigDir) joinPath(root string) string { - if c.VendorName != "" && hasVendorName { - return filepath.Join(root, c.VendorName, c.ApplicationName) - } - return filepath.Join(root, c.ApplicationName) -} - -func (c ConfigDir) QueryFolders(configType ConfigType) []*Config { - if configType == Cache { - return []*Config{c.QueryCacheFolder()} - } - var result []*Config - if c.LocalPath != "" && configType != System && configType != Global { - result = append(result, &Config{ - Path: c.LocalPath, - Type: Local, - }) - } - if configType != System && configType != Local { - result = append(result, &Config{ - Path: c.joinPath(globalSettingFolder), - Type: Global, - }) - } - if configType != Global && configType != Local { - for _, root := range systemSettingFolders { - result = append(result, &Config{ - Path: c.joinPath(root), - Type: System, - }) - } - } - if configType != Existing { - return result - } - var existing []*Config - for _, entry := range result { - if _, err := os.Stat(entry.Path); !os.IsNotExist(err) { - existing = append(existing, entry) - } - } - return existing -} - -func (c ConfigDir) QueryFolderContainsFile(fileName string) *Config { - configs := c.QueryFolders(Existing) - for _, config := range configs { - if _, err := os.Stat(filepath.Join(config.Path, fileName)); !os.IsNotExist(err) { - return config - } - } - return nil -} - -func (c ConfigDir) QueryCacheFolder() *Config { - return &Config{ - Path: c.joinPath(cacheFolder), - Type: Cache, - } -} diff --git a/vendor/github.com/shibukawa/configdir/config_darwin.go b/vendor/github.com/shibukawa/configdir/config_darwin.go deleted file mode 100644 index d668507a7e3..00000000000 --- a/vendor/github.com/shibukawa/configdir/config_darwin.go +++ /dev/null @@ -1,8 +0,0 @@ -package configdir - -import "os" - -var hasVendorName = true -var systemSettingFolders = []string{"/Library/Application Support"} -var globalSettingFolder = os.Getenv("HOME") + "/Library/Application Support" -var cacheFolder = os.Getenv("HOME") + "/Library/Caches" diff --git a/vendor/github.com/shibukawa/configdir/config_windows.go b/vendor/github.com/shibukawa/configdir/config_windows.go deleted file mode 100644 index 0984821778d..00000000000 --- a/vendor/github.com/shibukawa/configdir/config_windows.go +++ /dev/null @@ -1,8 +0,0 @@ -package configdir - -import "os" - -var hasVendorName = true -var systemSettingFolders = []string{os.Getenv("PROGRAMDATA")} -var globalSettingFolder = os.Getenv("APPDATA") -var cacheFolder = os.Getenv("LOCALAPPDATA") diff --git a/vendor/github.com/shibukawa/configdir/config_xdg.go b/vendor/github.com/shibukawa/configdir/config_xdg.go deleted file mode 100644 index 026ca68a0bb..00000000000 --- a/vendor/github.com/shibukawa/configdir/config_xdg.go +++ /dev/null @@ -1,34 +0,0 @@ -// +build !windows,!darwin - -package configdir - -import ( - "os" - "path/filepath" - "strings" -) - -// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html - -var hasVendorName = true -var systemSettingFolders []string -var globalSettingFolder string -var cacheFolder string - -func init() { - if os.Getenv("XDG_CONFIG_HOME") != "" { - globalSettingFolder = os.Getenv("XDG_CONFIG_HOME") - } else { - globalSettingFolder = filepath.Join(os.Getenv("HOME"), ".config") - } - if os.Getenv("XDG_CONFIG_DIRS") != "" { - systemSettingFolders = strings.Split(os.Getenv("XDG_CONFIG_DIRS"), ":") - } else { - systemSettingFolders = []string{"/etc/xdg"} - } - if os.Getenv("XDG_CACHE_HOME") != "" { - cacheFolder = os.Getenv("XDG_CACHE_HOME") - } else { - cacheFolder = filepath.Join(os.Getenv("HOME"), ".cache") - } -}