func DeleteNS(clientset *kubernetes.Clientset, namespace *v1.Namespace) {
	defer GinkgoRecover()
	clientset.Namespaces().Delete(namespace.Name, nil)
}
DeleteNS deletes k8s namespace
package utils
import (
	"flag"
	"fmt"
	"io"
	"regexp"
	"strconv"
	"strings"
	"github.com/Mirantis/k8s-AppController/pkg/client"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/pkg/api/errors"
	"k8s.io/client-go/pkg/api/v1"
	"k8s.io/client-go/pkg/apis/rbac/v1alpha1"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
)
var yamlDocumentDelimiter = regexp.MustCompile("(?m)^---")
const rbacServiceAccountAdmin = "system:serviceaccount-admin"
type TContext struct {
	Examples string
	Version  string
}
func SkipIf14() {
	if strings.Contains(TestContext.Version, "1.4") {
		Skip("This test is disabled on kubernetes of versions 1.4")
	}
}
func AddServiceAccountToAdmins(c kubernetes.Interface) {
	if IsVersionOlderThan16() {
		return
	}
	By("Adding service account group to cluster-admin role")
	roleBinding := &v1alpha1.ClusterRoleBinding{
		ObjectMeta: v1.ObjectMeta{
			Name: rbacServiceAccountAdmin,
		},
		Subjects: []v1alpha1.Subject{{
			Kind: "Group",
			Name: "system:serviceaccounts",
		}},
		RoleRef: v1alpha1.RoleRef{
			Kind:     "ClusterRole",
			Name:     "cluster-admin",
			APIGroup: "rbac.authorization.k8s.io",
		},
	}
	_, err := c.Rbac().ClusterRoleBindings().Create(roleBinding)
	Expect(err).NotTo(HaveOccurred(), "Failed to create role binding for serviceaccounts")
}
func RemoveServiceAccountFromAdmins(c kubernetes.Interface) {
	if IsVersionOlderThan16() {
		return
	}
	By("Remowing service account group from cluster-admin role")
	err := c.Rbac().ClusterRoleBindings().Delete(rbacServiceAccountAdmin, nil)
	Expect(err).NotTo(HaveOccurred(), "Failed to remove serviceaccount from cluster-admin role")
}
var TestContext = TContext{}
var url string
func init() {
	flag.StringVar(&TestContext.Examples, "examples-directory", "examples", "Provide path to directory with examples")
	flag.StringVar(&TestContext.Version, "k8s-version", "", "Specify kubernetes version that is used for e2e tests")
	flag.StringVar(&url, "cluster-url", "http://127.0.0.1:8080", "apiserver address to use with restclient")
}
func SanitizedVersion() float64 {
	var dirtyVersion string
	if strings.HasPrefix(TestContext.Version, "v") {
		dirtyVersion = TestContext.Version[1:]
	} else {
		dirtyVersion = TestContext.Version
	}
	version, err := strconv.ParseFloat(dirtyVersion, 64)
	Expect(err).NotTo(HaveOccurred())
	return version
}
func IsVersionOlderThan16() bool {
	return SanitizedVersion() < 1.6
}
func Logf(format string, a ...interface{}) {
	fmt.Fprintf(GinkgoWriter, format, a...)
}
func LoadConfig() *rest.Config {
	config, err := clientcmd.BuildConfigFromFlags(url, "")
	Expect(err).NotTo(HaveOccurred())
	return config
}
func KubeClient() (*kubernetes.Clientset, error) {
	Logf("Using master %v\n", url)
	config := LoadConfig()
	clientset, err := kubernetes.NewForConfig(config)
	Expect(err).NotTo(HaveOccurred())
	return clientset, nil
}
func GetAcClient(namespace string) (client.Interface, error) {
	client, err := client.NewForNamespace(url, namespace)
	return client, err
}