mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Pass through CA cert file to the connection when multiple vcenters are configured
This commit is contained in:
parent
b83028325c
commit
7ade8261f6
@ -428,6 +428,7 @@ func populateVsphereInstanceMap(cfg *VSphereConfig) (map[string]*VSphereInstance
|
||||
Insecure: cfg.Global.InsecureFlag,
|
||||
RoundTripperCount: vcConfig.RoundTripperCount,
|
||||
Port: vcConfig.VCenterPort,
|
||||
CACert: cfg.Global.CAFile,
|
||||
Thumbprint: vcConfig.Thumbprint,
|
||||
}
|
||||
vsphereIns := VSphereInstance{
|
||||
|
@ -641,6 +641,28 @@ func TestSecretVSphereConfig(t *testing.T) {
|
||||
"1.1.1.1": "thumbprint:1",
|
||||
},
|
||||
},
|
||||
{
|
||||
testName: "Multiple virtual centers use the global CA cert",
|
||||
conf: `[Global]
|
||||
user = user
|
||||
password = password
|
||||
datacenter = us-west
|
||||
ca-file = /some/path/to/my/trusted/ca.pem
|
||||
[VirtualCenter "0.0.0.0"]
|
||||
user = user
|
||||
password = password
|
||||
[VirtualCenter "1.1.1.1"]
|
||||
user = user
|
||||
password = password
|
||||
[Workspace]
|
||||
server = 0.0.0.0
|
||||
datacenter = us-west
|
||||
folder = kubernetes
|
||||
`,
|
||||
expectedUsername: username,
|
||||
expectedPassword: password,
|
||||
expectedError: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testcase := range testcases {
|
||||
@ -672,6 +694,7 @@ func TestSecretVSphereConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check, if all the expected thumbprints are configured
|
||||
for instanceName, expectedThumbprint := range testcase.expectedThumbprints {
|
||||
instanceConfig, ok := vs.vsphereInstanceMap[instanceName]
|
||||
if !ok {
|
||||
@ -684,5 +707,16 @@ func TestSecretVSphereConfig(t *testing.T) {
|
||||
)
|
||||
}
|
||||
}
|
||||
// Check, if all all connections are configured with the global CA certificate
|
||||
if expectedCaPath := cfg.Global.CAFile; expectedCaPath != "" {
|
||||
for name, instance := range vs.vsphereInstanceMap {
|
||||
if actualCaPath := instance.conn.CACert; actualCaPath != expectedCaPath {
|
||||
t.Fatalf(
|
||||
"Expected CA certificate path for instance '%s' to be the globally configured one ('%s'), got '%s'",
|
||||
name, expectedCaPath, actualCaPath,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user