本文整理汇总了Golang中github.com/openshift/origin/test/extended/util.CLI类的典型用法代码示例。如果您正苦于以下问题:Golang CLI类的具体用法?Golang CLI怎么用?Golang CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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())
}
}
}
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:32,代码来源:plugin.go
示例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
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:27,代码来源:limitrange_admission.go
示例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())
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:30,代码来源:forcepull.go
示例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
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:25,代码来源:idling.go
示例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)
}
}
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:8,代码来源:prune.go
示例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)
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:9,代码来源:quota_admission.go
示例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
})
}
开发者ID:xgwang-zte,项目名称:origin,代码行数:10,代码来源:registry.go
示例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]
}
开发者ID:xgwang-zte,项目名称:origin,代码行数:12,代码来源:ref.go
示例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
})
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:11,代码来源:util.go
示例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
})
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:11,代码来源:util.go
示例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
}
开发者ID:Xmagicer,项目名称:origin,代码行数:13,代码来源:helper.go
示例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"
}
开发者ID:screeley44,项目名称:origin,代码行数:13,代码来源:plugin.go
示例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()
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:14,代码来源:mysql.go
示例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
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:13,代码来源:common.go
示例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
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:15,代码来源:quota_admission.go
示例16: bumpLimit
// bumpLimit changes the limit value for given resource for all the limit types of limit range object
func bumpLimit(oc *exutil.CLI, resourceName kapi.ResourceName, limit string) (kapi.ResourceList, error) {
g.By(fmt.Sprintf("bump a limit on resource %q to %s", resourceName, limit))
lr, err := oc.AdminKubeClient().Core().LimitRanges(oc.Namespace()).Get(limitRangeName)
if err != nil {
return nil, err
}
res := kapi.ResourceList{}
change := false
for i := range lr.Spec.Limits {
item := &lr.Spec.Limits[i]
if old, exists := item.Max[resourceName]; exists {
for k, v := range item.Max {
res[k] = v
}
parsed := resource.MustParse(limit)
if old.Cmp(parsed) != 0 {
item.Max[resourceName] = parsed
change = true
}
}
}
if !change {
return res, nil
}
_, err = oc.AdminKubeClient().Core().LimitRanges(oc.Namespace()).Update(lr)
return res, err
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:30,代码来源:limitrange_admission.go
示例17: QueryPrivileged
// QueryPrivileged executes an SQL query as a root user and returns the result.
func (m PostgreSQL) QueryPrivileged(oc *util.CLI, query string) (string, error) {
container, err := firstContainerName(oc.KubeClient().Core().Pods(oc.Namespace()), m.podName)
if err != nil {
return "", err
}
masterConf, err := getPodConfig(oc.KubeClient().Core().Pods(oc.Namespace()), m.masterPodName)
if err != nil {
return "", err
}
return oc.Run("exec").Args(m.podName, "-c", container, "--", "bash", "-c",
fmt.Sprintf("psql postgres://postgres:%[email protected]/%s -x -c \"%s\"",
masterConf.Env["POSTGRESQL_ADMIN_PASSWORD"],
masterConf.Env["POSTGRESQL_DATABASE"], query)).Output()
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:15,代码来源:postgresql.go
示例18: ModifySourceCode
// ModifySourceCode will modify source code in the pod of the application
// according to the sed script.
func ModifySourceCode(oc *exutil.CLI, selector labels.Selector, sedScript, file string) error {
pods, err := exutil.WaitForPods(oc.KubeREST().Pods(oc.Namespace()), selector, exutil.CheckPodIsRunningFunc, 1, 120*time.Second)
if err != nil {
return err
}
if len(pods) != 1 {
return fmt.Errorf("Got %d pods for selector %v, expected 1", len(pods), selector)
}
pod, err := oc.KubeREST().Pods(oc.Namespace()).Get(pods[0])
if err != nil {
return err
}
return oc.Run("exec").Args(pod.Name, "-c", pod.Spec.Containers[0].Name, "--", "sed", "-ie", sedScript, file).Execute()
}
开发者ID:KrestenKjaer,项目名称:origin,代码行数:17,代码来源:helper.go
示例19: TestRemoteLogin
// TestRemoteLogin will test whether we can login through to a remote database.
func (m MySQL) TestRemoteLogin(oc *util.CLI, hostAddress 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
}
err = oc.Run("exec").Args(m.podName, "-c", container, "--", "bash", "-c",
fmt.Sprintf("mysql -h %s -u%s -p%s -e \"SELECT 1;\" %s",
hostAddress, masterConf.Env["MYSQL_USER"], masterConf.Env["MYSQL_PASSWORD"],
masterConf.Env["MYSQL_DATABASE"])).Execute()
return err
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:16,代码来源:mysql.go
示例20: waitForNumberOfPodsWithLabel
func waitForNumberOfPodsWithLabel(oc *exutil.CLI, number int, label string) []string {
g.By(fmt.Sprintf("expecting that there are %d running pods with label name=%s", number, label))
podNames, err := exutil.WaitForPods(
oc.KubeClient().Core().Pods(oc.Namespace()),
exutil.ParseLabelsOrDie("name="+label),
exutil.CheckPodIsRunningFn,
number,
1*time.Minute,
)
o.Expect(err).ShouldNot(o.HaveOccurred())
o.Expect(podNames).Should(o.HaveLen(number))
return podNames
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:15,代码来源:mongodb_replica.go
注:本文中的github.com/openshift/origin/test/extended/util.CLI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论