update deployment

This commit is contained in:
matst80
2024-11-09 13:07:49 +01:00
parent a03f7d9f1d
commit 82516b6814
7 changed files with 249 additions and 3 deletions

27
k8s-discovery_test.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"testing"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
func TestDiscovery(t *testing.T) {
config, err := clientcmd.BuildConfigFromFlags("", "/Users/mats/.kube/config")
if err != nil {
t.Errorf("Error building config: %v", err)
}
client, err := kubernetes.NewForConfig(config)
if err != nil {
t.Errorf("Error creating client: %v", err)
}
d := NewK8sDiscovery(client)
res, err := d.DiscoverInNamespace("cart")
if err != nil {
t.Errorf("Error discovering: %v", err)
}
if len(res) == 0 {
t.Errorf("Expected at least one host, got none")
}
}