Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpappa200 committed Sep 13, 2023
1 parent c9005a5 commit 963d19d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cache-config/t3c-generate/cfgfile/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func GetAllConfigs(
toData *t3cutil.ConfigData,
cfg config.Cfg,
) ([]t3cutil.ATSConfigFile, error) {
if &toData.Server.HostName == nil || toData.Server.HostName == "" {
if toData.Server.HostName == "" {
return nil, errors.New("server hostname is nil")
}
// if 0 get dataconfig.go was unable to get DS capabilities using APIv5
Expand Down
2 changes: 1 addition & 1 deletion lib/go-atscfg/headerrewritedotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func MakeHeaderRewriteDotConfig(
if ids.Active == tc.DSActiveStateInactive {
continue
}
if &ids.XMLID == nil || ids.XMLID == "" {
if ids.XMLID == "" {
warnings = append(warnings, "deliveryServices had DS with nil xmlId (name)")
continue
}
Expand Down
4 changes: 2 additions & 2 deletions lib/go-atscfg/hostingdotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func MakeHostingDotConfig(

filteredDSes := []DeliveryService{}
for _, ds := range deliveryServices {
if &ds.Active == nil || ds.Active == "" || ds.Type == nil || &ds.XMLID == nil || &ds.CDNID == nil || ds.ID == nil || ds.OrgServerFQDN == nil {
if ds.Active == "" || ds.Type == nil || ds.XMLID == "" || ds.CDNID == 0 || ds.ID == nil || ds.OrgServerFQDN == nil {
// some DSes have nil origins. I think MSO? TODO: verify
continue
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func MakeHostingDotConfig(

seenOrigins := map[string]struct{}{}
for _, ds := range filteredDSes {
if ds.OrgServerFQDN == nil || &ds.XMLID == nil || &ds.Active == nil {
if ds.OrgServerFQDN == nil || ds.XMLID == "" || ds.Active == "" {
warnings = append(warnings, "got DS with nil values, skipping!")
continue
}
Expand Down
10 changes: 5 additions & 5 deletions lib/go-atscfg/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func addMetaObjConfigDir(
nameTopologies := makeTopologyNameMap(topologies)

for _, ds := range dses {
if &ds.XMLID == nil {
if ds.XMLID == "" {
warnings = append(warnings, "got Delivery Service with nil XMLID - not considering!")
continue
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func getURISignedDSes(dses map[tc.DeliveryServiceName]DeliveryService) ([]tc.Del
warnings = append(warnings, "got delivery service with no id, skipping!")
continue
}
if &ds.XMLID == nil {
if ds.XMLID == "" {
warnings = append(warnings, "got delivery service with no xmlId (name), skipping!")
continue
}
Expand Down Expand Up @@ -359,7 +359,7 @@ func filterConfigFileDSes(server *Server, deliveryServices []DeliveryService, de
warnings = append(warnings, "got deliveryservice with nil id, skipping!")
continue
}
if &ds.XMLID == nil {
if ds.XMLID == "" {
warnings = append(warnings, "got deliveryservice with nil xmlId (name), skipping!")
continue
}
Expand All @@ -374,11 +374,11 @@ func filterConfigFileDSes(server *Server, deliveryServices []DeliveryService, de
warnings = append(warnings, "got deliveryservice with nil id, skipping!")
continue
}
if &ds.XMLID == nil {
if ds.XMLID == "" {
warnings = append(warnings, "got deliveryservice with nil xmlId (name), skipping!")
continue
}
if &ds.CDNID == nil || ds.CDNID != server.CDNID {
if ds.CDNID != server.CDNID {
continue
}
if ds.Active == tc.DSActiveStateInactive {
Expand Down
4 changes: 2 additions & 2 deletions lib/go-atscfg/parentdotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,10 @@ type dsesSortByName []DeliveryService
func (s dsesSortByName) Len() int { return len(s) }
func (s dsesSortByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s dsesSortByName) Less(i, j int) bool {
if &s[i].XMLID == nil || s[i].XMLID == "" {
if s[i].XMLID == "" {
return true
}
if &s[j].XMLID == nil || s[j].XMLID == "" {
if s[j].XMLID == "" {
return false
}
return s[i].XMLID < s[j].XMLID
Expand Down
2 changes: 1 addition & 1 deletion lib/go-atscfg/regexremapdotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func deliveryServicesToCDNDSes(dses []DeliveryService) (map[tc.DeliveryServiceNa
warnings := []string{}
sDSes := map[tc.DeliveryServiceName]cdnDS{}
for _, ds := range dses {
if ds.OrgServerFQDN == nil || ds.QStringIgnore == nil || &ds.XMLID == nil {
if ds.OrgServerFQDN == nil || ds.QStringIgnore == nil || ds.XMLID == "" {
if &ds.XMLID == nil {
warnings = append(warnings, "got unknown DS with nil values! Skipping!")
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/go-atscfg/regexrevalidatedotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func MakeRegexRevalidateDotConfig(

dsNames := map[string]struct{}{}
for _, ds := range deliveryServices {
if &ds.XMLID == nil {
if ds.XMLID == "" {
warnings = append(warnings, "got Delivery Service from Traffic Ops with a nil xmlId! Skipping!")
continue
}
Expand Down
12 changes: 6 additions & 6 deletions lib/go-atscfg/remapdotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func getServerConfigRemapDotConfigForMid(
}
}

if !tc.DSType(*ds.Type).UsesMidCache() && (!hasTopology || *ds.Topology == "") {
if ds.Type != nil && !tc.DSType(*ds.Type).UsesMidCache() && (!hasTopology || *ds.Topology == "") {
continue // Live local delivery services skip mids (except Topologies ignore DS types)
}

Expand Down Expand Up @@ -984,19 +984,19 @@ func remapFilterDSes(server *Server, dss []DeliveryServiceServer, dses []Deliver
if ds.LastHeaderRewrite == nil {
ds.LastHeaderRewrite = util.StrPtr("")
}
if &ds.XMLID == nil {
if ds.XMLID == "" {
warnings = append(warnings, "got Delivery Service with nil XMLID, skipping!")
continue
} else if ds.Type == nil {
warnings = append(warnings, "got Delivery Service '"+ds.XMLID+"' with nil Type, skipping!")
continue
} else if &ds.DSCP == nil {
} else if ds.DSCP == 0 {
warnings = append(warnings, "got Delivery Service '"+ds.XMLID+"' with nil DSCP, skipping!")
continue
} else if ds.ID == nil {
warnings = append(warnings, "got Delivery Service '"+ds.XMLID+"' with nil ID, skipping!")
continue
} else if &ds.Active == nil {
} else if ds.Active == "" {
warnings = append(warnings, "got Delivery Service '"+ds.XMLID+"' with nil Active, skipping!")
continue
} else if _, ok := dssMap[*ds.ID]; !ok && *ds.Topology == "" {
Expand Down Expand Up @@ -1161,8 +1161,8 @@ func makeFQDN(hostRegex string, ds *DeliveryService, server string, cdnDomain st
re = strings.Replace(re, `.*`, ``, -1)

hName := server
if tc.DSType(*ds.Type).IsDNS() {
if &ds.RoutingName == nil || ds.RoutingName == "" {
if ds.Type != nil && tc.DSType(*ds.Type).IsDNS() {
if ds.RoutingName == "" {
return "", errors.New("ds is dns, but missing routing name")
}
hName = ds.RoutingName
Expand Down
2 changes: 1 addition & 1 deletion lib/go-atscfg/servercachedotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func makeCacheDotConfigMid(

dses := map[tc.DeliveryServiceName]serverCacheConfigDS{}
for _, ds := range deliveryServices {
if &ds.XMLID == nil || &ds.Active == nil || ds.OrgServerFQDN == nil || ds.Type == nil {
if ds.XMLID == "" || ds.Active == "" || ds.OrgServerFQDN == nil || ds.Type == nil {
// TODO orgserverfqdn is nil for some DSes - MSO? Verify.
continue
// return "", fmt.Errorf("getting delivery services: got DS with nil values! '%v' %v %+v\n", *ds.XMLID, *ds.ID, ds)
Expand Down
2 changes: 1 addition & 1 deletion lib/go-atscfg/sslservernamedotyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func dsUsesServer(
serverCapabilities map[int]map[ServerCapability]struct{},
dsRequiredCapabilities map[int]map[ServerCapability]struct{},
) (bool, error) {
if &ds.XMLID == nil || ds.XMLID == "" {
if ds.XMLID == "" {
return false, errors.New("ds missing xmlId")
} else if ds.ID == nil {
return false, errors.New("ds missing id")
Expand Down
2 changes: 1 addition & 1 deletion lib/go-tc/totest/deliveryservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

func CreateTestDeliveryServices(t *testing.T, cl *toclient.Session, td TrafficControl) {
for _, ds := range td.DeliveryServices {
if &ds.XMLID == nil {
if ds.XMLID == "" {
t.Error("Found a Delivery Service in testing data with null or undefined XMLID")
continue
}
Expand Down

0 comments on commit 963d19d

Please sign in to comment.