/
skupper_kube.go
111 lines (95 loc) · 2.92 KB
/
skupper_kube.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"fmt"
"github.com/skupperproject/skupper/api/types"
"github.com/spf13/cobra"
)
var SkupperKubeCommands = []string{
"init", "delete", "update", "connection-token", "token", "link", "connect", "disconnect",
"check-connection", "status", "list-connectors", "expose", "unexpose", "list-exposed",
"service", "bind", "unbind", "version", "debug", "completion", "gateway", "revoke-access",
"network", "switch",
}
type SkupperKube struct {
Cli types.VanClientInterface
KubeContext string
Namespace string
KubeConfigPath string
site *SkupperKubeSite
service *SkupperKubeService
debug *SkupperKubeDebug
link *SkupperKubeLink
token *SkupperKubeToken
network *SkupperKubeNetwork
common SkupperClientCommon
}
func (s *SkupperKube) Site() SkupperSiteClient {
if s.site == nil {
s.site = &SkupperKubeSite{kube: s}
}
return s.site
}
func (s *SkupperKube) Service() SkupperServiceClient {
if s.service == nil {
s.service = &SkupperKubeService{kube: s}
}
return s.service
}
func (s *SkupperKube) Debug() SkupperDebugClient {
if s.debug == nil {
s.debug = &SkupperKubeDebug{kube: s}
}
return s.debug
}
func (s *SkupperKube) Link() SkupperLinkClient {
if s.link == nil {
s.link = &SkupperKubeLink{kube: s}
}
return s.link
}
func (s *SkupperKube) Token() SkupperTokenClient {
if s.token == nil {
s.token = &SkupperKubeToken{kube: s}
}
return s.token
}
func (s *SkupperKube) Network() SkupperNetworkClient {
if s.network == nil {
s.network = &SkupperKubeNetwork{kube: s}
}
return s.network
}
func (s *SkupperKube) SupportedCommands() []string {
return SkupperKubeCommands
}
func (s *SkupperKube) Platform() types.Platform {
return types.PlatformKubernetes
}
func (s *SkupperKube) Options(rootCmd *cobra.Command) {
rootCmd.PersistentFlags().StringVarP(&s.KubeConfigPath, "kubeconfig", "", "", "Path to the kubeconfig file to use")
rootCmd.PersistentFlags().StringVarP(&s.KubeContext, "context", "c", "", "The kubeconfig context to use")
rootCmd.PersistentFlags().StringVarP(&s.Namespace, "namespace", "n", "", "The Kubernetes namespace to use")
}
type kubeInit struct {
annotations []string
ingressAnnotations []string
routerServiceAnnotations []string
routerPodAnnotations []string
controllerServiceAnnotations []string
controllerPodAnnotations []string
prometheusServerPodAnnotations []string
}
func (s *SkupperKube) NewClient(cmd *cobra.Command, args []string) {
if s.common != nil {
s.common.NewClient(cmd, args)
return
}
exitOnError := true
if cmd.Name() == "version" {
exitOnError = false
}
s.Cli = NewClientHandleError(s.Namespace, s.KubeContext, s.KubeConfigPath, exitOnError)
}
func targetTypeServiceTargetNamespaceError() error {
return fmt.Errorf("--target-namespace cannot be used when target type is service (qualify the target service name instead)")
}