func BuildSelectors()

in webhooks/alloydb-nodeselector-mwh/handlers/pod_nodeselector_handler.go [29:47]


func BuildSelectors() {
	path := os.Getenv("SELECTORS_CONFIG_PATH")
	fileName := os.Getenv("SELECTORS_CONFIG_FILE")
	filePath := filepath.Join(path, fileName)
	configFile, err := os.Open(filePath)
	if err != nil {
		log.Fatalf(fmt.Sprintf("handlers.BuildSelectors():Error opening node selectors config file %s", os.Getenv("SELECTORS_CONFIG_PATH")), err)
	}
	defer configFile.Close()
	data, err := io.ReadAll(configFile)
	if err != nil {
		log.Fatalf("handlers.BuildSelectors():Error reading the node selectors data from the file:: %v", err)
	}
	if err = json.Unmarshal(data, &nodelSelectors); err != nil {
		log.Fatalf("handlers.BuildSelectors():Error unmarshalling the node selectors data from the file:: %v", err)
	}
	log.Info("handlers.BuildSelectors():Initialized the node selectors to be configured for the pod")

}