func newFakeRequestDeployment(image string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "apps",
		      "version": "v1",
		      "kind": "Deployment"
		    },
		    "resource": {
		      "group": "apps",
		      "version": "v1",
		      "resource": "deployments"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
						"replicas":1,
						"template":{
							"spec":{
								"volumes": [
									{
										"name": "default-token-xff4f",
										"secret": {
											"secretName": "default-token-xff4f"
		            }
		          }
							],
							"containers": [
										{
											"name": "statsd",
											"image": "%s",
											"ports": [
												{
													"hostPort": 8080,
													"containerPort": 8080,
													"protocol": "TCP"
												}
												],
												"resources": {},
												"volumeMounts": [
													{
														"name": "default-token-xff4f",
														"readOnly": true,
														"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
													}
													],
													"terminationMessagePath": "/dev/termination-log",
													"terminationMessagePolicy": "File",
													"imagePullPolicy": "Always"
												}
												],
												"restartPolicy": "Always",
												"terminationGracePeriodSeconds": 30,
												"dnsPolicy": "ClusterFirst",
												"serviceAccountName": "default",
												"serviceAccount": "default",
												"hostNetwork": true,
												"securityContext": {},
												"imagePullSecrets": [
													{
														"name": "regsecret"
													}
													],
													"schedulerName": "default-scheduler",
													"tolerations": [
														{
															"key": "node.kubernetes.io/not-ready",
															"operator": "Exists",
															"effect": "NoExecute",
															"tolerationSeconds": 300
														},
														{
															"key": "node.kubernetes.io/unreachable",
															"operator": "Exists",
															"effect": "NoExecute",
															"tolerationSeconds": 300
														}
														]
													},
													"status": {}
												},
												"oldObject": null
											}
										}
									}
								}`, image)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
newFakeRequest creates a new http request
package trust
import (
	"bytes"
	"fmt"
	"net/http"
	"os"
	policyclientsetfake "github.com/IBM/portieris/pkg/apis/portieris.cloud.ibm.com/client/clientset/versioned/fake"
	policyv1 "github.com/IBM/portieris/pkg/apis/portieris.cloud.ibm.com/v1"
	"github.com/IBM/portieris/pkg/kubernetes"
	"github.com/IBM/portieris/pkg/notary/fakenotary"
	"github.com/IBM/portieris/pkg/policy"
	"github.com/IBM/portieris/pkg/registry/fakeregistry"
	"github.com/IBM/portieris/pkg/webhook"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/util/yaml"
	k8sfake "k8s.io/client-go/kubernetes/fake"
	"testing"
)
func TestAdmissioncontroller(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Admissioncontroller Suite")
}
var _ = BeforeSuite(func() {
	tempTrustDir = "./test_trust"
})
var _ = AfterSuite(func() {
	os.RemoveAll(tempTrustDir)
})
var (
	tempTrustDir        string
	ctrl                *Verifier
	kubeClientset       *k8sfake.Clientset
	kubeWrapper         kubernetes.WrapperInterface
	secClientset        *policyclientsetfake.Clientset
	policyClient        *policy.Client
	kubeObjects         []runtime.Object
	imageObjects        []runtime.Object
	clusterimageObjects []runtime.Object
	trust               *fakenotary.FakeNotary
	cr                  *fakeregistry.FakeRegistry
	wh                  *webhook.Server
)
func resetAllFakes() {
	kubeObjects = []runtime.Object{}
	kubeClientset = k8sfake.NewSimpleClientset(kubeObjects...)
	kubeWrapper = kubernetes.NewKubeClientsetWrapper(kubeClientset)
	imageObjects = []runtime.Object{}
	secClientset = policyclientsetfake.NewSimpleClientset(imageObjects...)
	policyClient = policy.NewClient(secClientset)
	trust = &fakenotary.FakeNotary{}
	cr = &fakeregistry.FakeRegistry{}
	ctrl = NewVerifier(kubeWrapper, trust, cr)
}
func newImagePolicyFromYAMLOrJSON(payload *bytes.Buffer, namespace string) *policyv1.ImagePolicy {
	decoder := yaml.NewYAMLOrJSONDecoder(payload, 50)
	policy := &policyv1.ImagePolicy{
		ObjectMeta: metav1.ObjectMeta{
			Namespace: namespace,
		},
	}
	decoder.Decode(policy)
	return policy
}
func createNewImagePolicy(repo, namespace string) *policyv1.ImagePolicy {
	return &policyv1.ImagePolicy{
		TypeMeta: metav1.TypeMeta{
			APIVersion: policyv1.SchemeGroupVersion.String(),
			Kind:       "ImagePolicy",
		},
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%s-test", namespace),
			Namespace: namespace,
		},
		Spec: policyv1.ImagePolicySpec{
			Repositories: []policyv1.Repository{
				{
					Name: repo,
					Policy: policyv1.Policy{
						Trust: policyv1.Trust{
							Enabled:       policyv1.FalsePointer,
							SignerSecrets: []policyv1.TrustSigner{},
						},
					},
				},
			},
		},
	}
}
func newClusterImagePolicyFromYAMLOrJSON(payload *bytes.Buffer, namespace string) *policyv1.ClusterImagePolicy {
	decoder := yaml.NewYAMLOrJSONDecoder(payload, 50)
	policy := &policyv1.ClusterImagePolicy{
		ObjectMeta: metav1.ObjectMeta{
			Namespace: namespace,
		},
	}
	err := decoder.Decode(policy)
	Expect(err).ToNot(HaveOccurred())
	return policy
}
func createClusterImagePolicy(repo, namespace string) *policyv1.ClusterImagePolicy {
	return &policyv1.ClusterImagePolicy{
		TypeMeta: metav1.TypeMeta{
			APIVersion: policyv1.SchemeGroupVersion.String(),
			Kind:       "ClusterImagePolicy",
		},
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%s-test", namespace),
			Namespace: namespace,
		},
		Spec: policyv1.ImagePolicySpec{
			Repositories: []policyv1.Repository{
				{
					Name: repo,
					Policy: policyv1.Policy{
						Trust: policyv1.Trust{
							Enabled:       policyv1.FalsePointer,
							SignerSecrets: []policyv1.TrustSigner{},
						},
					},
				},
			},
		},
	}
}
func newFakeSecret(secretName, namespace, registry string) *corev1.Secret {
	return &corev1.Secret{
		TypeMeta: metav1.TypeMeta{
			APIVersion: "v1",
			Kind:       "Secret",
		},
		ObjectMeta: metav1.ObjectMeta{
			Name:      secretName,
			Namespace: namespace,
		},
		Data: map[string][]byte{
			".dockerconfigjson": []byte(
				fmt.Sprintf(`{
			  "auths": {
			    "%s": {
			      "username": "token",
			      "password": "registry-token",
			      "email": "email@email.com",
			      "auth": "auth-token"
			    }
			  }
			}`, registry)),
		},
	}
}
func newFakeRequest(image string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
		        "containers": [
		          {
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
		          {
								"name": "regsecret"
		          }
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, image)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
func newFakeRequestMulitpleSecretsBadSecond(image string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
		        "containers": [
		          {
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
							{
								"name": "regsecret"
							},
							{
								"name": "badregsecret"
							}
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, image)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
func newFakeRequestMulitpleSecrets(image string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
		        "containers": [
		          {
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
							{
								"name": "badregsecret"
							},
							{
								"name": "regsecret"
							}
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, image)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
func newFakeRequestMultipleValidSecrets(image string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
		        "containers": [
		          {
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
							{
								"name": "regsecret1"
							},
							{
								"name": "regsecret"
							}
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, image)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
func newFakeRequestMultiContainer(image, image1 string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
		        "containers": [
		          {
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
							},
							{
		            "name": "statsd",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
		          {
		            "name": "regsecret"
		          }
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, image, image1)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
func newFakeRequestMultiContainerMultiSecret(image, image1 string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
		        "containers": [
		          {
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
							},
							{
		            "name": "statsd",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
							{
								"name": "regsecret"
							},
							{
								"name": "regsecret3"
							}
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, image, image1)))
	req.Header.Set("Content-Type", "application/json")
	return req
}
func newFakeRequestInitContainer(initImage, image string) *http.Request {
	req, _ := http.NewRequest("POST", "/", bytes.NewBufferString(fmt.Sprintf(`
		{
		  "kind": "AdmissionReview",
		  "apiVersion": "admission.k8s.io/v1beta1",
		  "request": {
		    "uid": "ed782967-1c99-11e8-936d-08002789d446",
		    "kind": {
		      "group": "",
		      "version": "v1",
		      "kind": "Pod"
		    },
		    "resource": {
		      "group": "",
		      "version": "v1",
		      "resource": "pods"
		    },
		    "namespace": "default",
		    "operation": "CREATE",
		    "userInfo": {
		      "username": "minikube-user",
		      "groups": [
		        "system:masters",
		        "system:authenticated"
		      ]
		    },
		    "object": {
		      "metadata": {
		        "name": "nginx",
		        "namespace": "default",
		        "creationTimestamp": null
		      },
		      "spec": {
		        "volumes": [
		          {
		            "name": "default-token-xff4f",
		            "secret": {
		              "secretName": "default-token-xff4f"
		            }
		          }
		        ],
                "initContainers" : [
				{
		            "name": "nginx",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
					}
                ],
		        "containers": [
                 {
		            "name": "statsd",
		            "image": "%s",
		            "ports": [
		              {
		                "hostPort": 8080,
		                "containerPort": 8080,
		                "protocol": "TCP"
		              }
		            ],
		            "resources": {},
		            "volumeMounts": [
		              {
		                "name": "default-token-xff4f",
		                "readOnly": true,
		                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
		              }
		            ],
		            "terminationMessagePath": "/dev/termination-log",
		            "terminationMessagePolicy": "File",
		            "imagePullPolicy": "Always"
		          }
		        ],
		        "restartPolicy": "Always",
		        "terminationGracePeriodSeconds": 30,
		        "dnsPolicy": "ClusterFirst",
		        "serviceAccountName": "default",
		        "serviceAccount": "default",
		        "hostNetwork": true,
		        "securityContext": {},
		        "imagePullSecrets": [
		          {
		            "name": "regsecret"
		          }
		        ],
		        "schedulerName": "default-scheduler",
		        "tolerations": [
		          {
		            "key": "node.kubernetes.io/not-ready",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          },
		          {
		            "key": "node.kubernetes.io/unreachable",
		            "operator": "Exists",
		            "effect": "NoExecute",
		            "tolerationSeconds": 300
		          }
		        ]
		      },
		      "status": {}
		    },
		    "oldObject": null
		  }
		}`, initImage, image)))
	req.Header.Set("Content-Type", "application/json")
	return req
}