MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / initConfig

Function initConfig

cmd/root.go:107–126  ·  view source on GitHub ↗

initConfig reads in config file and ENV variables if set.

()

Source from the content-addressed store, hash-verified

105
106// initConfig reads in config file and ENV variables if set.
107func initConfig() {
108 viper.AutomaticEnv() // read in environment variables that match
109 configFile := viper.GetString(varConfig)
110
111 // If a custom config file is specified by flag or env var, use it. Otherwise use default file.
112 if len(configFile) > 0 {
113 if len(configFile) < 5 || strings.ToLower(configFile[len(configFile)-5:]) != ".json" {
114 fmt.Println("Error: Config file must be a .json file")
115 }
116 viper.SetConfigFile(configFile)
117 } else {
118 viper.AddConfigPath(defaultConfigFileDirectory())
119 viper.SetConfigName("cronitor")
120 }
121
122 // If a config file is found, read it in.
123 if err := viper.ReadInConfig(); err == nil {
124 log("Reading config from " + viper.ConfigFileUsed())
125 }
126}
127
128func sendPing(endpoint string, uniqueIdentifier string, message string, series string, timestamp float64, duration *float64, exitCode *int, metrics map[string]int, schedule string, group *sync.WaitGroup) {
129 if group != nil {

Callers

nothing calls this directly

Calls 2

logFunction · 0.85

Tested by

no test coverage detected