本文整理汇总了Golang中github.com/openshift/origin/test/extended/util.CLI类的典型用法代码示例。如果您正苦于以下问题:Golang CLI类的具体用法?Golang CLI怎么用?Golang CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: assertEnvVars
func assertEnvVars(oc *exutil.CLI, buildPrefix string, varsToFind map[string]string) {
buildList, err := oc.REST().Builds(oc.Namespace()).List(kapi.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
// Ensure that expected start-build environment variables were injected
for _, build := range buildList.Items {
ginkgolog("Found build: %q", build.GetName())
if strings.HasPrefix(build.GetName(), buildPrefix) {
envs := []kapi.EnvVar{}
if build.Spec.Strategy.DockerStrategy != nil && build.Spec.Strategy.DockerStrategy.Env != nil {
envs = build.Spec.Strategy.DockerStrategy.Env
} else if build.Spec.Strategy.SourceStrategy != nil && build.Spec.Strategy.SourceStrategy.Env != nil {
envs = build.Spec.Strategy.SourceStrategy.Env
} else {
continue
}
for k, v := range varsToFind {
found := false
for _, env := range envs {
ginkgolog("Found %s=%s in build %s", env.Name, env.Value, build.GetName())
if k == env.Name && v == env.Value {
found = true
break
}
}
o.ExpectWithOffset(1, found).To(o.BeTrue())
}
}
}
}
示例2: buildAndPushTestImagesTo
// buildAndPushTestImagesTo builds a given number of test images. The images are pushed to a new image stream
// of given name under <tagPrefix><X> where X is a number of image starting from 1.
func buildAndPushTestImagesTo(oc *exutil.CLI, isName string, tagPrefix string, numberOfImages int) (tag2Image map[string]imageapi.Image, err error) {
dClient, err := testutil.NewDockerClient()
if err != nil {
return
}
tag2Image = make(map[string]imageapi.Image)
for i := 1; i <= numberOfImages; i++ {
tag := fmt.Sprintf("%s%d", tagPrefix, i)
dgst, err := imagesutil.BuildAndPushImageOfSizeWithDocker(oc, dClient, isName, tag, imageSize, 2, g.GinkgoWriter, true)
if err != nil {
return nil, err
}
ist, err := oc.Client().ImageStreamTags(oc.Namespace()).Get(isName, tag)
if err != nil {
return nil, err
}
if dgst != ist.Image.Name {
return nil, fmt.Errorf("digest of built image does not match stored: %s != %s", dgst, ist.Image.Name)
}
tag2Image[tag] = ist.Image
}
return
}
示例3: doTest
func doTest(bldPrefix, debugStr string, same bool, oc *exutil.CLI) {
// corrupt the builder image
exutil.CorruptImage(fullImageName, corruptor)
if bldPrefix == buildPrefixFC || bldPrefix == buildPrefixTC {
// grant access to the custom build strategy
err := oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
defer func() {
err = oc.AsAdmin().Run("adm").Args("policy", "remove-cluster-role-from-user", "system:build-strategy-custom", oc.Username()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
}()
}
// kick off the app/lang build and verify the builder image accordingly
_, err := exutil.StartBuildAndWait(oc, bldPrefix)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
if same {
exutil.VerifyImagesSame(fullImageName, corruptor, debugStr)
} else {
exutil.VerifyImagesDifferent(fullImageName, corruptor, debugStr)
}
// reset corrupted tagging for next test
exutil.ResetImage(resetData)
// dump tags/hexids for debug
_, err = exutil.DumpAndReturnTagging(tags)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
}
示例4: createFixture
func createFixture(oc *exutil.CLI, path string) ([]string, []string, error) {
output, err := oc.Run("create").Args("-f", path, "-o", "name").Output()
if err != nil {
return nil, nil, err
}
lines := strings.Split(output, "\n")
resources := make([]string, 0, len(lines)-1)
names := make([]string, 0, len(lines)-1)
for _, line := range lines {
if line == "" {
continue
}
parts := strings.Split(line, "/")
if len(parts) != 2 {
return nil, nil, fmt.Errorf("expected type/name syntax, got: %q", line)
}
resources = append(resources, parts[0])
names = append(names, parts[1])
}
return resources, names, nil
}
示例5: tearDownPruneImagesTest
func tearDownPruneImagesTest(oc *exutil.CLI, cleanUp *cleanUpContainer) {
for _, image := range cleanUp.imageNames {
err := oc.AsAdmin().Client().Images().Delete(image)
if err != nil {
fmt.Fprintf(g.GinkgoWriter, "clean up of image %q failed: %v\n", image, err)
}
}
}
示例6: waitForLimitSync
// waitForLimitSync waits until a usage of a quota reaches given limit with a short timeout
func waitForLimitSync(oc *exutil.CLI, hardLimit kapi.ResourceList) error {
g.By(fmt.Sprintf("waiting for resource quota %s to get updated", quotaName))
return testutil.WaitForResourceQuotaLimitSync(
oc.KubeClient().Core().ResourceQuotas(oc.Namespace()),
quotaName,
hardLimit,
waitTimeout)
}
示例7: waitForImageUpdate
func waitForImageUpdate(oc *exutil.CLI, image *imageapi.Image) error {
return wait.Poll(200*time.Millisecond, 2*time.Minute, func() (bool, error) {
newImage, err := oc.AsAdmin().Client().Images().Get(image.Name)
if err != nil {
return false, err
}
return (image.ResourceVersion < newImage.ResourceVersion), nil
})
}
示例8: FindJenkinsPod
// Finds the pod running Jenkins
func FindJenkinsPod(oc *exutil.CLI) *kapi.Pod {
pods, err := exutil.GetDeploymentConfigPods(oc, "jenkins")
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
if pods == nil || pods.Items == nil {
g.Fail("No pods matching jenkins deploymentconfig in namespace " + oc.Namespace())
}
o.ExpectWithOffset(1, len(pods.Items)).To(o.Equal(1))
return &pods.Items[0]
}
示例9: waitForNoPodsAvailable
func waitForNoPodsAvailable(oc *exutil.CLI) error {
return wait.Poll(200*time.Millisecond, 2*time.Minute, func() (bool, error) {
//ep, err := oc.KubeClient().Core().Endpoints(oc.Namespace()).Get(serviceName)
pods, err := oc.KubeClient().Core().Pods(oc.Namespace()).List(kapi.ListOptions{})
if err != nil {
return false, err
}
return len(pods.Items) == 0, nil
})
}
示例10: waitForEndpointsAvailable
func waitForEndpointsAvailable(oc *exutil.CLI, serviceName string) error {
return wait.Poll(200*time.Millisecond, 2*time.Minute, func() (bool, error) {
ep, err := oc.KubeClient().Core().Endpoints(oc.Namespace()).Get(serviceName)
// Tolerate NotFound b/c it could take a moment for the endpoints to be created
if errors.TolerateNotFoundError(err) != nil {
return false, err
}
return (len(ep.Subsets) > 0) && (len(ep.Subsets[0].Addresses) > 0), nil
})
}
示例11: GetDockerRegistryURL
// GetDockerRegistryURL returns a cluster URL of internal docker registry if available.
func GetDockerRegistryURL(oc *exutil.CLI) (string, error) {
svc, err := oc.AdminKubeREST().Services("default").Get("docker-registry")
if err != nil {
return "", err
}
url := svc.Spec.ClusterIP
for _, p := range svc.Spec.Ports {
url = fmt.Sprintf("%s:%d", url, p.Port)
break
}
return url, nil
}
示例12: getAdminPassword
func getAdminPassword(oc *exutil.CLI) string {
envs, err := oc.Run("set").Args("env", "dc/jenkins", "--list").Output()
o.Expect(err).NotTo(o.HaveOccurred())
kvs := strings.Split(envs, "\n")
for _, kv := range kvs {
if strings.HasPrefix(kv, "JENKINS_PASSWORD=") {
s := strings.Split(kv, "=")
fmt.Fprintf(g.GinkgoWriter, "\nJenkins admin password %s\n", s[1])
return s[1]
}
}
return "password"
}
示例13: QueryPrivileged
// QueryPrivileged executes an SQL query as a root user and returns the result.
func (m MySQL) QueryPrivileged(oc *util.CLI, query string) (string, error) {
container, err := firstContainerName(oc.KubeREST().Pods(oc.Namespace()), m.podName)
if err != nil {
return "", err
}
masterConf, err := getPodConfig(oc.KubeREST().Pods(oc.Namespace()), m.masterPodName)
if err != nil {
return "", err
}
return oc.Run("exec").Args(m.podName, "-c", container, "--", "bash", "-c",
fmt.Sprintf("mysql -h 127.0.0.1 -uroot -e \"%s\" %s",
query, masterConf.Env["MYSQL_DATABASE"])).Output()
}
示例14: executeShellCommand
func executeShellCommand(oc *util.CLI, podName string, command string) (string, error) {
out, err := oc.Run("exec").Args(podName, "--", "bash", "-c", command).Output()
if err != nil {
switch err.(type) {
case *util.ExitError, *exec.ExitError:
return "", nil
default:
return "", err
}
}
return out, nil
}
示例15: waitForResourceQuotaSync
// waitForResourceQuotaSync waits until a usage of a quota reaches given limit with a short timeout
func waitForResourceQuotaSync(oc *exutil.CLI, name string, expectedResources kapi.ResourceList) (kapi.ResourceList, error) {
g.By(fmt.Sprintf("waiting for resource quota %s to get updated", name))
used, err := exutil.WaitForResourceQuotaSync(
oc.KubeClient().Core().ResourceQuotas(oc.Namespace()),
quotaName,
expectedResources,
false,
waitTimeout,
)
if err != nil {
return nil, err
}
return used, nil
}