You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
694 B
42 lines
694 B
package kubernetes
|
|
|
|
import (
|
|
"log"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/go-kratos/kratos/v2/config"
|
|
"k8s.io/client-go/util/homedir"
|
|
)
|
|
|
|
func TestSource(t *testing.T) {
|
|
home := homedir.HomeDir()
|
|
s := NewSource(
|
|
Namespace("mesh"),
|
|
LabelSelector(""),
|
|
KubeConfig(filepath.Join(home, ".kube", "config")),
|
|
)
|
|
kvs, err := s.Load()
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
for _, v := range kvs {
|
|
t.Log(v)
|
|
}
|
|
}
|
|
|
|
func ExampleNewSource() {
|
|
conf := config.New(
|
|
config.WithSource(
|
|
NewSource(
|
|
Namespace("mesh"),
|
|
LabelSelector("app=test"),
|
|
KubeConfig(filepath.Join(homedir.HomeDir(), ".kube", "config")),
|
|
),
|
|
),
|
|
)
|
|
err := conf.Load()
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
}
|
|
|