-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
k8s.go
36 lines (28 loc) · 769 Bytes
/
k8s.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package profile
import (
"github.com/guumaster/hostctl/pkg/k8s"
"github.com/guumaster/hostctl/pkg/k8s/minikube"
"github.com/guumaster/hostctl/pkg/types"
)
// NewProfileFromMinikube creates a new profile from a minikube profile and k8s namespace
func NewProfileFromMinikube(mini *minikube.Profile, ns string) (*types.Profile, error) {
if mini.Status != minikube.Running {
return nil, types.ErrMinikubeStatus
}
if !mini.IngressEnabled {
return nil, types.ErrMinikubeIngress
}
cli, err := k8s.NewClientset()
if err != nil {
return nil, err
}
list, err := k8s.GetIngresses(cli, ns)
if err != nil {
return nil, err
}
p := &types.Profile{}
for _, in := range list {
p.AddRoute(types.NewRoute(in.IP.String(), in.Hostname))
}
return p, nil
}