INNER CODE UNIT · Go

checkNamespaces

nginx/kubernetes-ingress · cmd/nginx-ingress/main.go:480

func checkNamespaces(ctx context.Context, kubeClient kubernetes.Interface) {
	l := nl.LoggerFromContext(ctx)
	if *watchNamespaceLabel != "" {
		// bootstrap the watched namespace list
		var newWatchNamespaces []string
		nsList, err := kubeClient.CoreV1().Namespaces().List(context.TODO(), meta_v1.ListOptions{LabelSelector: *watchNamespaceLabel})
		if err != nil {
			nl.Errorf(l, "error when getting Namespaces with the label selector %v: %v", watchNamespaceLabel, err)
		}
		for _, ns := range nsList.Items {
			newWatchNamespaces = append(newWatchNamespaces, ns.Name)
		}
		watchNamespaces = newWatchNamespaces
		nl.Infof(l, "Namespaces watched using label %v: %v", *watchNamespaceLabel, watchNamespaces)
	} else {
		checkNamespaceExists(ctx, kubeClient, watchNamespaces)
	}
	checkNamespaceExists(ctx, kubeClient, watchSecretNamespaces)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…