func ValidateBasicFields()

in helpers/foundation-deployer/stages/validate.go [46:93]


func ValidateBasicFields(t testing.TB, g GlobalTFVars) {
	gcpConf := gcp.NewGCP()
	fmt.Println("")
	fmt.Println("# Validating tfvar file.")
	if g.OrgID != replaceME {
		if g.HasValidatorProj() && gcpConf.HasSccNotification(t, g.OrgID, g.SccNotificationName) {
			fmt.Printf("# Notification '%s' exists in organization '%s'. Chose a different one.\n", g.SccNotificationName, g.OrgID)
			fmt.Printf("# See existing Notifications for organization '%s'.\n", g.OrgID)
			fmt.Printf("# gcloud scc notifications list organizations/%s --filter=\"name:organizations/%s/notificationConfigs/%s\" --format=\"value(name)\"\n", g.OrgID, g.OrgID, g.SccNotificationName)
			fmt.Println("")
		}
		if g.HasValidatorProj() && !g.CreateUniqueTagKey && gcpConf.HasTagKey(t, g.OrgID, "environment") {
			fmt.Printf("# Tag key 'environment' exists in organization '%s'.\n", g.OrgID)
			fmt.Println("# Set variable 'create_unique_tag_key' to 'true' in the tfvar file.")
			fmt.Println("")
		}
	}

	g.CheckString(replaceME)

	if strings.Contains(g.Domain, exampleDotCom) {
		fmt.Println("# Replace value 'example.com' for input 'domain'")
	}
	if g.Domain != "" && g.Domain[len(g.Domain)-1:] != "." {
		fmt.Println("# Value for input 'domain' must end with '.'")
	}
	for _, d := range g.DomainsToAllow {
		if strings.Contains(d, exampleDotCom) {
			fmt.Println("# Replace value 'example.com' for input 'domains_to_allow'")
		}
	}
	for _, e := range g.EssentialContactsDomains {
		if strings.Contains(e, exampleDotCom) {
			fmt.Println("# Replace value 'example.com' for input 'essential_contacts_domains_to_allow'")
		}
		if e != "" && e[0:1] != "@" {
			fmt.Printf("# Essential contacts must start with '@': '%s'\n", e)
		}
	}
	for _, p := range g.PerimeterAdditionalMembers {
		if strings.Contains(p, exampleDotCom) {
			fmt.Printf("# Replace value for input 'perimeter_additional_members': '%s'\n", p)
		}
		if strings.Contains(p, "group:") {
			fmt.Printf("# VPC Service Controls does not allow groups in the perimeter: '%s'\n", p)
		}
	}
}