func main()

in main/main.go [66:173]


func main() {
	var (
		config                           *rest.Config
		err                              error
		namespaceMap, ignoreNamespaceMap map[string]bool
	)

	if *atsNamespace == "" {
		log.Panicln("Not all required args given.")
	}

	namespaceMap = make(map[string]bool)

	// default namespace to "all"
	if *namespaces != namespace.ALL {
		namespaceList := strings.Split(strings.Replace(strings.ToLower(*namespaces), " ", "", -1), ",")
		for _, namespace := range namespaceList {
			if namespace != "" {
				namespaceMap[namespace] = true
			}
		}
	}

	ignoreNamespaceMap = make(map[string]bool)

	if *ignoreNamespaces != "" {
		ignoreNamespaceList := strings.Split(strings.Replace(strings.ToLower(*ignoreNamespaces), " ", "", -1), ",")
		for _, namespace := range ignoreNamespaceList {
			if namespace != "" {
				ignoreNamespaceMap[namespace] = true
			}
		}
	}

	if *useKubeConfig {
		log.Println("Read config from ", *kubeconfig)
		/* For running outside of the cluster
		uses the current context in kubeconfig */
		config, err = clientcmd.BuildConfigFromFlags("", *kubeconfig)
		if err != nil {
			log.Panicln(err.Error())
		}
		/* for running inside the cluster */
	} else if *useInClusterConfig {
		config, err = rest.InClusterConfig()
		if err != nil {
			log.Panicln("failed to create InClusterConfig: " + err.Error())
		}
	} else {
		/* create config and set necessary parameters */
		config = &rest.Config{}
		config.Host = *apiServer
		config.CertFile = *certFilePath
		config.KeyFile = *keyFilePath
		config.CAFile = *caFilePath
	}

	/* creates the clientset */
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		log.Panicln(err.Error())
	}

	stopChan := make(chan struct{})

	// ------------ Resolving Namespaces --------------------------------------
	nsManager := namespace.NsManager{
		NamespaceMap:       namespaceMap,
		IgnoreNamespaceMap: ignoreNamespaceMap,
	}

	nsManager.Init()

	//------------ Setting up Redis in memory Datastructure -------------------
	rClient, err := redis.Init()
	if err != nil {
		log.Panicln("Redis Error: ", err)
	}

	// ALL services must be using CORE V1 API
	endpoint := ep.Endpoint{
		RedisClient: rClient,
		ATSManager:  &proxy.ATSManager{Namespace: *atsNamespace, IngressClass: *atsIngressClass},
		NsManager:   &nsManager,
	}

	watcher := w.Watcher{
		Cs:           clientset,
		ATSNamespace: *atsNamespace,
		ResyncPeriod: *resyncPeriod,
		Ep:           &endpoint,
		StopChan:     stopChan,
	}

	err = watcher.Watch()
	if err != nil {
		log.Panicln("Error received from watcher.Watch() :", err)
	}

	/* Program termination */
	signalChan := make(chan os.Signal, 1)
	signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
	for range signalChan {
		log.Println("Shutdown signal received, exiting...")
		close(stopChan)
		os.Exit(0)
	}
}