- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在 openshift/client-go 的帮助下列出 openshift 中的所有构建配置
import (
"context"
"flag"
"fmt"
"os"
"path/filepath"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"
buildv1 "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1"
)
func main() {
err := start()
if err != nil {
fmt.Fprintf(os.Stderr, "error: %v", err)
os.Exit(1)
}
}
func start() error {
var kubeconfig *string
if home := homeDir(); home != "" {
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
} else {
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
}
flag.Parse()
// use the current context in kubeconfig
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
if err != nil {
return err
}
buildV1Client, err := buildv1.NewForConfig(config)
if err != nil {
return err
}
namespace := "testproject"
// get all builds
builds, err := buildV1Client.Builds(namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return err
}
fmt.Printf("There are %d builds in project %s\n", len(builds.Items), namespace)
// List names of all builds
for i, build := range builds.Items {
fmt.Printf("index %d: Name of the build: %s", i, build.Name)
}
return nil
}
func homeDir() string {
if h := os.Getenv("HOME"); h != "" {
return h
}
return os.Getenv("USERPROFILE") // windows
}
我已经通过 glide 获得了所有依赖项。 glide.yaml glide update -v
package: .
import:
- package: github.com/openshift/client-go
subpackages:
- build/clientset/versioned/typed/build/v1
- package: k8s.io/apimachinery
subpackages:
- pkg/apis/meta/v1
- package: k8s.io/client-go
subpackages:
- tools/clientcmd
我看到我的所有软件包都是 vendor 的一部分。但我无法将类型更改为 vendor 配置。
go run main.go
# command-line-arguments
./main.go:39:44: cannot use config (type *"k8s.io/client-go/rest".Config) as type *"github.com/openshift/client-go/vendor/k8s.io/client-go/rest".Config in argument to "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1".NewForConfig
./main.go:46:88: cannot use "k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions literal (type "k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions) as type "github.com/openshift/client-go/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ListOptions in argument to buildV1Client.Builds(namespace).List
我已经删除了当前目录中的 vendor 目录,并确保 gopath 具有所有必需的依赖项作为替代尝试,但这不起作用。我还尝试链接 ~/go/src/github.com/openshift/client-go/vendor/* vendor ,但这似乎不起作用。
我也尝试了解决方案List Openshift objects via Go client API 。这不起作用。
最佳答案
滑动有点outdated截至撰写本文时。它的最后一次发布是 2019 年 7 月 10 日。
自版本 1.11
起,Golang 提出了名为 go modules 的 native 包管理。这已成为管理依赖关系的更优选方式。这就是管理您的 vendor
目录的内容,也是 github.com/openshift/client-go
使用的内容。我还假设您从 this main.go
file 开始.
因为 github.com/openshift/client-go
下的所有内容都已管理依赖项。我推荐🎬:
go get github.com/openshift/client-go
cd $GOPATH/src/github.com/mygihubusername/myrepo
cp -R ../../openshift/client-go/* .
# put main.go here with your code or any of the subdirectories
# cd subdir 👈 if you put the main.go file under a subdir.
go build -o buildclient .
# clean up any files you don't need
# create github repo
git add *
git commit -m 'My first commit'
git push origin master
对我有用。 ✌️
关于go - 使用 Openshift/Client-go 进行 Openshift API 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62998245/
我是 devops 的新手,并且正在阅读有关此的 openshift 文档。似乎 buildconfig 和 pipeline(openshift 4.6 中的 tekton)都可以实现 source
我正在寻找 OpenShift Origin 和 OpenShift Enterprise 之间的主要区别。我知道第一个是开源的,后者是商业版。与开源版本相比,OpenShift Enterprise
在 Openshift 上部署应用程序后,收集应用程序的 1) CPU、2) 网络、3) 内存、4) 磁盘存储使用情况的推荐方法/最佳实践是什么?基本上是为了监控应用程序。 如果它们能够以时间序列格式
几天来,我一直在尝试通过 Openshift 连接到我的应用程序,但仍然没有运气。 我现在不确定该去哪个论坛,因为我在任何地方都没有得到帮助。 1) 我通过终端运行sudo rhc setup (我之
Spinnaker 是否可以作为云提供商在 Red Hat 的 Openshift 上运行和部署应用程序? 如果没有,需要什么才能使之成为现实? 谢谢。 最佳答案 首先,您需要为 Openshift
我目前正在使用 Red Had 提供的免费培训来学习 Openshift 作为开发人员和管理员。你知道我可以用来获得“刺激”经验的任何其他地方吗?提前致谢。 :) 最佳答案 红帽提供的免费培训是一个良
我在 openshift 中创建应用程序时不小心选择了大齿轮。有没有办法在不重新创建我的应用程序的情况下降级齿轮类型?比如从大到中,甚至从大到小。highcpu。 提前谢谢各位 最佳答案 您确实必须重
我创建了一个 Web 应用程序,我想在 Openshift 上进行部署。 最简单的方法是什么?我正在使用 Openshift Eclipse 客户端。 我应该创建一个新的 openshift,然后从我
我想在 Openshift 中定义一条具有多条路径的路由,每条路径转发到不同的服务。例如/pathA 会将请求转发到 ServiceA ,而/pathB 会将请求转发到 ServiceB。 这在 Op
我想创建一个构建器图像 app_name:latest这将采用多个源输入,例如,另一个图像和二进制源,然后将输出创建到 app_name:latest . 示例 - { "kind": "Bu
我有一个 openshift 应用程序,我在本地彻底重新设计了该应用程序,并希望在 openshift 服务器上重新开始。 我可以删除所有齿轮并重做它们,但是有没有一种优雅的方法或任何方法可以将 op
大约一周以来,它说: Queued for provisioning Due to an increase in OpenShift Online Starter popularity, please
我希望我的部署配置使用作为构建配置输出的镜像。 我目前正在使用这样的东西: - apiVersion: v1 kind: DeploymentConfig metadata: anno
与 OpenShift Container Platform(以前的 Enterprise)相比,OpenShift Origin 是否有任何强制限制?我的意思是,像 Origin 这样的东西,你最多
一个 openshift 应用程序可以有多个域吗? Heroku 允许这样做。完全不同的域(app.abc.com、app.xyz.com)或子域(*.abc.com、*.xyz.com)。 open
我想开发一种新的墨盒供我自己使用。我使用 OpenShift Cartridge Development Kit 开始我的工作。我的构建脚本写在.openshift/action_hooks/buil
我正在使用 flask 。我安装了 Flask-migrate 并一直在使用它来迁移我的 postgresql 数据库。它在我的本地盒子上工作正常。但是,当我在 openshift 上运行它时出现错误
当我尝试在打开的类次项目中推送一些更改时,我在尝试构建项目时遇到了这个错误: remote: Found pom.xml... attempting to build with 'mvn --glob
在不可扩展的奇异齿轮中,齿轮空闲多长时间没有流量。我看过 https://access.redhat.com/site/documentation/en-US/OpenShift_Online/2.0
我试图在 OpenShift 中更新图像时触发部署。该图像托管在私有(private)外部 docker 注册表中。我创建了一个 ImageStream映射到这个外部图像。当我将新图像推送到注册表时,
我是一名优秀的程序员,十分优秀!