func (b *Builder) Build() (*PodTemplateSpec, error) {
	err := b.validate()
	if err != nil {
		return nil, errors.Wrapf(
			err,
			"failed to build a podtemplatespec: %s",
			b.podtemplatespec.Object,
		)
	}
	return b.podtemplatespec, nil
}
Build returns a deployment instance
package podtemplatespec
import (
	"github.com/openebs/dynamic-nfs-provisioner/pkg/kubernetes/api/core/v1/container"
	"github.com/openebs/dynamic-nfs-provisioner/pkg/kubernetes/api/core/v1/volume"
	errors "github.com/pkg/errors"
	corev1 "k8s.io/api/core/v1"
)
type PodTemplateSpec struct {
	Object *corev1.PodTemplateSpec
}
type Builder struct {
	podtemplatespec *PodTemplateSpec
	errs            []error
}
func NewBuilder() *Builder {
	return &Builder{
		podtemplatespec: &PodTemplateSpec{
			Object: &corev1.PodTemplateSpec{},
		},
	}
}
func (b *Builder) WithName(name string) *Builder {
	if len(name) == 0 {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec object: missing name"),
		)
		return b
	}
	b.podtemplatespec.Object.Name = name
	return b
}
func (b *Builder) WithNamespace(namespace string) *Builder {
	if len(namespace) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing namespace",
			),
		)
		return b
	}
	b.podtemplatespec.Object.Namespace = namespace
	return b
}
func (b *Builder) WithAnnotations(annotations map[string]string) *Builder {
	if len(annotations) == 0 {
		b.errs = append(
			b.errs,
			errors.New("failed to build deployment object: missing annotations"),
		)
		return b
	}
	if b.podtemplatespec.Object.Annotations == nil {
		return b.WithAnnotationsNew(annotations)
	}
	for key, value := range annotations {
		b.podtemplatespec.Object.Annotations[key] = value
	}
	return b
}
func (b *Builder) WithAnnotationsNew(annotations map[string]string) *Builder {
	if len(annotations) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing annotations",
			),
		)
		return b
	}
	newannotations := map[string]string{}
	for key, value := range annotations {
		newannotations[key] = value
	}
	b.podtemplatespec.Object.Annotations = newannotations
	return b
}
func (b *Builder) WithLabels(labels map[string]string) *Builder {
	if len(labels) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing labels",
			),
		)
		return b
	}
	if b.podtemplatespec.Object.Labels == nil {
		return b.WithLabelsNew(labels)
	}
	for key, value := range labels {
		b.podtemplatespec.Object.Labels[key] = value
	}
	return b
}
func (b *Builder) WithLabelsNew(labels map[string]string) *Builder {
	if len(labels) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing labels",
			),
		)
		return b
	}
	newlbls := map[string]string{}
	for key, value := range labels {
		newlbls[key] = value
	}
	b.podtemplatespec.Object.Labels = newlbls
	return b
}
func (b *Builder) WithSecurityContext(
	podSecurityContext *corev1.PodSecurityContext) *Builder {
	if podSecurityContext == nil {
		return b
	}
	b.podtemplatespec.Object.Spec.SecurityContext = podSecurityContext
	return b
}
func (b *Builder) WithNodeSelector(nodeselectors map[string]string) *Builder {
	if len(nodeselectors) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing nodeselectors",
			),
		)
		return b
	}
	if b.podtemplatespec.Object.Spec.NodeSelector == nil {
		return b.WithNodeSelectorNew(nodeselectors)
	}
	for key, value := range nodeselectors {
		b.podtemplatespec.Object.Spec.NodeSelector[key] = value
	}
	return b
}
func (b *Builder) WithPriorityClassName(prorityClassName string) *Builder {
	b.podtemplatespec.Object.Spec.PriorityClassName = prorityClassName
	return b
}
func (b *Builder) WithNodeSelectorNew(nodeselectors map[string]string) *Builder {
	if len(nodeselectors) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing nodeselectors",
			),
		)
		return b
	}
	newnodeselectors := map[string]string{}
	for key, value := range nodeselectors {
		newnodeselectors[key] = value
	}
	b.podtemplatespec.Object.Spec.NodeSelector = newnodeselectors
	return b
}
func (b *Builder) WithNodeSelectorByValue(nodeselectors map[string]string) *Builder {
	newnodeselectors := map[string]string{}
	for key, value := range nodeselectors {
		newnodeselectors[key] = value
	}
	b.podtemplatespec.Object.Spec.NodeSelector = newnodeselectors
	return b
}
func (b *Builder) WithServiceAccountName(serviceAccountnNme string) *Builder {
	if len(serviceAccountnNme) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing serviceaccountname",
			),
		)
		return b
	}
	b.podtemplatespec.Object.Spec.ServiceAccountName = serviceAccountnNme
	return b
}
func (b *Builder) WithImagePullSecret(imagePullSecretName string) *Builder {
	if len(imagePullSecretName) != 0 {
		b.podtemplatespec.Object.Spec.ImagePullSecrets = append(
			b.podtemplatespec.Object.Spec.ImagePullSecrets,
			corev1.LocalObjectReference{
				Name: imagePullSecretName,
			},
		)
	}
	return b
}
func (b *Builder) WithAffinity(affinity *corev1.Affinity) *Builder {
	if affinity == nil {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing affinity",
			),
		)
		return b
	}
	newaffinitylist := *affinity
	b.podtemplatespec.Object.Spec.Affinity = &newaffinitylist
	return b
}
func (b *Builder) WithNodeAffinityMatchExpressions(
	mExpressions []corev1.NodeSelectorRequirement) *Builder {
	if len(mExpressions) == 0 {
		return b
	}
	if b.podtemplatespec.Object.Spec.Affinity == nil {
		b.podtemplatespec.Object.Spec.Affinity = &corev1.Affinity{}
	}
	if b.podtemplatespec.Object.Spec.Affinity.NodeAffinity == nil {
		b.podtemplatespec.Object.Spec.Affinity.NodeAffinity = &corev1.NodeAffinity{}
	}
	if b.podtemplatespec.
		Object.
		Spec.
		Affinity.
		NodeAffinity.
		RequiredDuringSchedulingIgnoredDuringExecution == nil {
		b.podtemplatespec.
			Object.
			Spec.
			Affinity.
			NodeAffinity.
			RequiredDuringSchedulingIgnoredDuringExecution = &corev1.NodeSelector{}
	}
	b.podtemplatespec.
		Object.
		Spec.
		Affinity.
		NodeAffinity.
		RequiredDuringSchedulingIgnoredDuringExecution.
		NodeSelectorTerms = append(b.podtemplatespec.
		Object.
		Spec.
		Affinity.
		NodeAffinity.
		RequiredDuringSchedulingIgnoredDuringExecution.
		NodeSelectorTerms,
		corev1.NodeSelectorTerm{
			MatchExpressions: mExpressions,
		},
	)
	return b
}
func (b *Builder) WithTolerationsByValue(tolerations ...corev1.Toleration) *Builder {
	if len(b.podtemplatespec.Object.Spec.Tolerations) == 0 {
		b.podtemplatespec.Object.Spec.Tolerations = tolerations
		return b
	}
	b.podtemplatespec.Object.Spec.Tolerations = append(
		b.podtemplatespec.Object.Spec.Tolerations,
		tolerations...,
	)
	return b
}
func (b *Builder) WithTolerations(tolerations ...corev1.Toleration) *Builder {
	if tolerations == nil {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: nil tolerations",
			),
		)
		return b
	}
	if len(tolerations) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing tolerations",
			),
		)
		return b
	}
	if len(b.podtemplatespec.Object.Spec.Tolerations) == 0 {
		return b.WithTolerationsNew(tolerations...)
	}
	b.podtemplatespec.Object.Spec.Tolerations = append(
		b.podtemplatespec.Object.Spec.Tolerations,
		tolerations...,
	)
	return b
}
func (b *Builder) WithTolerationsNew(tolerations ...corev1.Toleration) *Builder {
	if tolerations == nil {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: nil tolerations",
			),
		)
		return b
	}
	if len(tolerations) == 0 {
		b.errs = append(
			b.errs,
			errors.New(
				"failed to build podtemplatespec object: missing tolerations",
			),
		)
		return b
	}
	newtolerations := []corev1.Toleration{}
	newtolerations = append(newtolerations, tolerations...)
	b.podtemplatespec.Object.Spec.Tolerations = newtolerations
	return b
}
func (b *Builder) WithContainerBuilders(
	containerBuilderList ...*container.Builder,
) *Builder {
	if containerBuilderList == nil {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec: nil containerbuilder"),
		)
		return b
	}
	for _, containerBuilder := range containerBuilderList {
		containerObj, err := containerBuilder.Build()
		if err != nil {
			b.errs = append(
				b.errs,
				errors.Wrap(
					err,
					"failed to build podtemplatespec",
				),
			)
			return b
		}
		b.podtemplatespec.Object.Spec.Containers = append(
			b.podtemplatespec.Object.Spec.Containers,
			containerObj,
		)
	}
	return b
}
func (b *Builder) WithVolumeBuilders(
	volumeBuilderList ...*volume.Builder,
) *Builder {
	if volumeBuilderList == nil {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec: nil volumeBuilderList"),
		)
		return b
	}
	for _, volumeBuilder := range volumeBuilderList {
		vol, err := volumeBuilder.Build()
		if err != nil {
			b.errs = append(
				b.errs,
				errors.Wrap(err, "failed to build podtemplatespec"),
			)
			return b
		}
		newvol := *vol
		b.podtemplatespec.Object.Spec.Volumes = append(
			b.podtemplatespec.Object.Spec.Volumes,
			newvol,
		)
	}
	return b
}
func (b *Builder) WithContainerBuildersNew(
	containerBuilderList ...*container.Builder,
) *Builder {
	if containerBuilderList == nil {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec: nil containerbuilder"),
		)
		return b
	}
	if len(containerBuilderList) == 0 {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec: missing containerbuilder"),
		)
		return b
	}
	containerList := []corev1.Container{}
	for _, containerBuilder := range containerBuilderList {
		containerObj, err := containerBuilder.Build()
		if err != nil {
			b.errs = append(
				b.errs,
				errors.Wrap(
					err,
					"failed to build podtemplatespec",
				),
			)
			return b
		}
		containerList = append(
			containerList,
			containerObj,
		)
	}
	b.podtemplatespec.Object.Spec.Containers = containerList
	return b
}
func (b *Builder) WithVolumeBuildersNew(
	volumeBuilderList ...*volume.Builder,
) *Builder {
	if volumeBuilderList == nil {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec: nil volumeBuilderList"),
		)
		return b
	}
	if len(volumeBuilderList) == 0 {
		b.errs = append(
			b.errs,
			errors.New("failed to build podtemplatespec: missing volumeBuilderList"),
		)
		return b
	}
	volList := []corev1.Volume{}
	for _, volumeBuilder := range volumeBuilderList {
		vol, err := volumeBuilder.Build()
		if err != nil {
			b.errs = append(
				b.errs,
				errors.Wrap(err, "failed to build podtemplatespec"),
			)
			return b
		}
		newvol := *vol
		volList = append(
			volList,
			newvol,
		)
	}
	b.podtemplatespec.Object.Spec.Volumes = volList
	return b
}