-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (51 loc) · 1.63 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
package main
import (
parser "finops-composition-definition-parser/internal/helpers/configuration"
kubeHelper "finops-composition-definition-parser/internal/helpers/kube/client"
"finops-composition-definition-parser/internal/webservice"
"os"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"k8s.io/client-go/rest"
)
func main() {
configuration, err := parser.ParseConfig()
if err != nil {
configuration.Default()
}
// Logger configuration
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
zerolog.SetGlobalLevel(configuration.DebugLevel)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
if err != nil {
log.Error().Err(err).Msg("configuration missing")
log.Info().Msg("using default configuration for webservice")
}
log.Debug().Msg("List of environment variables:")
for _, s := range os.Environ() {
log.Debug().Msg(s)
}
kubeHelper.PLURALIZER_URL = configuration.PluralizerUrl
// Kubernetes configuration
rcConfig, err := rest.InClusterConfig()
if err != nil {
log.Error().Err(err).Msg("resolving kubeconfig for rest client")
return
}
dynClient, err := kubeHelper.NewDynamicClient(rcConfig)
if err != nil {
log.Error().Err(err).Msg("obtaining dynamic client for kubernetes")
return
}
// // Start webservice to serve endpoints
w := webservice.Webservice{
Config: rcConfig,
WebservicePort: configuration.WebServicePort,
AnnotationLabel: configuration.AnnotationLabel,
AnnotationTable: configuration.AnnotationTable,
DynClient: dynClient,
NotebookUrl: configuration.WebserviceUrl,
DatabaseConfig: configuration.DatabaseConfig,
}
w.Spinup() // blocks main thread
}