mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Converge etcd functionality as part of quick.Config
This commit is contained in:
committed by
kannappanr
parent
6df1e4a529
commit
481390d51a
@@ -27,7 +27,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
etcdc "github.com/coreos/etcd/client"
|
||||
etcd "github.com/coreos/etcd/client"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
@@ -49,7 +49,7 @@ func checkUpdate(mode string) {
|
||||
// Initialize and load config from remote etcd or local config directory
|
||||
func initConfig() {
|
||||
if globalEtcdClient != nil {
|
||||
kapi := etcdc.NewKeysAPI(globalEtcdClient)
|
||||
kapi := etcd.NewKeysAPI(globalEtcdClient)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
_, err := kapi.Get(ctx, getConfigFile(), nil)
|
||||
cancel()
|
||||
@@ -57,7 +57,7 @@ func initConfig() {
|
||||
logger.FatalIf(migrateConfig(), "Config migration failed.")
|
||||
logger.FatalIf(loadConfig(), "Unable to load config version: '%s'.", serverConfigVersion)
|
||||
} else {
|
||||
if etcdc.IsKeyNotFound(err) {
|
||||
if etcd.IsKeyNotFound(err) {
|
||||
logger.FatalIf(newConfig(), "Unable to initialize minio config for the first time.")
|
||||
logger.Info("Created minio configuration file successfully at", globalEtcdClient.Endpoints())
|
||||
} else {
|
||||
@@ -154,7 +154,7 @@ func handleCommonEnvVars() {
|
||||
if ok {
|
||||
etcdEndpoints := strings.Split(etcdEndpointsEnv, ",")
|
||||
var err error
|
||||
globalEtcdClient, err = etcdc.New(etcdc.Config{
|
||||
globalEtcdClient, err = etcd.New(etcd.Config{
|
||||
Endpoints: etcdEndpoints,
|
||||
Transport: &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
|
||||
@@ -129,26 +129,17 @@ func (s *serverConfig) GetCacheConfig() CacheConfig {
|
||||
|
||||
// Save config file to corresponding backend
|
||||
func Save(configFile string, data interface{}) error {
|
||||
if globalEtcdClient == nil {
|
||||
return quick.SaveLocalConfig(configFile, data)
|
||||
}
|
||||
return quick.SaveEtcdConfig(configFile, data, globalEtcdClient)
|
||||
return quick.SaveConfig(data, configFile, globalEtcdClient)
|
||||
}
|
||||
|
||||
// Load config from backend
|
||||
func Load(configFile string, data interface{}) (quick.Config, error) {
|
||||
if globalEtcdClient == nil {
|
||||
return quick.LoadLocalConfig(configFile, data)
|
||||
}
|
||||
return quick.LoadEtcdConfig(configFile, data, globalEtcdClient)
|
||||
return quick.LoadConfig(configFile, globalEtcdClient, data)
|
||||
}
|
||||
|
||||
// GetVersion gets config version from backend
|
||||
func GetVersion(configFile string) (string, error) {
|
||||
if globalEtcdClient == nil {
|
||||
return quick.GetLocalVersion(configFile)
|
||||
}
|
||||
return quick.GetEtcdVersion(configFile, globalEtcdClient)
|
||||
return quick.GetVersion(configFile, globalEtcdClient)
|
||||
}
|
||||
|
||||
// Returns the string describing a difference with the given
|
||||
@@ -296,17 +287,7 @@ func newConfig() error {
|
||||
// newQuickConfig - initialize a new server config, with an allocated
|
||||
// quick.Config interface.
|
||||
func newQuickConfig(srvCfg *serverConfig) (*serverConfig, error) {
|
||||
if globalEtcdClient == nil {
|
||||
qcfg, err := quick.NewLocalConfig(srvCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
srvCfg.Config = qcfg
|
||||
return srvCfg, nil
|
||||
}
|
||||
|
||||
qcfg, err := quick.NewEtcdConfig(srvCfg, globalEtcdClient)
|
||||
qcfg, err := quick.NewConfig(srvCfg, globalEtcdClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
etcdc "github.com/coreos/etcd/client"
|
||||
etcd "github.com/coreos/etcd/client"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/event"
|
||||
@@ -195,7 +195,7 @@ func purgeV1() error {
|
||||
|
||||
cv1 := &configV1{}
|
||||
_, err := Load(configFile, cv1)
|
||||
if os.IsNotExist(err) || etcdc.IsKeyNotFound(err) {
|
||||
if os.IsNotExist(err) || etcd.IsKeyNotFound(err) {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("Unable to load config version ‘1’. %v", err)
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
etcdc "github.com/coreos/etcd/client"
|
||||
etcd "github.com/coreos/etcd/client"
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
xhttp "github.com/minio/minio/cmd/http"
|
||||
@@ -200,7 +200,7 @@ var (
|
||||
globalRPCAPIVersion = RPCVersion{3, 0, 0}
|
||||
|
||||
// Allocated etcd endpoint for config and bucket DNS.
|
||||
globalEtcdClient etcdc.Client
|
||||
globalEtcdClient etcd.Client
|
||||
|
||||
// Allocated DNS config wrapper over etcd client.
|
||||
globalDNSConfig dns.Config
|
||||
|
||||
Reference in New Issue
Block a user