ocket8888 commented on code in PR #7660:
URL: https://github.com/apache/trafficcontrol/pull/7660#discussion_r1277043200
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -168,6 +168,44 @@ type DSServerBaseV4 struct {
DeliveryServiceCapabilities []string `json:"-"
db:"deliveryservice_capabilities"`
}
+// DSServerBaseV5 contains the base information for a Delivery Service Server
associated with APIv5.
+type DSServerBaseV5 struct {
Review Comment:
The reason we have a DSServerBase was to re-use a struct that shares many
details between v4 and earlier versions. You are only using DSServerBaseV5 in
exactly one place: the definition of DSServerV50. So it's completely
unnecessary.
##########
lib/go-tc/deliveryservice_servers.go:
##########
@@ -290,3 +346,48 @@ func (baseV4 DSServerBaseV4)
ToDSServerBase(routerHostName, routerPort, pDesc *s
dsServerBase.RouterPortName = routerPort
return dsServerBase
}
+
+// ToDSServerV5 convert DSServerV4 lastUpdated time format to RFC3339 for
DSServerV5
+// and also assign V4 values to V5
+func ToDSServerV5(serverList []DSServerV4) []DSServerV5 {
+ updatedServerList := make([]DSServerV5, len(serverList))
+
+ for i, server := range serverList {
+ r := time.Unix(server.LastUpdated.Unix(), 0)
+ updatedServerList[i].LastUpdated = &r
+ updatedServerList[i].Cachegroup = server.Cachegroup
+ updatedServerList[i].CachegroupID = server.CachegroupID
+ updatedServerList[i].CDNID = server.CDNID
+ updatedServerList[i].CDNName = server.CDNName
+ updatedServerList[i].DeliveryServices = server.DeliveryServices
+ updatedServerList[i].DomainName = server.DomainName
+ updatedServerList[i].FQDN = server.FQDN
+ updatedServerList[i].FqdnTime = server.FqdnTime
+ updatedServerList[i].GUID = server.GUID
+ updatedServerList[i].HostName = server.HostName
+ updatedServerList[i].HTTPSPort = server.HTTPSPort
+ updatedServerList[i].ID = server.ID
+ updatedServerList[i].ILOIPAddress = server.ILOIPAddress
+ updatedServerList[i].ILOIPGateway = server.ILOIPGateway
+ updatedServerList[i].ILOIPNetmask = server.ILOIPNetmask
+ updatedServerList[i].ILOPassword = server.ILOPassword
+ updatedServerList[i].ILOUsername = server.ILOUsername
+ updatedServerList[i].MgmtIPAddress = server.MgmtIPAddress
+ updatedServerList[i].MgmtIPGateway = server.MgmtIPGateway
+ updatedServerList[i].MgmtIPNetmask = server.MgmtIPNetmask
+ updatedServerList[i].OfflineReason = server.OfflineReason
+ updatedServerList[i].PhysLocation = server.PhysLocation
+ updatedServerList[i].PhysLocationID = server.PhysLocationID
+ updatedServerList[i].ProfileNames = server.ProfileNames
+ updatedServerList[i].Rack = server.Rack
+ updatedServerList[i].Status = server.Status
+ updatedServerList[i].StatusID = server.StatusID
+ updatedServerList[i].TCPPort = server.TCPPort
+ updatedServerList[i].Type = server.Type
+ updatedServerList[i].TypeID = server.TypeID
+ updatedServerList[i].UpdPending = server.UpdPending
+ updatedServerList[i].ServerCapabilities =
server.ServerCapabilities
+ updatedServerList[i].DeliveryServiceCapabilities =
server.DeliveryServiceCapabilities
+ }
+ return updatedServerList
+}
Review Comment:
This is missing (at least) network interface information.
IMO, it would much better to simply wrap a `ServerV50` to add the list of
`DeliveryServices` (and DS Capabilities?) and then you can upgrade the server
part by just calling `ServerV4.Upgrade` - which has test coverage that assures
you that you haven't missed anything - and just making this a method on
`DSServerV4` instead of trying to update a slice of those.
--
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]