Browse Source

embed: deprecate "CAFile" field

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
c524ebe6fd
2 changed files with 4 additions and 7 deletions
  1. 1 3
      embed/config.go
  2. 3 4
      embed/config_test.go

+ 1 - 3
embed/config.go

@@ -247,7 +247,6 @@ type configJSON struct {
 }
 }
 
 
 type securityConfig struct {
 type securityConfig struct {
-	CAFile        string `json:"ca-file"`
 	CertFile      string `json:"cert-file"`
 	CertFile      string `json:"cert-file"`
 	KeyFile       string `json:"key-file"`
 	KeyFile       string `json:"key-file"`
 	CertAuth      bool   `json:"client-cert-auth"`
 	CertAuth      bool   `json:"client-cert-auth"`
@@ -421,7 +420,6 @@ func (cfg *configYAML) configFromFile(path string) error {
 	}
 	}
 
 
 	copySecurityDetails := func(tls *transport.TLSInfo, ysc *securityConfig) {
 	copySecurityDetails := func(tls *transport.TLSInfo, ysc *securityConfig) {
-		tls.CAFile = ysc.CAFile
 		tls.CertFile = ysc.CertFile
 		tls.CertFile = ysc.CertFile
 		tls.KeyFile = ysc.KeyFile
 		tls.KeyFile = ysc.KeyFile
 		tls.ClientCertAuth = ysc.CertAuth
 		tls.ClientCertAuth = ysc.CertAuth
@@ -525,7 +523,7 @@ func (cfg *Config) PeerURLsMapAndToken(which string) (urlsmap types.URLsMap, tok
 			plog.Noticef("got bootstrap from DNS for etcd-server at %s", s)
 			plog.Noticef("got bootstrap from DNS for etcd-server at %s", s)
 		}
 		}
 		clusterStr := strings.Join(clusterStrs, ",")
 		clusterStr := strings.Join(clusterStrs, ",")
-		if strings.Contains(clusterStr, "https://") && cfg.PeerTLSInfo.CAFile == "" {
+		if strings.Contains(clusterStr, "https://") && cfg.PeerTLSInfo.TrustedCAFile == "" {
 			cfg.PeerTLSInfo.ServerName = cfg.DNSCluster
 			cfg.PeerTLSInfo.ServerName = cfg.DNSCluster
 		}
 		}
 		urlsmap, err = types.NewURLsMap(clusterStr)
 		urlsmap, err = types.NewURLsMap(clusterStr)

+ 3 - 4
embed/config_test.go

@@ -27,8 +27,8 @@ import (
 )
 )
 
 
 func TestConfigFileOtherFields(t *testing.T) {
 func TestConfigFileOtherFields(t *testing.T) {
-	ctls := securityConfig{CAFile: "cca", CertFile: "ccert", KeyFile: "ckey"}
-	ptls := securityConfig{CAFile: "pca", CertFile: "pcert", KeyFile: "pkey"}
+	ctls := securityConfig{TrustedCAFile: "cca", CertFile: "ccert", KeyFile: "ckey"}
+	ptls := securityConfig{TrustedCAFile: "pca", CertFile: "pcert", KeyFile: "pkey"}
 	yc := struct {
 	yc := struct {
 		ClientSecurityCfgFile securityConfig `json:"client-transport-security"`
 		ClientSecurityCfgFile securityConfig `json:"client-transport-security"`
 		PeerSecurityCfgFile   securityConfig `json:"peer-transport-security"`
 		PeerSecurityCfgFile   securityConfig `json:"peer-transport-security"`
@@ -129,8 +129,7 @@ func TestUpdateDefaultClusterFromNameOverwrite(t *testing.T) {
 }
 }
 
 
 func (s *securityConfig) equals(t *transport.TLSInfo) bool {
 func (s *securityConfig) equals(t *transport.TLSInfo) bool {
-	return s.CAFile == t.CAFile &&
-		s.CertFile == t.CertFile &&
+	return s.CertFile == t.CertFile &&
 		s.CertAuth == t.ClientCertAuth &&
 		s.CertAuth == t.ClientCertAuth &&
 		s.TrustedCAFile == t.TrustedCAFile
 		s.TrustedCAFile == t.TrustedCAFile
 }
 }