Fix omitempty issue for ATS config metadata generation (#4306) (#4313)

If empty, the 'url' and 'apiUri' fields should be omitted from the
marshalled JSON, which is how Perl handled it.

(cherry picked from commit 5f3c3f26f1fe8309bf83e8397937ffc442cf1b21)
diff --git a/lib/go-atscfg/meta_test.go b/lib/go-atscfg/meta_test.go
index 5317220..dbd7b52 100644
--- a/lib/go-atscfg/meta_test.go
+++ b/lib/go-atscfg/meta_test.go
@@ -109,6 +109,11 @@
 			FileNameOnDisk: "custom.config",
 			Location:       "/my/location/",
 		},
+		"external.config": ConfigProfileParams{
+			FileNameOnDisk: "external.config",
+			Location:       "/my/location/",
+			URL:            "http://myurl/remap.config",
+		},
 	}
 	uriSignedDSes := []tc.DeliveryServiceName{"mydsname"}
 	dses := map[tc.DeliveryServiceName]struct{}{"mydsname": {}}
@@ -233,6 +238,14 @@
 				t.Errorf("expected scope '%v', actual '%v'", expected, cf.Scope)
 			}
 		},
+		"external.config": func(cf tc.ATSConfigMetaDataConfigFile) {
+			if expected := "/my/location/"; cf.Location != expected {
+				t.Errorf("expected location '%v', actual '%v'", expected, cf.Location)
+			}
+			if expected := string(tc.ATSConfigMetaDataConfigFileScopeCDNs); cf.Scope != expected {
+				t.Errorf("expected scope '%v', actual '%v'", expected, cf.Scope)
+			}
+		},
 	}
 
 	for _, cfgFile := range cfg.ConfigFiles {
@@ -262,4 +275,22 @@
 	if strings.Contains(txt, "nonexistentds") {
 		t.Errorf("expected location parameters for nonexistent delivery services to not be added to config, actual '%v'", txt)
 	}
+
+	// check for expected apiUri vs url keys (if values are empty strings, they should be omitted from the json)
+	m := map[string]interface{}{}
+	if err := json.Unmarshal([]byte(txt), &m); err != nil {
+		t.Fatalf("MakeMetaConfig returned invalid JSON: " + err.Error())
+	}
+	cfl := m["configFiles"].([]interface{})
+	for _, cf := range cfl {
+		c := cf.(map[string]interface{})
+		if c["fnameOnDisk"] == "external.config" {
+			if _, exists := c["apiUri"]; exists {
+				t.Errorf("expected: apiUri field to be omitted for external.config, actual: present")
+			}
+			if _, exists := c["url"]; !exists {
+				t.Errorf("expected: url field to be present for external.config, actual: omitted")
+			}
+		}
+	}
 }
diff --git a/lib/go-tc/ats.go b/lib/go-tc/ats.go
index 106c048..c7af337 100644
--- a/lib/go-tc/ats.go
+++ b/lib/go-tc/ats.go
@@ -44,8 +44,8 @@
 type ATSConfigMetaDataConfigFile struct {
 	FileNameOnDisk string `json:"fnameOnDisk"`
 	Location       string `json:"location"`
-	APIURI         string `json:"apiUri, omitempty"`
-	URL            string `json:"url, omitempty"`
+	APIURI         string `json:"apiUri,omitempty"`
+	URL            string `json:"url,omitempty"`
 	Scope          string `json:"scope"`
 }