func LoadConfig(t *testing.T, configBytes []byte) (cfg ProvisionerConfig) {
	err := yaml.Unmarshal(configBytes, &cfg)
	require.NoError(t, err, string(configBytes))
	switch cfg.CloudProvider {
	case constants.Azure:
		require.NotNil(t, cfg.Azure)
		cfg.dockerDevice = cfg.Azure.DockerDevice
		cfg.cloudRegions = newCloudRegions(strings.Split(cfg.Azure.Location, ","))
	case constants.AWS:
		require.NotNil(t, cfg.AWS)
		cfg.dockerDevice = cfg.AWS.DockerDevice
	case constants.GCE:
		require.NotNil(t, cfg.GCE)
		cfg.cloudRegions = newCloudRegions(strings.Split(cfg.GCE.Region, ","))
	case constants.Ops:
		require.NotNil(t, cfg.Ops)
		os.Setenv("AWS_ACCESS_KEY_ID", cfg.Ops.EC2AccessKey)
		os.Setenv("AWS_SECRET_ACCESS_KEY", cfg.Ops.EC2SecretKey)
		cfg.dockerDevice = "/var/lib/gravity"
	default:
		t.Fatalf("unknown cloud provider %s", cfg.CloudProvider)
	}
	return cfg
}
LoadConfig loads essential parameters from YAML
package gravity
import (
	"bytes"
	"fmt"
	"math/rand"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"testing"
	"github.com/gravitational/robotest/infra/providers/aws"
	"github.com/gravitational/robotest/infra/providers/azure"
	"github.com/gravitational/robotest/infra/providers/gce"
	"github.com/gravitational/robotest/infra/providers/ops"
	"github.com/gravitational/robotest/lib/constants"
	"github.com/gravitational/trace"
	"github.com/stretchr/testify/require"
	"gopkg.in/go-playground/validator.v9"
	"gopkg.in/yaml.v2"
)
type OS struct {
	Vendor, Version string
}
func (os *OS) UnmarshalText(b []byte) error {
	split := bytes.Split(b, []byte(":"))
	if len(split) != 2 {
		return trace.BadParameter("OS should be in format vendor:version, got %q", b)
	}
	os.Vendor = string(split[0])
	os.Version = string(split[1])
	return nil
}
func (os OS) String() string {
	return fmt.Sprintf("%s:%s", os.Vendor, os.Version)
}
type StorageDriver string
func (drv *StorageDriver) UnmarshalText(name []byte) error {
	switch string(name) {
	case constants.DeviceMapper, constants.Overlay, constants.Overlay2, constants.Loopback, constants.ManifestStorageDriver:
		*drv = StorageDriver(name)
		return nil
	default:
		return trace.BadParameter("unknown storage driver %s", name)
	}
}
func (drv StorageDriver) Driver() string {
	return string(drv)
}
type ProvisionerConfig struct {
	CloudProvider string `yaml:"cloud" validate:"required,eq=aws|eq=azure|eq=gce|eq=ops"`
	AWS *aws.Config `yaml:"aws"`
	Azure *azure.Config `yaml:"azure"`
	GCE *gce.Config `yaml:"gce"`
	Ops *ops.Config `yaml:"ops"`
	ScriptPath string `yaml:"script_path" validate:"required"`
	TerraformPluginDir string `yaml:"tf_plugin_dir"`
	InstallerURL string `yaml:"installer_url" validate:"required"`
	GravityURL string `yaml:"gravity_url" validate:"required"`
	StateDir string `yaml:"state_dir" validate:"required"`
	tag string `validate:"required"`
	NodeCount uint `validate:"gte=1"`
	os OS `validate:"required"`
	storageDriver StorageDriver
	dockerDevice string `validate:"required"`
	clusterName  string
	cloudRegions *cloudRegions
}