mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Support setting env vars in kubectl run
This commit is contained in:
@@ -17,10 +17,12 @@ limitations under the License.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
)
|
||||
|
||||
func TestGetRestartPolicy(t *testing.T) {
|
||||
@@ -78,3 +80,20 @@ func TestGetRestartPolicy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetEnv(t *testing.T) {
|
||||
test := struct {
|
||||
input []string
|
||||
expected []string
|
||||
}{
|
||||
input: []string{"a=b", "c=d"},
|
||||
expected: []string{"a=b", "c=d"},
|
||||
}
|
||||
cmd := &cobra.Command{}
|
||||
cmd.Flags().StringSlice("env", test.input, "")
|
||||
|
||||
envStrings := cmdutil.GetFlagStringSlice(cmd, "env")
|
||||
if len(envStrings) != 2 || !reflect.DeepEqual(envStrings, test.expected) {
|
||||
t.Errorf("expected: %s, saw: %s", test.expected, envStrings)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user