ocket8888 commented on code in PR #7795:
URL: https://github.com/apache/trafficcontrol/pull/7795#discussion_r1322242574


##########
infrastructure/cdn-in-a-box/enroller/enroller.go:
##########
@@ -318,10 +318,10 @@ func enrollDeliveryServiceServer(toSession *session, r 
io.Reader) error {
                if len(servers.Response) == 0 {
                        return errors.New("no server with hostName " + sn)
                }
-               if servers.Response[0].ID == nil {
-                       return fmt.Errorf("Traffic Ops gave back a 
representation for server '%s' with null or undefined ID", sn)
+               if servers.Response[0].ID < 1 {
+                       return fmt.Errorf("Traffic Ops gave back a 
representation for server '%s' with non-positive ID", sn)

Review Comment:
   I think you should just get rid of this check instead of "fixing" it. It's 
not actually stated anywhere that all of our IDs will always be positive 
numbers, that's an implementation detail of an implementation detail. Clients 
needn't be expected to handle that.
   
   Besides, the purpose of the check was to prevent a segmentation fault later 
during dereference, not to double-check that data received is valid.



##########
infrastructure/cdn-in-a-box/enroller/enroller.go:
##########
@@ -361,21 +361,21 @@ func enrollDivision(toSession *session, r io.Reader) 
error {
 
 func enrollOrigin(toSession *session, r io.Reader) error {
        dec := json.NewDecoder(r)
-       var s tc.Origin
+       var s tc.OriginV5
        err := dec.Decode(&s)
        if err != nil {
                log.Infof("error decoding Origin: %v", err)
                return err
        }
-       if s.Name == nil {
+       if s.Name == "" {

Review Comment:
   same as above, but with less gusto



##########
infrastructure/cdn-in-a-box/enroller/enroller.go:
##########
@@ -827,7 +827,7 @@ func enrollFederation(toSession *session, r io.Reader) 
error {
                                return err
                        }
                        deliveryService := deliveryServices.Response[0]
-                       if deliveryService.CDNName == nil || deliveryService.ID 
== nil || deliveryService.XMLID == nil {
+                       if deliveryService.CDNName == nil || deliveryService.ID 
== nil || deliveryService.XMLID == "" {

Review Comment:
   same as directly above



##########
infrastructure/cdn-in-a-box/enroller/Dockerfile:
##########
@@ -40,6 +40,7 @@ COPY ./go.mod ./go.sum 
/go/src/github.com/apache/trafficcontrol/
 COPY ./vendor/ /go/src/github.com/apache/trafficcontrol/vendor/
 COPY ./traffic_ops/toclientlib/ 
/go/src/github.com/apache/trafficcontrol/traffic_ops/toclientlib/
 COPY ./traffic_ops/v4-client/ 
/go/src/github.com/apache/trafficcontrol/traffic_ops/v4-client/

Review Comment:
   do we still need the v4 client for something?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to