func (spec *VaultSpec) GetHAStorage() map[string]interface{} {
	haStorage := spec.getHAStorage()
	return cast.ToStringMap(haStorage[spec.GetHAStorageType()])
}
GetHAStorage returns Vault's ha_storage stanza
package v1alpha1
import (
	"encoding/json"
	"errors"
	"fmt"
	"os"
	"reflect"
	"sort"
	"strings"
	"time"
	"github.com/Masterminds/semver/v3"
	"github.com/coreos/etcd-operator/pkg/util/etcdutil"
	"github.com/imdario/mergo"
	"github.com/spf13/cast"
	v1 "k8s.io/api/core/v1"
	netv1 "k8s.io/api/networking/v1"
	extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/utils/pointer"
	ctrl "sigs.k8s.io/controller-runtime"
)
var log = ctrl.Log.WithName("controller_vault")
var bankVaultsImage string
func init() {
	if bankVaultsImage = os.Getenv("BANK_VAULTS_IMAGE"); bankVaultsImage == "" {
		bankVaultsImage = "ghcr.io/banzaicloud/bank-vaults:latest"
	}
}
type Vault struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec   VaultSpec   `json:"spec,omitempty"`
	Status VaultStatus `json:"status,omitempty"`
}
type VaultList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Vault `json:"items"`
}
type VaultSpec struct {
	Size int32 `json:"size,omitempty"`
	Image string `json:"image,omitempty"`
	BankVaultsImage string `json:"bankVaultsImage,omitempty"`
	BankVaultsVolumeMounts []v1.VolumeMount `json:"bankVaultsVolumeMounts,omitempty"`
	StatsDDisabled bool `json:"statsdDisabled,omitempty"`
	StatsDImage string `json:"statsdImage,omitempty"`
	FluentDEnabled bool `json:"fluentdEnabled,omitempty"`
	FluentDImage string `json:"fluentdImage,omitempty"`
	FleuntDConfLocation string `json:"fleuntdConfLocation,omitempty"`
	FluentDConfig string `json:"fluentdConfig,omitempty"`
	WatchedSecretsLabels []map[string]string `json:"watchedSecretsLabels,omitempty"`
	WatchedSecretsAnnotations []map[string]string `json:"watchedSecretsAnnotations,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	VaultAnnotations map[string]string `json:"vaultAnnotations,omitempty"`
	VaultLabels map[string]string `json:"vaultLabels,omitempty"`
	VaultPodSpec *EmbeddedPodSpec `json:"vaultPodSpec,omitempty"`
	VaultContainerSpec v1.Container `json:"vaultContainerSpec,omitempty"`
	VaultConfigurerAnnotations map[string]string `json:"vaultConfigurerAnnotations,omitempty"`
	VaultConfigurerLabels map[string]string `json:"vaultConfigurerLabels,omitempty"`
	VaultConfigurerPodSpec *EmbeddedPodSpec `json:"vaultConfigurerPodSpec,omitempty"`
	Config extv1beta1.JSON `json:"config"`
	ExternalConfig extv1beta1.JSON `json:"externalConfig,omitempty"`
	UnsealConfig UnsealConfig `json:"unsealConfig,omitempty"`
	CredentialsConfig CredentialsConfig `json:"credentialsConfig,omitempty"`
	EnvsConfig []v1.EnvVar `json:"envsConfig,omitempty"`
	SecurityContext v1.PodSecurityContext `json:"securityContext,omitempty"`
	EtcdVersion string `json:"etcdVersion,omitempty"`
	EtcdSize int `json:"etcdSize,omitempty"`
	EtcdRepository string `json:"etcdRepository,omitempty"`
	EtcdPodBusyBoxImage string `json:"etcdPodBusyBoxImage,omitempty"`
	EtcdAnnotations map[string]string `json:"etcdAnnotations,omitempty"`
	EtcdPodAnnotations map[string]string `json:"etcdPodAnnotations,omitempty"`
	EtcdPVCSpec *v1.PersistentVolumeClaimSpec `json:"etcdPVCSpec,omitempty"`
	EtcdAffinity *v1.Affinity `json:"etcdAffinity,omitempty"`
	ServiceType string `json:"serviceType,omitempty"`
	LoadBalancerIP string `json:"loadBalancerIP,omitempty"`
	ServiceRegistrationEnabled bool `json:"serviceRegistrationEnabled,omitempty"`
	RaftLeaderAddress string `json:"raftLeaderAddress,omitempty"`
	ServicePorts map[string]int32 `json:"servicePorts,omitempty"`
	Affinity *v1.Affinity `json:"affinity,omitempty"`
	PodAntiAffinity string `json:"podAntiAffinity,omitempty"`
	NodeAffinity v1.NodeAffinity `json:"nodeAffinity,omitempty"`
	NodeSelector map[string]string `json:"nodeSelector,omitempty"`
	Tolerations []v1.Toleration `json:"tolerations,omitempty"`
	ServiceAccount string `json:"serviceAccount,omitempty"`
	Volumes []v1.Volume `json:"volumes,omitempty"`
	VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
	VolumeClaimTemplates []EmbeddedPersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"`
	VaultEnvsConfig []v1.EnvVar `json:"vaultEnvsConfig,omitempty"`
	SidecarEnvsConfig []v1.EnvVar `json:"sidecarEnvsConfig,omitempty"`
	Resources *Resources `json:"resources,omitempty"`
	Ingress *Ingress `json:"ingress,omitempty"`
	ServiceMonitorEnabled bool `json:"serviceMonitorEnabled,omitempty"`
	ExistingTLSSecretName string `json:"existingTlsSecretName,omitempty"`
	TLSExpiryThreshold string `json:"tlsExpiryThreshold,omitempty"`
	TLSAdditionalHosts []string `json:"tlsAdditionalHosts,omitempty"`
	CANamespaces []string `json:"caNamespaces,omitempty"`
	IstioEnabled bool `json:"istioEnabled,omitempty"`
	VeleroEnabled bool `json:"veleroEnabled,omitempty"`
	VeleroFsfreezeImage string `json:"veleroFsfreezeImage,omitempty"`
	VaultInitContainers []v1.Container `json:"vaultInitContainers,omitempty"`
}
var HAStorageTypes = map[string]bool{
	"consul":     true,
	"dynamodb":   true,
	"etcd":       true,
	"gcs":        true,
	"mysql":      true,
	"postgresql": true,
	"raft":       true,
	"spanner":    true,
	"zookeeper":  true,
}
func (spec *VaultSpec) HasHAStorage() bool {
	storageType := spec.GetStorageType()
	if _, ok := HAStorageTypes[storageType]; ok {
		if spec.HasStorageHAEnabled() {
			return true
		}
	}
	if spec.hasHAStorageStanza() {
		return true
	}
	return false
}
func (spec *VaultSpec) hasHAStorageStanza() bool {
	return len(spec.getHAStorage()) != 0
}
func (spec *VaultSpec) HasEtcdStorage() bool {
	if spec.hasHAStorageStanza() && spec.GetHAStorageType() == "etcd" {
		return true
	}
	return spec.GetStorageType() == "etcd"
}
func (spec *VaultSpec) GetStorage() map[string]interface{} {
	storage := spec.getStorage()
	return cast.ToStringMap(storage[spec.GetStorageType()])
}
func (spec *VaultSpec) getStorage() map[string]interface{} {
	config := spec.GetVaultConfig()
	return cast.ToStringMap(config["storage"])
}