本文整理匯總了Golang中github.com/openshift/origin/test/extended/util.CLI.SetNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Golang CLI.SetNamespace方法的具體用法?Golang CLI.SetNamespace怎麽用?Golang CLI.SetNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/openshift/origin/test/extended/util.CLI
的用法示例。
在下文中一共展示了CLI.SetNamespace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ensureRegistryAcceptsSchema2
// ensureRegistryAcceptsSchema2 checks whether the registry is configured to accept manifests V2 schema 2 or
// not. If the result doesn't match given accept argument, registry's deployment config is updated accordingly
// and the function blocks until the registry is re-deployed and ready for new requests.
func ensureRegistryAcceptsSchema2(oc *exutil.CLI, accept bool) error {
ns := oc.Namespace()
oc = oc.SetNamespace(kapi.NamespaceDefault).AsAdmin()
defer oc.SetNamespace(ns)
env, err := oc.Run("env").Args("dc/docker-registry", "--list").Output()
if err != nil {
return err
}
value := fmt.Sprintf("%s=%t", dockerregistryserver.AcceptSchema2EnvVar, accept)
if strings.Contains(env, value) {
if accept {
g.By("docker-registry is already configured to accept schema 2")
} else {
g.By("docker-registry is already configured to refuse schema 2")
}
return nil
}
dc, err := oc.Client().DeploymentConfigs(kapi.NamespaceDefault).Get("docker-registry")
if err != nil {
return err
}
waitForVersion := dc.Status.LatestVersion + 1
g.By("configuring Docker registry to accept schema 2")
err = oc.Run("env").Args("dc/docker-registry", value).Execute()
if err != nil {
return fmt.Errorf("failed to update registry's environment with %s: %v", &waitForVersion, err)
}
return exutil.WaitForRegistry(oc.AdminClient(), oc.AdminKubeClient(), &waitForVersion, oc)
}
示例2: doesRegistryAcceptSchema2
func doesRegistryAcceptSchema2(oc *exutil.CLI) (bool, error) {
ns := oc.Namespace()
defer oc.SetNamespace(ns)
env, err := oc.SetNamespace(kapi.NamespaceDefault).AsAdmin().Run("env").Args("dc/docker-registry", "--list").Output()
if err != nil {
return false, err
}
return strings.Contains(env, fmt.Sprintf("%s=true", dockerregistryserver.AcceptSchema2EnvVar)), nil
}
示例3: getRegistryStorageSize
func getRegistryStorageSize(oc *exutil.CLI) (int64, error) {
ns := oc.Namespace()
defer oc.SetNamespace(ns)
out, err := oc.SetNamespace(kapi.NamespaceDefault).AsAdmin().Run("rsh").Args("dc/docker-registry", "du", "--bytes", "--summarize", "/registry/docker/registry").Output()
if err != nil {
return 0, err
}
m := regexp.MustCompile(`^\d+`).FindString(out)
if len(m) == 0 {
return 0, fmt.Errorf("failed to parse du output: %s", out)
}
size, err := strconv.ParseInt(m, 10, 64)
if err != nil {
return 0, fmt.Errorf("failed to parse du output: %s", m)
}
return size, nil
}
示例4: followDCLogs
func followDCLogs(oc *exutil.CLI, jenkinsNamespace string) {
oc.SetNamespace(jenkinsNamespace)
oc.Run("logs").Args("-f", "dc/jenkins").Execute()
}