-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
64 lines (53 loc) · 1.61 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"log"
"os"
harvesterv1beta1 "github.com/harvester/harvester/pkg/apis/harvesterhci.io/v1beta1"
"github.com/rancher/wrangler/pkg/signals"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/clientcmd"
kubevirtv1 "kubevirt.io/api/core/v1"
source "github.com/harvester/vm-import-controller/pkg/apis/migration.harvesterhci.io/v1beta1"
"github.com/harvester/vm-import-controller/pkg/controllers"
"github.com/harvester/vm-import-controller/pkg/server"
)
func init() {
var err error
scheme := runtime.NewScheme()
if err = source.AddToScheme(scheme); err != nil {
log.Fatalf("failed to add source scheme, %v", err)
}
if err = harvesterv1beta1.AddToScheme(scheme); err != nil {
log.Fatalf("failed to add harvesterv1beta1 scheme, %v", err)
}
if err = kubevirtv1.AddToScheme(scheme); err != nil {
log.Fatalf("failed to add kubevirtv1 scheme, %v", err)
}
debug := os.Getenv("DEBUG")
if debug == "true" || debug == "TRUE" {
logrus.SetLevel(logrus.DebugLevel)
}
}
func main() {
ctx := signals.SetupSignalContext()
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
configOverrides := &clientcmd.ConfigOverrides{}
kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
config, err := kubeConfig.ClientConfig()
if err != nil {
log.Fatal(err)
}
eg, egctx := errgroup.WithContext(ctx)
eg.Go(func() error {
return controllers.Start(egctx, config)
})
eg.Go(func() error {
return server.NewServer(egctx)
})
err = eg.Wait()
if err != nil {
log.Fatal(err)
}
}