forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh-ingress.go
39 lines (34 loc) · 1.15 KB
/
mesh-ingress.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
37
38
39
package surveyutils
import (
"context"
skclients "github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
"github.com/solo-io/supergloo/cli/pkg/helpers/clients"
)
func SurveyMeshIngresses(ctx context.Context) ([]*core.ResourceRef, error) {
// collect Meshes list
meshIngressClient := clients.MustMeshIngressClient()
meshIngresses, err := meshIngressClient.List("", skclients.ListOpts{Ctx: ctx})
if err != nil {
return nil, err
}
var selected []*core.ResourceRef
for {
meshIngress, err := surveyResources("meshingresses", "add a mesh ingress (choose <done> to finish): ", "<done>", meshIngresses.AsResources())
if err != nil {
return nil, err
}
// the user chose
if meshIngress.Namespace == "" {
return selected, nil
}
selected = append(selected, &meshIngress)
}
}
func SurveyMeshIngress(ctx context.Context) (core.ResourceRef, error) {
meshIngresses, err := clients.MustMeshIngressClient().List("", skclients.ListOpts{Ctx: ctx})
if err != nil {
return core.ResourceRef{}, err
}
return surveyResources("meshingresses", "select a mesh ingress: ", "", meshIngresses.AsResources())
}