func (d ExistingDeployment) Delete() error {
	return d.Client.Delete(d.Name, nil)
}
Delete deletes Deployment from the cluster
package resources
import (
	"errors"
	"log"
	"github.com/Mirantis/k8s-AppController/pkg/client"
	"github.com/Mirantis/k8s-AppController/pkg/interfaces"
	"github.com/Mirantis/k8s-AppController/pkg/report"
	"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
	extbeta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
)
var deploymentParamFields = []string{
	"Spec.Template.Spec.Containers.Name",
	"Spec.Template.Spec.Containers.Env",
	"Spec.Template.Spec.InitContainers.Name",
	"Spec.Template.Spec.InitContainers.Env",
	"Spec.Template.ObjectMeta",
}
type Deployment struct {
	Base
	Deployment *extbeta1.Deployment
	Client     v1beta1.DeploymentInterface
}
type deploymentTemplateFactory struct{}
func (deploymentTemplateFactory) ShortName(definition client.ResourceDefinition) string {
	if definition.Deployment == nil {
		return ""
	}
	return definition.Deployment.Name
}
func (deploymentTemplateFactory) Kind() string {
	return "deployment"
}
func (deploymentTemplateFactory) New(def client.ResourceDefinition, c client.Interface, gc interfaces.GraphContext) interfaces.Resource {
	newDeployment := parametrizeResource(def.Deployment, gc, deploymentParamFields).(*extbeta1.Deployment)
	return report.SimpleReporter{BaseResource: Deployment{Base: Base{def.Meta}, Deployment: newDeployment, Client: c.Deployments()}}
}
func (deploymentTemplateFactory) NewExisting(name string, c client.Interface, gc interfaces.GraphContext) interfaces.Resource {
	return report.SimpleReporter{BaseResource: ExistingDeployment{Name: name, Client: c.Deployments()}}
}
func deploymentKey(name string) string {
	return "deployment/" + name
}
func deploymentStatus(d v1beta1.DeploymentInterface, name string) (interfaces.ResourceStatus, error) {
	deployment, err := d.Get(name)
	if err != nil {
		return interfaces.ResourceError, err
	}
	if deployment.Status.UpdatedReplicas >= *deployment.Spec.Replicas && deployment.Status.AvailableReplicas >= *deployment.Spec.Replicas {
		return interfaces.ResourceReady, nil
	}
	return interfaces.ResourceNotReady, nil
}
func (d Deployment) Key() string {
	return deploymentKey(d.Deployment.Name)
}
func (d Deployment) Status(meta map[string]string) (interfaces.ResourceStatus, error) {
	return deploymentStatus(d.Client, d.Deployment.Name)
}
func (d Deployment) Create() error {
	log.Println("Looking for deployment", d.Deployment.Name)
	status, err := d.Status(nil)
	if err == nil {
		log.Printf("Found deployment %s, status: %s", d.Deployment.Name, status)
		log.Println("Skipping creation of deployment", d.Deployment.Name)
	}
	log.Println("Creating deployment", d.Deployment.Name)
	d.Deployment, err = d.Client.Create(d.Deployment)
	return err
}
func (d Deployment) Delete() error {
	return d.Client.Delete(d.Deployment.Name, nil)
}
type ExistingDeployment struct {
	Base
	Name   string
	Client v1beta1.DeploymentInterface
}
func (d ExistingDeployment) UpdateMeta(meta map[string]string) error {
	return nil
}
func (d ExistingDeployment) Key() string {
	return deploymentKey(d.Name)
}
func (d ExistingDeployment) Status(meta map[string]string) (interfaces.ResourceStatus, error) {
	return deploymentStatus(d.Client, d.Name)
}
func (d ExistingDeployment) Create() error {
	log.Println("Looking for deployment", d.Name)
	status, err := d.Status(nil)
	if err == nil {
		log.Printf("Found deployment %s, status: %s", d.Name, status)
		return nil
	}
	log.Fatalf("Deployment %s not found", d.Name)
	return errors.New("Deployment not found")
}