package e2e

import (
	. "github.com/onsi/gomega"
	"github.com/unknwon/goconfig" // nolint:misspell
)

type Config struct {
	AWS AWSConfig
	GCP GCPConfig
}

type AWSConfig struct {
	Region       string
	InstanceType string
	VPCID        string
	VPCCIDR      string
	AccountID    string

	AnotherRegion        string
	AnotherRegionVPCID   string
	AnotherRegionVPCCIDR string

	ImportSQLS3URL           string
	ImportNoPlicyS3URL       string
	ImportAnotherRegionS3URL string
}

type GCPConfig struct {
	Region       string
	InstanceType string
	ProjectID    string
	NetworkName  string

	AnotherRegion            string
	AnotherRegionNetworkName string
}

func InitialConfig() *Config {
	var e2eConfig Config
	config, err := goconfig.LoadConfigFile("./conf/e2e.conf")
	Expect(err).Should(BeNil())

	e2eConfig.AWS.Region, _ = config.GetValue("aws", "region")
	e2eConfig.AWS.InstanceType, _ = config.GetValue("aws", "instance_type")
	e2eConfig.AWS.AccountID, _ = config.GetValue("aws", "account_id")
	e2eConfig.AWS.VPCID, _ = config.GetValue("aws", "vpc_id")
	e2eConfig.AWS.VPCCIDR, _ = config.GetValue("aws", "vpc_cidr")

	e2eConfig.AWS.AnotherRegion, _ = config.GetValue("aws", "another_region")
	e2eConfig.AWS.AnotherRegionVPCID, _ = config.GetValue("aws", "another_region_vpc_id")
	e2eConfig.AWS.AnotherRegionVPCCIDR, _ = config.GetValue("aws", "another_region_vpc_cidr")

	e2eConfig.AWS.ImportSQLS3URL, _ = config.GetValue("aws", "sql_S3_URL")
	e2eConfig.AWS.ImportNoPlicyS3URL, _ = config.GetValue("aws", "noPolicy_S3_URL")
	e2eConfig.AWS.ImportAnotherRegionS3URL, _ = config.GetValue("aws", "another_region_S3_URL")

	e2eConfig.GCP.Region, _ = config.GetValue("gcp", "region")
	e2eConfig.GCP.InstanceType, _ = config.GetValue("gcp", "instance_type")
	e2eConfig.GCP.ProjectID, _ = config.GetValue("gcp", "project_id")
	e2eConfig.GCP.NetworkName, _ = config.GetValue("gcp", "network_name")

	e2eConfig.GCP.AnotherRegion, _ = config.GetValue("gcp", "another_region")
	e2eConfig.GCP.AnotherRegionNetworkName, _ = config.GetValue("gcp", "another_region_network_name")
	return &e2eConfig
}
