Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify making copy #2520

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions info/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,41 +217,7 @@ type MachineInfo struct {
}

func (m *MachineInfo) Clone() *MachineInfo {
memoryByType := m.MemoryByType
if len(m.MemoryByType) > 0 {
memoryByType = make(map[string]*MemoryInfo)
for memoryType, memoryInfo := range m.MemoryByType {
memoryByType[memoryType] = memoryInfo
}
}
diskMap := m.DiskMap
if len(m.DiskMap) > 0 {
diskMap = make(map[string]DiskInfo)
for k, info := range m.DiskMap {
diskMap[k] = info
}
}
copy := MachineInfo{
Timestamp: m.Timestamp,
NumCores: m.NumCores,
NumPhysicalCores: m.NumPhysicalCores,
NumSockets: m.NumSockets,
CpuFrequency: m.CpuFrequency,
MemoryCapacity: m.MemoryCapacity,
MemoryByType: memoryByType,
NVMInfo: m.NVMInfo,
HugePages: m.HugePages,
MachineID: m.MachineID,
SystemUUID: m.SystemUUID,
BootID: m.BootID,
Filesystems: m.Filesystems,
DiskMap: diskMap,
NetworkDevices: m.NetworkDevices,
Topology: m.Topology,
CloudProvider: m.CloudProvider,
InstanceType: m.InstanceType,
InstanceID: m.InstanceID,
}
copy := *m
return &copy
}

Expand Down
9 changes: 1 addition & 8 deletions manager/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,7 @@ func (cd *containerData) GetInfo(shouldUpdateSubcontainers bool) (*containerInfo
}
cd.lock.Lock()
defer cd.lock.Unlock()
cInfo := containerInfo{
Subcontainers: cd.info.Subcontainers,
Spec: cd.info.Spec,
}
cInfo.Id = cd.info.Id
cInfo.Name = cd.info.Name
cInfo.Aliases = cd.info.Aliases
cInfo.Namespace = cd.info.Namespace
cInfo := cd.info
return &cInfo, nil
}

Expand Down