style: use direct type conversions in model converters
Replace struct literal copies with direct type conversions where the source and destination types have identical field layouts.
This commit is contained in:
parent
95a258ac32
commit
d7d1631e1c
1 changed files with 5 additions and 38 deletions
|
|
@ -391,12 +391,7 @@ func (c DockerContainer) ToFrontend() DockerContainerFrontend {
|
||||||
if len(c.Ports) > 0 {
|
if len(c.Ports) > 0 {
|
||||||
ports := make([]DockerContainerPortFrontend, len(c.Ports))
|
ports := make([]DockerContainerPortFrontend, len(c.Ports))
|
||||||
for i, port := range c.Ports {
|
for i, port := range c.Ports {
|
||||||
ports[i] = DockerContainerPortFrontend{
|
ports[i] = DockerContainerPortFrontend(port)
|
||||||
PrivatePort: port.PrivatePort,
|
|
||||||
PublicPort: port.PublicPort,
|
|
||||||
Protocol: port.Protocol,
|
|
||||||
IP: port.IP,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
container.Ports = ports
|
container.Ports = ports
|
||||||
}
|
}
|
||||||
|
|
@ -404,11 +399,7 @@ func (c DockerContainer) ToFrontend() DockerContainerFrontend {
|
||||||
if len(c.Networks) > 0 {
|
if len(c.Networks) > 0 {
|
||||||
networks := make([]DockerContainerNetworkFrontend, len(c.Networks))
|
networks := make([]DockerContainerNetworkFrontend, len(c.Networks))
|
||||||
for i, net := range c.Networks {
|
for i, net := range c.Networks {
|
||||||
networks[i] = DockerContainerNetworkFrontend{
|
networks[i] = DockerContainerNetworkFrontend(net)
|
||||||
Name: net.Name,
|
|
||||||
IPv4: net.IPv4,
|
|
||||||
IPv6: net.IPv6,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
container.Networks = networks
|
container.Networks = networks
|
||||||
}
|
}
|
||||||
|
|
@ -425,16 +416,7 @@ func (c DockerContainer) ToFrontend() DockerContainerFrontend {
|
||||||
if len(c.Mounts) > 0 {
|
if len(c.Mounts) > 0 {
|
||||||
mounts := make([]DockerContainerMountFrontend, len(c.Mounts))
|
mounts := make([]DockerContainerMountFrontend, len(c.Mounts))
|
||||||
for i, mount := range c.Mounts {
|
for i, mount := range c.Mounts {
|
||||||
mounts[i] = DockerContainerMountFrontend{
|
mounts[i] = DockerContainerMountFrontend(mount)
|
||||||
Type: mount.Type,
|
|
||||||
Source: mount.Source,
|
|
||||||
Destination: mount.Destination,
|
|
||||||
Mode: mount.Mode,
|
|
||||||
RW: mount.RW,
|
|
||||||
Propagation: mount.Propagation,
|
|
||||||
Name: mount.Name,
|
|
||||||
Driver: mount.Driver,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
container.Mounts = mounts
|
container.Mounts = mounts
|
||||||
}
|
}
|
||||||
|
|
@ -504,13 +486,7 @@ func (s DockerService) ToFrontend() DockerServiceFrontend {
|
||||||
|
|
||||||
// ToFrontend converts a DockerServicePort to DockerServicePortFrontend.
|
// ToFrontend converts a DockerServicePort to DockerServicePortFrontend.
|
||||||
func (p DockerServicePort) ToFrontend() DockerServicePortFrontend {
|
func (p DockerServicePort) ToFrontend() DockerServicePortFrontend {
|
||||||
return DockerServicePortFrontend{
|
return DockerServicePortFrontend(p)
|
||||||
Name: p.Name,
|
|
||||||
Protocol: p.Protocol,
|
|
||||||
TargetPort: p.TargetPort,
|
|
||||||
PublishedPort: p.PublishedPort,
|
|
||||||
PublishMode: p.PublishMode,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToFrontend converts a DockerServiceUpdate to DockerServiceUpdateFrontend.
|
// ToFrontend converts a DockerServiceUpdate to DockerServiceUpdateFrontend.
|
||||||
|
|
@ -565,16 +541,7 @@ func (t DockerTask) ToFrontend() DockerTaskFrontend {
|
||||||
|
|
||||||
// ToFrontend converts DockerSwarmInfo to DockerSwarmFrontend.
|
// ToFrontend converts DockerSwarmInfo to DockerSwarmFrontend.
|
||||||
func (s DockerSwarmInfo) ToFrontend() DockerSwarmFrontend {
|
func (s DockerSwarmInfo) ToFrontend() DockerSwarmFrontend {
|
||||||
return DockerSwarmFrontend{
|
return DockerSwarmFrontend(s)
|
||||||
NodeID: s.NodeID,
|
|
||||||
NodeRole: s.NodeRole,
|
|
||||||
LocalState: s.LocalState,
|
|
||||||
ControlAvailable: s.ControlAvailable,
|
|
||||||
ClusterID: s.ClusterID,
|
|
||||||
ClusterName: s.ClusterName,
|
|
||||||
Scope: s.Scope,
|
|
||||||
Error: s.Error,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostSensorSummaryToFrontend(src HostSensorSummary) *HostSensorSummaryFrontend {
|
func hostSensorSummaryToFrontend(src HostSensorSummary) *HostSensorSummaryFrontend {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue