func main() { startUp() defer cleanUp() // get context from args args := os.Args[1:] if len(args) == 3 { isSecure, err := strconv.ParseBool(args[2]) if err != nil { panic("isSecure cli argument is not boolean.") } context.SetContext(args[0], args[1], isSecure) } err := images.InitImages() if err != nil { gomol.Fatal("Could not load images.json.") panic(err) } err = slack.InitSlackConfig() if err != nil { gomol.Fatal("Could not load slack.json.") panic(err) } controllers.Register() http.ListenAndServe(":"+context.Port, nil) }
func newSlackConfig(path string) (*SlackConfig, error) { var config *SlackConfig configFile, err := ioutil.ReadFile(path) if err != nil { gomol.Fatal(err.Error()) return nil, err } if err := json.Unmarshal(configFile, &config); err != nil { gomol.Fatal(err.Error()) return nil, err } return config, nil }
func newImages(path string) (*ImageOptions, error) { imgs := &ImageOptions{} configFile, err := ioutil.ReadFile(path) if err != nil { gomol.Fatal(err.Error()) return nil, err } if err := json.Unmarshal(configFile, &imgs.imageOptions); err != nil { gomol.Fatal(err.Error()) return nil, err } return imgs, nil }