mhoppa commented on a change in pull request #4015: Rewrite /federations to Go 
- POST/PUT/DELETE
URL: https://github.com/apache/trafficcontrol/pull/4015#discussion_r339566176
 
 

 ##########
 File path: lib/go-tc/federation.go
 ##########
 @@ -67,36 +80,85 @@ type FederationMapping struct {
        TTL   int    `json:"ttl"`
 }
 
-// AllFederation is the JSON object returned by /api/1.x/federations?all
-type AllFederation struct {
-       Mappings        []AllFederationMapping `json:"mappings"`
-       DeliveryService DeliveryServiceName    `json:"deliveryService"`
+// AllDeliveryServiceFederationsMapping is a structure that contains 
identifying information for a
+// Delivery Service as well as any and all Federation Resolver mapping 
assigned to it (or all those
+// getting assigned to it).
+type AllDeliveryServiceFederationsMapping struct {
+       Mappings        []FederationResolverMapping `json:"mappings"`
+       DeliveryService DeliveryServiceName         `json:"deliveryService"`
 }
 
-func (a AllFederation) IsAllFederations() bool { return true }
+// IsAllFederations implements the IAllFederation interface. Always returns 
true.
+func (a AllDeliveryServiceFederationsMapping) IsAllFederations() bool { return 
true }
 
 // AllFederation is the JSON object returned by 
/api/1.x/federations?all&cdnName=my-cdn-name
 type AllFederationCDN struct {
        CDNName *CDNName `json:"cdnName"`
 }
 
+// IsAllFederations implements the IAllFederation interface. Always returns 
true.
 func (a AllFederationCDN) IsAllFederations() bool { return true }
 
-type AllFederationMapping struct {
-       TTL      *int     `json:"ttl"`
-       CName    *string  `json:"cname"`
+type ResolverMapping struct {
        Resolve4 []string `json:"resolve4,omitempty"`
        Resolve6 []string `json:"resolve6,omitempty"`
 }
 
+func (r *ResolverMapping) Validate(tx *sql.Tx) error {
+       errs := []error{}
+       for _, res := range r.Resolve4 {
 
 Review comment:
   This looks good but anyway we could leverage 
https://github.com/go-ozzo/ozzo-validation#built-in-validation-rules to 
accomplish this? I see they have validation for ipv4/ipv6.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to