mirror of
https://github.com/clearlinux/rkt.git
synced 2026-11-25 13:34:53 +00:00
rkt: Kill Default{Vendor,Custom}Path constants
This commit is contained in:
@@ -56,12 +56,6 @@ var (
|
||||
parsersForKind = make(map[string]map[string]configParser)
|
||||
)
|
||||
|
||||
// Default paths for vendor and custom configuration
|
||||
const (
|
||||
DefaultVendorPath = common.DefaultSystemConfigDir
|
||||
DefaultCustomPath = common.DefaultCustomConfigDir
|
||||
)
|
||||
|
||||
func addParser(kind, version string, parser configParser) {
|
||||
if len(kind) == 0 {
|
||||
panic("empty kind string when registering a config parser")
|
||||
@@ -110,10 +104,11 @@ func toArray(s map[string]struct{}) []string {
|
||||
}
|
||||
|
||||
// GetConfig gets the Config instance with configuration taken from
|
||||
// default vendor path (see DefaultVendorPath) overridden with
|
||||
// configuration from default custom path (see DefaultCustomPath).
|
||||
// default vendor path (see common.DefaultSystemConfigDir) overridden
|
||||
// with configuration from default custom path (see
|
||||
// common.DefaultSystemConfigDir).
|
||||
func GetConfig() (*Config, error) {
|
||||
return GetConfigFrom(DefaultVendorPath, DefaultCustomPath)
|
||||
return GetConfigFrom(common.DefaultSystemConfigDir, common.DefaultCustomConfigDir)
|
||||
}
|
||||
|
||||
// GetConfigFrom gets the Config instance with configuration taken from
|
||||
|
||||
+3
-2
@@ -24,6 +24,7 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/coreos/rkt/common"
|
||||
"github.com/coreos/rkt/pkg/keystore"
|
||||
"github.com/coreos/rkt/rkt/config"
|
||||
)
|
||||
@@ -53,8 +54,8 @@ func init() {
|
||||
globalFlagset.BoolVar(&globalFlags.Help, "help", false, "Print usage information and exit")
|
||||
globalFlagset.BoolVar(&globalFlags.Debug, "debug", false, "Print out more debug information to stderr")
|
||||
globalFlagset.StringVar(&globalFlags.Dir, "dir", defaultDataDir, "rkt data directory")
|
||||
globalFlagset.StringVar(&globalFlags.VendorConfigDir, "vendor-config", config.DefaultVendorPath, "vendor configuration directory")
|
||||
globalFlagset.StringVar(&globalFlags.CustomConfigDir, "custom-config", config.DefaultCustomPath, "custom configuration directory")
|
||||
globalFlagset.StringVar(&globalFlags.VendorConfigDir, "vendor-config", common.DefaultSystemConfigDir, "vendor configuration directory")
|
||||
globalFlagset.StringVar(&globalFlags.CustomConfigDir, "custom-config", common.DefaultCustomConfigDir, "custom configuration directory")
|
||||
globalFlagset.BoolVar(&globalFlags.InsecureSkipVerify, "insecure-skip-verify", false, "skip image or key verification")
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/coreos/rkt/Godeps/_workspace/src/github.com/ThomasRooney/gexpect"
|
||||
"github.com/coreos/rkt/rkt/config"
|
||||
"github.com/coreos/rkt/common"
|
||||
taas "github.com/coreos/rkt/tests/test-auth-server/aci"
|
||||
)
|
||||
|
||||
@@ -50,8 +50,8 @@ type genericAuthTest struct {
|
||||
func TestAuthBasic(t *testing.T) {
|
||||
tests := []genericAuthTest{
|
||||
{"basic-no-config", false, "", authFailedDownload},
|
||||
{"basic-custom-config", true, config.DefaultCustomPath, authSuccessfulDownload},
|
||||
{"basic-vendor-config", true, config.DefaultVendorPath, authSuccessfulDownload},
|
||||
{"basic-custom-config", true, common.DefaultCustomConfigDir, authSuccessfulDownload},
|
||||
{"basic-vendor-config", true, common.DefaultSystemConfigDir, authSuccessfulDownload},
|
||||
}
|
||||
testAuthGeneric(t, taas.Basic, tests)
|
||||
}
|
||||
@@ -59,8 +59,8 @@ func TestAuthBasic(t *testing.T) {
|
||||
func TestAuthOauth(t *testing.T) {
|
||||
tests := []genericAuthTest{
|
||||
{"oauth-no-config", false, "", authFailedDownload},
|
||||
{"oauth-custom-config", true, config.DefaultCustomPath, authSuccessfulDownload},
|
||||
{"oauth-vendor-config", true, config.DefaultVendorPath, authSuccessfulDownload},
|
||||
{"oauth-custom-config", true, common.DefaultCustomConfigDir, authSuccessfulDownload},
|
||||
{"oauth-vendor-config", true, common.DefaultSystemConfigDir, authSuccessfulDownload},
|
||||
}
|
||||
testAuthGeneric(t, taas.Oauth, tests)
|
||||
}
|
||||
@@ -126,8 +126,8 @@ func testAuthIgnoreBogusFiles(t *testing.T, server *taas.Server) {
|
||||
|
||||
func testAuthIgnoreSubdirectories(t *testing.T, server *taas.Server) {
|
||||
removeAllConfig(t)
|
||||
customSubdir := filepath.Join(config.DefaultCustomPath, "subdir")
|
||||
vendorSubdir := filepath.Join(config.DefaultVendorPath, "subdir")
|
||||
customSubdir := filepath.Join(common.DefaultCustomConfigDir, "subdir")
|
||||
vendorSubdir := filepath.Join(common.DefaultSystemConfigDir, "subdir")
|
||||
writeConfig(t, customSubdir, "test.json", server.Conf)
|
||||
writeConfig(t, vendorSubdir, "test.json", server.Conf)
|
||||
failedRunRkt(t, server.URL, "oauth-subdirectories")
|
||||
@@ -189,8 +189,8 @@ func runRkt(t *testing.T, host, dir string) *gexpect.ExpectSubprocess {
|
||||
|
||||
func removeAllConfig(t *testing.T) {
|
||||
dirs := []string{
|
||||
authDir(config.DefaultCustomPath),
|
||||
authDir(config.DefaultVendorPath),
|
||||
authDir(common.DefaultCustomConfigDir),
|
||||
authDir(common.DefaultSystemConfigDir),
|
||||
}
|
||||
for _, p := range dirs {
|
||||
if err := os.RemoveAll(p); err != nil {
|
||||
@@ -203,11 +203,11 @@ func removeAllConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func writeCustomConfig(t *testing.T, filename, contents string) {
|
||||
writeConfig(t, config.DefaultCustomPath, filename, contents)
|
||||
writeConfig(t, common.DefaultCustomConfigDir, filename, contents)
|
||||
}
|
||||
|
||||
func writeVendorConfig(t *testing.T, filename, contents string) {
|
||||
writeConfig(t, config.DefaultVendorPath, filename, contents)
|
||||
writeConfig(t, common.DefaultSystemConfigDir, filename, contents)
|
||||
}
|
||||
|
||||
func writeConfig(t *testing.T, baseDir, filename, contents string) {
|
||||
|
||||
Reference in New Issue
Block a user