MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / main

Function main

app/controlplane/cmd/main.go:84–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82}
83
84func main() {
85 flag.Parse()
86 c := config.New(
87 config.WithSource(
88 file.NewSource(flagconf),
89 // Load environments variables prefixed with CP_
90 // NOTE: They get resolved without the prefix, i.e CP_DB_HOST -> DB_HOST
91 env.NewSource("CP_"),
92 ),
93 )
94 defer c.Close()
95
96 if err := c.Load(); err != nil {
97 panic(err)
98 }
99
100 var bc conf.Bootstrap
101 if err := c.Scan(&bc); err != nil {
102 panic(err)
103 }
104
105 // validate configuration
106 validator, err := protovalidate.New()
107 if err != nil {
108 panic(err)
109 }
110
111 if err := validator.Validate(&bc); err != nil {
112 panic(err)
113 }
114
115 logger, err := servicelogger.InitZapLogger(Version)
116 if err != nil {
117 panic(err)
118 }
119
120 logger = log.NewFilter(logger, log.FilterFunc(filterSensitiveArgs))
121
122 _ = logger.Log(log.LevelInfo, "msg", "starting control-plane service", "version", Version)
123
124 flush, err := initSentry(&bc, logger)
125 defer flush()
126 if err != nil {
127 panic(err)
128 }
129
130 credsWriter, err := manager.NewFromConfig(bc.GetCredentialsService(), credentials.RoleWriter, logger)
131 if err != nil {
132 panic(err)
133 }
134
135 // Load plugins
136 availablePlugins, err := plugins.Load(bc.GetPluginsDir(), logger)
137 if err != nil {
138 panic(err)
139 }
140 // Kill plugins processes on exit
141 defer availablePlugins.Cleanup()

Callers

nothing calls this directly

Calls 15

GetCredentialsServiceMethod · 0.95
GetPluginsDirMethod · 0.95
InitZapLoggerFunction · 0.92
NewFromConfigFunction · 0.92
LoadFunction · 0.92
cleanupFunction · 0.85
ParseMethod · 0.80
SyncUserAccessMethod · 0.80
initSentryFunction · 0.70
wireAppFunction · 0.70
toPtrFunction · 0.70
LoadMethod · 0.65

Tested by

no test coverage detected