MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / Main

Function Main

main.go:26–87  ·  view source on GitHub ↗

Main is a helper function to start a standard ContainerSSH instance. It should be used as the outer-most function and should never be used as an embedding technique.

()

Source from the content-addressed store, hash-verified

24// Main is a helper function to start a standard ContainerSSH instance. It should be used as the outer-most function
25// and should never be used as an embedding technique.
26func Main() {
27 cfg := config.AppConfig{}
28 cfg.Default()
29
30 loggerFactory := log.NewLoggerFactory()
31 logger, err := loggerFactory.Make(
32 cfg.Log,
33 )
34 if err != nil {
35 panic(err)
36 }
37
38 logger = logger.WithLabel("module", "core")
39
40 configFile, actionDumpConfig, actionLicenses, actionHealthCheck := getArguments()
41
42 if configFile == "" {
43 configFile = "config.yaml"
44 }
45 realConfigFile, err := filepath.Abs(configFile)
46 if err != nil {
47 logger.Critical(
48 message.Wrap(
49 err,
50 message.ECoreConfig,
51 "Failed to fetch absolute path for configuration file %s",
52 configFile,
53 ))
54 os.Exit(1)
55 }
56 configFile = realConfigFile
57 if err = readConfigFile(configFile, loggerFactory, &cfg); err != nil {
58 logger.Critical(
59 message.Wrap(
60 err,
61 message.ECoreConfig,
62 "Invalid configuration in file %s",
63 configFile,
64 ))
65 os.Exit(1)
66 }
67
68 configuredLogger, err := loggerFactory.Make(
69 cfg.Log,
70 )
71 if err != nil {
72 logger.Critical(err)
73 os.Exit(1)
74 }
75 configuredLogger.Debug(message.NewMessage(message.MCoreConfigFile, "Using configuration file %s...", configFile))
76
77 switch {
78 case actionDumpConfig:
79 runDumpConfig(cfg, configuredLogger)
80 case actionLicenses:
81 runActionLicenses(configuredLogger)
82 case actionHealthCheck:
83 runHealthCheck(cfg, configuredLogger)

Callers 1

mainFunction · 0.92

Calls 14

DefaultMethod · 0.95
MakeMethod · 0.95
NewLoggerFactoryFunction · 0.92
WrapFunction · 0.92
NewMessageFunction · 0.92
getArgumentsFunction · 0.85
runDumpConfigFunction · 0.85
runActionLicensesFunction · 0.85
runHealthCheckFunction · 0.85
runContainerSSHFunction · 0.85
readConfigFileFunction · 0.70
WithLabelMethod · 0.65

Tested by

no test coverage detected