mirror of
https://github.com/rancher/rke.git
synced 2025-09-17 07:30:01 +00:00
Merge pull request #3599 from jiaqiluo/fix-kubeapi-env-15
This commit is contained in:
@@ -203,7 +203,7 @@ func (c *Cluster) BuildKubeAPIProcess(host *hosts.Host, serviceOptions v3.Kubern
|
|||||||
"tls-private-key-file": pki.GetKeyPath(pki.KubeAPICertName),
|
"tls-private-key-file": pki.GetKeyPath(pki.KubeAPICertName),
|
||||||
}
|
}
|
||||||
CommandArrayArgs := make(map[string][]string, len(c.Services.KubeAPI.ExtraArgsArray))
|
CommandArrayArgs := make(map[string][]string, len(c.Services.KubeAPI.ExtraArgsArray))
|
||||||
Env := make([]string, len(c.Services.KubeAPI.ExtraEnv))
|
var Env []string
|
||||||
|
|
||||||
if len(c.CloudProvider.Name) > 0 {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
CommandArgs["cloud-config"] = cloudConfigFileName
|
CommandArgs["cloud-config"] = cloudConfigFileName
|
||||||
@@ -1272,6 +1272,10 @@ func getUniqStringList(l []string) []string {
|
|||||||
m := map[string]bool{}
|
m := map[string]bool{}
|
||||||
ul := []string{}
|
ul := []string{}
|
||||||
for _, k := range l {
|
for _, k := range l {
|
||||||
|
k = strings.TrimSpace(k)
|
||||||
|
if k == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, ok := m[k]; !ok {
|
if _, ok := m[k]; !ok {
|
||||||
m[k] = true
|
m[k] = true
|
||||||
ul = append(ul, k)
|
ul = append(ul, k)
|
||||||
|
52
cluster/plan_test.go
Normal file
52
cluster/plan_test.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package cluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_getUniqStringList(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
l []string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"contain strings with only spaces",
|
||||||
|
args{
|
||||||
|
[]string{" ", "key1=value1", " ", "key2=value2"},
|
||||||
|
},
|
||||||
|
[]string{"key1=value1", "key2=value2"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contain strings with trailing or leading spaces",
|
||||||
|
args{
|
||||||
|
[]string{" key1=value1", "key1=value1 ", " key2=value2 "},
|
||||||
|
},
|
||||||
|
[]string{"key1=value1", "key2=value2"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contain duplicated strings",
|
||||||
|
args{
|
||||||
|
[]string{"", "key1=value1", "key1=value1", "key2=value2"},
|
||||||
|
},
|
||||||
|
[]string{"key1=value1", "key2=value2"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contain empty string",
|
||||||
|
args{
|
||||||
|
[]string{"", "key1=value1", "", "key2=value2"},
|
||||||
|
},
|
||||||
|
[]string{"key1=value1", "key2=value2"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
assert.Equalf(t, tt.want, getUniqStringList(tt.args.l), "getUniqStringList(%v)", tt.args.l)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@@ -90,6 +90,25 @@ nodes:
|
|||||||
- address: rke-node-${node}
|
- address: rke-node-${node}
|
||||||
role: [etcd, controlplane, worker]
|
role: [etcd, controlplane, worker]
|
||||||
user: ubuntu
|
user: ubuntu
|
||||||
|
services:
|
||||||
|
etcd:
|
||||||
|
extra_env:
|
||||||
|
- TEST_VAR=etcd
|
||||||
|
kubeproxy:
|
||||||
|
extra_env:
|
||||||
|
- TEST_VAR=kube-proxy
|
||||||
|
scheduler:
|
||||||
|
extra_env:
|
||||||
|
- TEST_VAR=scheduler
|
||||||
|
kubelet:
|
||||||
|
extra_env:
|
||||||
|
- TEST_VAR=kubelet
|
||||||
|
kube-controller:
|
||||||
|
extra_env:
|
||||||
|
- TEST_VAR=kube-controller
|
||||||
|
kube-api:
|
||||||
|
extra_env:
|
||||||
|
- TEST_VAR=kube-api
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ "x${NETWORK_PLUGIN}" != "x" ]; then
|
if [ "x${NETWORK_PLUGIN}" != "x" ]; then
|
||||||
|
Reference in New Issue
Block a user