func main()

in main.go [26:78]


func main() {
	flag.Parse()

	if *flagLogDebug {
		logging.Set(logging.Level("debug"))
	}

	log := logging.New("main")

	// "debuggable" builds at runtime produce extensive logging output compared
	// to release builds with the debug flag enabled. This requires building and
	// using a distinct build in the deployment in order to use.
	if logging.Debuggable {
		log.Info("low-level logging.Debuggable is enabled in this build")
		log.Warn("logging.Debuggable produces large volumes of logs")
		delay := 3 * time.Second
		log.WithField("delay", delay).Warn("delaying start due to logging.Debuggable build")
		time.Sleep(delay)
		log.Info("starting logging.Debuggable enabled build")
	}

	kube, err := k8sutil.DefaultKubernetesClient()
	if err != nil {
		log.WithError(err).Fatalf("kubernetes client")
	}

	ctx, cancel := sigcontext.WithSignalCancel(context.Background(), syscall.SIGINT, syscall.SIGTERM)
	defer cancel()

	switch {
	case *flagNodeName == "":
		log.Errorf("nodeName to operate under must be provided")
		os.Exit(1)
	case *flagController && *flagAgent:
		log.Error("cannot run both agent and controller")
		os.Exit(1)
	case !*flagController && !*flagAgent:
		log.Error("no component specified to run, provide either -agent or -controller")
		flag.Usage()
		os.Exit(1)
	case *flagController:
		err = runController(ctx, kube, *flagNodeName)
		if err != nil {
			log.WithError(err).Fatalf("controller stopped")
		}
	case *flagAgent:
		err = runAgent(ctx, kube, *flagNodeName)
		if err != nil {
			log.WithError(err).Fatalf("agent stopped")
		}
	}
	log.Info("bark bark! 🐕")
}