-
Notifications
You must be signed in to change notification settings - Fork 219
/
main.go
50 lines (42 loc) · 1.26 KB
/
main.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
package main
import (
"log"
"net/http"
_ "net/http/pprof"
"github.com/rancher/fleet/pkg/agent"
"github.com/rancher/fleet/pkg/fleetcontroller"
"github.com/rancher/fleet/pkg/version"
command "github.com/rancher/wrangler-cli"
_ "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
_ "github.com/rancher/wrangler/pkg/generated/controllers/networking.k8s.io"
"github.com/spf13/cobra"
)
var (
debugConfig command.DebugConfig
)
type FleetManager struct {
Kubeconfig string `usage:"Kubeconfig file"`
Namespace string `usage:"namespace to watch" default:"fleet-system" env:"NAMESPACE"`
DisableGitops bool `usage:"disable gitops components" name:"disable-gitops"`
}
func (f *FleetManager) Run(cmd *cobra.Command, args []string) error {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
debugConfig.MustSetupDebug()
if err := fleetcontroller.Start(cmd.Context(), f.Namespace, f.Kubeconfig, f.DisableGitops); err != nil {
return err
}
if debugConfig.Debug {
agent.DebugLevel = debugConfig.DebugLevel
}
<-cmd.Context().Done()
return nil
}
func main() {
cmd := command.Command(&FleetManager{}, cobra.Command{
Version: version.FriendlyVersion(),
})
cmd = command.AddDebug(cmd, &debugConfig)
command.Main(cmd)
}