func validateConfigStorageClass(
	storageClassName *string,
	valErrors []string,
) []string {
	if storageClassName == nil {
		return valErrors
	}
	_, err := observer.GetStorageClass(*storageClassName)
	if err == nil {
		return valErrors
	}
	valErrors = append(
		valErrors,
		fmt.Sprintf(
			invalidStorageClass,
			*storageClassName,
		),
	)
	return valErrors
}
validateConfigStorageClass validates storageClassName by checking
for a valid storageClass k8s resource.
package validator
import (
	"encoding/json"
	"fmt"
	"github.com/bluek8s/kubedirector/pkg/secretkeys"
	"strings"
	"github.com/bluek8s/kubedirector/pkg/controller/kubedirectorconfig"
	"github.com/bluek8s/kubedirector/pkg/shared"
	kdv1 "github.com/bluek8s/kubedirector/pkg/apis/kubedirector/v1beta1"
	"github.com/bluek8s/kubedirector/pkg/observer"
	"k8s.io/api/admission/v1beta1"
	"k8s.io/apimachinery/pkg/api/equality"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/validation/field"
)
type configPatchSpec struct {
	Op    string           `json:"op"`
	Path  string           `json:"path"`
	Value configPatchValue `json:"value"`
}
type configPatchValue struct {
	ValueStr  *string
	ValueBool *bool
}
func (obj configPatchValue) MarshalJSON() ([]byte, error) {
	if obj.ValueStr != nil {
		return json.Marshal(obj.ValueStr)
	}
	if obj.ValueBool != nil {
		return json.Marshal(obj.ValueBool)
	}
	return json.Marshal(struct{}{})
}
func ensureConfigSpec(
	cr *kdv1.KubeDirectorConfig,
) []configPatchSpec {
	if cr.Spec != nil {
		return []configPatchSpec{}
	}
	cr.Spec = &kdv1.KubeDirectorConfigSpec{}
	return []configPatchSpec{
		{
			Op:   "add",
			Path: "/spec",
		},
	}
}