forked from alibaba/kt-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
42 lines (36 loc) · 932 Bytes
/
types.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
package kt
import (
"github.com/jonyhy96/kt-connect/pkg/kt/cluster"
"github.com/jonyhy96/kt-connect/pkg/kt/connect"
"github.com/jonyhy96/kt-connect/pkg/kt/exec"
"github.com/jonyhy96/kt-connect/pkg/kt/options"
)
// CliInterface ...
type CliInterface interface {
Kubernetes() (cluster.KubernetesInterface, error)
Shadow() connect.ShadowInterface
Exec() exec.CliInterface
}
// Cli ...
type Cli struct {
Options *options.DaemonOptions
}
// Kubernetes ...
func (c *Cli) Kubernetes() (cluster.KubernetesInterface, error) {
if c.Options.RuntimeOptions.Clientset != nil {
return cluster.CreateFromClientSet(c.Options.RuntimeOptions.Clientset)
}
return cluster.Create(c.Options.KubeConfig)
}
// Shadow ...
func (c *Cli) Shadow() connect.ShadowInterface {
return &connect.Shadow{
Options: c.Options,
}
}
// Exec ...
func (c *Cli) Exec() exec.CliInterface {
return &exec.Cli{
KubeOptions: c.Options.KubeOptions,
}
}