Files
kubernetes/test/images/agnhost/utils_windows.go
Claudiu Belu 625a9d98a8 tests: Adds agnhost image
The new image is meant to be used for testing purposes, whenever there
are significant differences between Linux and Windows in the way
something is obtained or tested. For example, the DNS suffix list can
be found in ``/etc/resolv.conf`` on Linux, but on Windows, such file
does not exist, and one way to obtain the mentioned list would be
through some powershell commands.

The image contains an extendable CLI as the entrypoint, the tests
only having to add the necessary arguments. For the previous example,
passing the ``dns-suffix`` argument will print out the comma separated
DNS suffix list, on both Linux and Windows.

The image name means that it should behave the same way on any host,
no matter the host OS.
2019-03-30 06:04:56 -07:00

42 lines
995 B
Go

/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"bytes"
"os/exec"
"strings"
)
func getDNSSuffixList() []string {
var out bytes.Buffer
cmd := exec.Command("powershell", "-Command", "(Get-DnsClient)[0].SuffixSearchList")
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
panic(err)
}
output := strings.TrimSpace(out.String())
if len(output) > 0 {
return strings.Split(output, "\r\n")
}
panic("Could not find DNS search list!")
}