本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/unversioned.SecretsInterface.List方法的典型用法代码示例。如果您正苦于以下问题:Golang SecretsInterface.List方法的具体用法?Golang SecretsInterface.List怎么用?Golang SecretsInterface.List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/client/unversioned.SecretsInterface
的用法示例。
在下文中一共展示了SecretsInterface.List方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var ingClient client.IngressInterface
var secretsClient client.SecretsInterface
/* Anon http client
config := client.Config{
Host: "http://localhost:8080",
Username: "admin",
Password: "admin",
}
kubeClient, err := client.New(&config)
*/
kubeClient, err := client.NewInCluster()
if err != nil {
log.Fatalf("Failed to create client: %v.", err)
} else {
ingClient = kubeClient.Extensions().Ingress(api.NamespaceAll)
secretsClient = kubeClient.Secrets(api.NamespaceAll)
}
tmpl := template.New("nginx.tmpl").Funcs(template.FuncMap{"hasprefix": hasPrefix, "hassuffix": hasSuffix})
if _, err := tmpl.ParseFiles("./nginx.tmpl"); err != nil {
log.Fatalf("Failed to parse template %v", err)
}
rateLimiter := util.NewTokenBucketRateLimiter(0.1, 1)
known := &extensions.IngressList{}
known_secrets := &api.SecretList{}
// Controller loop
shellOut("nginx")
for {
rateLimiter.Accept()
ingresses, err := ingClient.List(api.ListOptions{})
if err != nil {
log.Printf("Error retrieving ingresses: %v", err)
continue
}
secrets, err := secretsClient.List(api.ListOptions{})
if err != nil {
log.Printf("Error retrieving secrets: %v", err)
continue
}
if reflect.DeepEqual(ingresses.Items, known.Items) && reflect.DeepEqual(secrets.Items, known_secrets.Items) {
continue
}
// Process SSL context
// old values
known = ingresses
known_secrets = secrets
// context variable
context := &Context{Ingress: ingresses, Secrets: secrets}
if w, err := os.Create("/etc/nginx/nginx.conf"); err != nil {
log.Fatalf("Failed to open %v: %v", err)
} else if err := tmpl.Execute(w, context); err != nil {
log.Fatalf("Failed to write template %v", err)
}
shellOut("nginx -s reload")
}
}