func getNamespace() string {
	ns := os.Getenv("KUBERNETES_AC_POD_NAMESPACE")
	if ns == "" {
		ns = api.NamespaceDefault
	}
	return ns
}
getNamespace returns the namespace the AC pod lives in. KUBERNETES_AC_POD_NAMESPACE should be populated by metadata.namespace in AC pod definition
package client
import (
	"log"
	"os"
	_ "github.com/Mirantis/k8s-AppController/pkg/client/petsets/apis/apps/install"
	"github.com/Mirantis/k8s-AppController/pkg/client/petsets/typed/apps/v1alpha1"
	"k8s.io/client-go/kubernetes"
	appsbeta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
	batchv1 "k8s.io/client-go/kubernetes/typed/batch/v1"
	corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
	"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
	"k8s.io/client-go/pkg/api"
	"k8s.io/client-go/pkg/api/unversioned"
	"k8s.io/client-go/pkg/apimachinery/announced"
	"k8s.io/client-go/pkg/runtime"
	"k8s.io/client-go/rest"
)
const (
	GroupName string = "appcontroller.k8s"
	Version string = "v1alpha1"
)
var (
	schemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: Version}
	schemeBuilder      = runtime.NewSchemeBuilder(addKnownTypes)
)
func addKnownTypes(scheme *runtime.Scheme) error {
	definitionGVK := schemeGroupVersion.WithKind("Definition")
	scheme.AddKnownTypeWithName(
		definitionGVK,
		&ResourceDefinition{},
	)
	definitionListGVK := schemeGroupVersion.WithKind("DefinitionList")
	scheme.AddKnownTypeWithName(
		definitionListGVK,
		&ResourceDefinitionList{},
	)
	scheme.AddKnownTypes(
		schemeGroupVersion,
		&Dependency{},
		&DependencyList{},
		&Replica{},
		&ReplicaList{},
	)
	return nil
}
func init() {
	if err := announced.NewGroupMetaFactory(
		&announced.GroupMetaFactoryArgs{
			GroupName:              GroupName,
			VersionPreferenceOrder: []string{schemeGroupVersion.Version},
		},
		announced.VersionToSchemeFunc{
			schemeGroupVersion.Version: schemeBuilder.AddToScheme,
		},
	).Announce().RegisterAndEnable(); err != nil {
		panic(err)
	}
}
type Interface interface {
	ConfigMaps() corev1.ConfigMapInterface
	Secrets() corev1.SecretInterface
	ServiceAccounts() corev1.ServiceAccountInterface
	Pods() corev1.PodInterface
	Jobs() batchv1.JobInterface
	Services() corev1.ServiceInterface
	ReplicaSets() v1beta1.ReplicaSetInterface
	StatefulSets() appsbeta1.StatefulSetInterface
	PetSets() v1alpha1.PetSetInterface
	DaemonSets() v1beta1.DaemonSetInterface
	Deployments() v1beta1.DeploymentInterface
	PersistentVolumeClaims() corev1.PersistentVolumeClaimInterface
	Dependencies() DependenciesInterface
	ResourceDefinitions() ResourceDefinitionsInterface
	Replicas() ReplicasInterface
	IsEnabled(version unversioned.GroupVersion) bool
	Namespace() string
}
type client struct {
	clientset           kubernetes.Interface
	alphaApps           v1alpha1.AppsInterface
	dependencies        DependenciesInterface
	resourceDefinitions ResourceDefinitionsInterface
	replicas            ReplicasInterface
	namespace           string
	apiVersions         *unversioned.APIGroupList
}
var _ Interface = &client{}
func (c client) Dependencies() DependenciesInterface {
	return c.dependencies
}
func (c client) ResourceDefinitions() ResourceDefinitionsInterface {
	return c.resourceDefinitions
}
func (c client) ConfigMaps() corev1.ConfigMapInterface {
	return c.clientset.Core().ConfigMaps(c.namespace)
}
func (c client) Secrets() corev1.SecretInterface {
	return c.clientset.Core().Secrets(c.namespace)
}
func (c client) Pods() corev1.PodInterface {
	return c.clientset.Core().Pods(c.namespace)
}
func (c client) Jobs() batchv1.JobInterface {
	return c.clientset.Batch().Jobs(c.namespace)
}
func (c client) Services() corev1.ServiceInterface {
	return c.clientset.Core().Services(c.namespace)
}
func (c client) ServiceAccounts() corev1.ServiceAccountInterface {
	return c.clientset.Core().ServiceAccounts(c.namespace)
}
func (c client) ReplicaSets() v1beta1.ReplicaSetInterface {
	return c.clientset.Extensions().ReplicaSets(c.namespace)
}
func (c client) StatefulSets() appsbeta1.StatefulSetInterface {
	return c.clientset.Apps().StatefulSets(c.namespace)
}
func (c client) PetSets() v1alpha1.PetSetInterface {
	return c.alphaApps.PetSets(c.namespace)
}
func (c client) DaemonSets() v1beta1.DaemonSetInterface {
	return c.clientset.Extensions().DaemonSets(c.namespace)
}
func (c client) Deployments() v1beta1.DeploymentInterface {
	return c.clientset.Extensions().Deployments(c.namespace)
}
func (c client) PersistentVolumeClaims() corev1.PersistentVolumeClaimInterface {
	return c.clientset.Core().PersistentVolumeClaims(c.namespace)
}
func (c client) Replicas() ReplicasInterface {
	return c.replicas
}
func (c client) Namespace() string {
	return c.namespace
}
func (c client) IsEnabled(version unversioned.GroupVersion) bool {
	for i := range c.apiVersions.Groups {
		group := c.apiVersions.Groups[i]
		if group.Name != version.Group {
			continue
		}
		for _, v := range group.Versions {
			if v.Version == version.Version {
				return true
			}
		}
	}
	return false
}
func newForConfig(c rest.Config, namespace string) (Interface, error) {
	deps, err := newDependencies(c, namespace)
	if err != nil {
		return nil, err
	}
	resdefs, err := newResourceDefinitions(c, namespace)
	if err != nil {
		return nil, err
	}
	replicas, err := newReplicas(c, namespace)
	if err != nil {
		return nil, err
	}
	cl, err := kubernetes.NewForConfig(&c)
	if err != nil {
		return nil, err
	}
	apps, err := v1alpha1.NewForConfig(&c)
	if err != nil {
		return nil, err
	}
	versions, err := cl.Discovery().ServerGroups()
	if err != nil {
		return nil, err
	}
	return NewClient(cl, apps, deps, resdefs, replicas, namespace, versions), nil
}
func NewClient(
	clientset kubernetes.Interface,
	alphaApps v1alpha1.AppsInterface,
	dependencies DependenciesInterface,
	resourceDefinitions ResourceDefinitionsInterface,
	replicas ReplicasInterface,
	namespace string,
	apiVersions *unversioned.APIGroupList) Interface {
	return &client{
		clientset:           clientset,
		alphaApps:           alphaApps,
		dependencies:        dependencies,
		resourceDefinitions: resourceDefinitions,
		replicas:            replicas,
		namespace:           namespace,
		apiVersions:         apiVersions,
	}
}
func thirdPartyResourceRESTClient(c *rest.Config) (*rest.RESTClient, error) {
	c.APIPath = "/apis"
	c.ContentConfig = rest.ContentConfig{
		GroupVersion: &unversioned.GroupVersion{
			Group:   GroupName,
			Version: Version,
		},
		NegotiatedSerializer: api.Codecs,
	}
	return rest.RESTClientFor(c)
}
func GetConfig(url string) (*rest.Config, error) {
	if url == "" {
		log.Println("No Kubernetes cluster URL provided. Assume in-cluster.")
		return rest.InClusterConfig()
	}
	return &rest.Config{Host: url}, nil
}
func New(url string) (Interface, error) {
	rc, err := GetConfig(url)
	if err != nil {
		return nil, err
	}
	return newForConfig(*rc, getNamespace())
}
func NewForNamespace(url string, namespace string) (Interface, error) {
	rc, err := GetConfig(url)
	if err != nil {
		return nil, err
	}
	return newForConfig(*rc, namespace)
}