mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05:00 
			
		
		
		
	* Merge notification code by @aledbf and update for recent changes. * Fix travis environment to correctly build with k8s.io and forked repositories. * Refactored kubernetes Corefile parser * Added lots of Corefile parsing tests
		
			
				
	
	
		
			43 lines
		
	
	
		
			983 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			983 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Package kubernetes/util provides helper functions for the kubernetes middleware
 | 
						|
package util
 | 
						|
 | 
						|
import (
 | 
						|
	"strings"
 | 
						|
 | 
						|
	"k8s.io/kubernetes/pkg/api"
 | 
						|
	"k8s.io/kubernetes/pkg/client/cache"
 | 
						|
)
 | 
						|
 | 
						|
// StringInSlice check whether string a is a member of slice.
 | 
						|
func StringInSlice(a string, slice []string) bool {
 | 
						|
	for _, b := range slice {
 | 
						|
		if b == a {
 | 
						|
			return true
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
// SymbolContainsWildcard checks whether symbol contains a wildcard value
 | 
						|
func SymbolContainsWildcard(symbol string) bool {
 | 
						|
	return (strings.Contains(symbol, WildcardStar) || (symbol == WildcardAny))
 | 
						|
}
 | 
						|
 | 
						|
const (
 | 
						|
	WildcardStar = "*"
 | 
						|
	WildcardAny  = "any"
 | 
						|
)
 | 
						|
 | 
						|
// StoreToNamespaceLister makes a Store that lists Namespaces.
 | 
						|
type StoreToNamespaceLister struct {
 | 
						|
	cache.Store
 | 
						|
}
 | 
						|
 | 
						|
// List lists all Namespaces in the store.
 | 
						|
func (s *StoreToNamespaceLister) List() (ns api.NamespaceList, err error) {
 | 
						|
	for _, m := range s.Store.List() {
 | 
						|
		ns.Items = append(ns.Items, *(m.(*api.Namespace)))
 | 
						|
	}
 | 
						|
	return ns, nil
 | 
						|
}
 |