feat: improve naming

I fixed naming to recommended by Golang.
This commit is contained in:
sivchari 2022-07-24 19:04:08 +09:00
parent 27110bd821
commit 5494b30ce5
7 changed files with 14 additions and 14 deletions

View File

@ -50,7 +50,7 @@ type endpointImpl struct {
// This is to be used during normal device plugin registration.
func newEndpointImpl(p plugin.DevicePlugin) *endpointImpl {
return &endpointImpl{
api: p.Api(),
api: p.API(),
resourceName: p.Resource(),
}
}

View File

@ -203,7 +203,7 @@ func (m *ManagerImpl) CleanupPluginDirectory(dir string) error {
}
func (m *ManagerImpl) PluginConnected(resourceName string, p plugin.DevicePlugin) error {
options, err := p.Api().GetDevicePluginOptions(context.Background(), &pluginapi.Empty{})
options, err := p.API().GetDevicePluginOptions(context.Background(), &pluginapi.Empty{})
if err != nil {
return fmt.Errorf("failed to get device plugin options: %v", err)
}

View File

@ -30,7 +30,7 @@ import (
)
type DevicePlugin interface {
Api() api.DevicePluginClient
API() api.DevicePluginClient
Resource() string
SocketPath() string
}
@ -104,7 +104,7 @@ func (c *client) Resource() string {
return c.resource
}
func (c *client) Api() api.DevicePluginClient {
func (c *client) API() api.DevicePluginClient {
return c.client
}

View File

@ -343,11 +343,11 @@ func (pdev *podDevices) getContainerDevices(podUID, contName string) ResourceDev
}
devicePluginMap := make(map[string]pluginapi.Device)
for numaid, devlist := range allocateInfo.deviceIds {
for _, devId := range devlist {
for _, devID := range devlist {
var topology *pluginapi.TopologyInfo
if numaid != nodeWithoutTopology {
NUMANodes := []*pluginapi.NUMANode{{ID: numaid}}
if pDev, ok := devicePluginMap[devId]; ok && pDev.Topology != nil {
if pDev, ok := devicePluginMap[devID]; ok && pDev.Topology != nil {
if nodes := pDev.Topology.GetNodes(); nodes != nil {
NUMANodes = append(NUMANodes, nodes...)
}
@ -356,7 +356,7 @@ func (pdev *podDevices) getContainerDevices(podUID, contName string) ResourceDev
// ID and Healthy are not relevant here.
topology = &pluginapi.TopologyInfo{Nodes: NUMANodes}
}
devicePluginMap[devId] = pluginapi.Device{
devicePluginMap[devID] = pluginapi.Device{
Topology: topology,
}
}

View File

@ -42,14 +42,14 @@ func TestGetContainerDevices(t *testing.T) {
contDevices, ok := resContDevices[resourceName1]
require.True(t, ok, "resource %q not present", resourceName1)
for devId, plugInfo := range contDevices {
for devID, plugInfo := range contDevices {
nodes := plugInfo.GetTopology().GetNodes()
require.Equal(t, len(nodes), len(devices), "Incorrect container devices: %v - %v (nodes %v)", devices, contDevices, nodes)
for _, node := range plugInfo.GetTopology().GetNodes() {
dev, ok := devices[node.ID]
require.True(t, ok, "NUMA id %v doesn't exist in result", node.ID)
require.Equal(t, devId, dev[0], "Can't find device %s in result", dev[0])
require.Equal(t, devID, dev[0], "Can't find device %s in result", dev[0])
}
}
}

View File

@ -26,11 +26,11 @@ type ResourceConfig struct {
// Memory limit (in bytes).
Memory *int64
// CPU shares (relative weight vs. other containers).
CpuShares *uint64
CPUShares *uint64
// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
CpuQuota *int64
CPUQuota *int64
// CPU quota period.
CpuPeriod *uint64
CPUPeriod *uint64
// HugePageLimit map from page size (in bytes) to limit (in bytes)
HugePageLimit map[int64]int64
// Maximum number of pids

View File

@ -495,7 +495,7 @@ func parseCPUToInt64(res string) int64 {
return (&r).MilliValue()
}
func parseNonCpuResourceToInt64(res string) int64 {
func parseNonCPUResourceToInt64(res string) int64 {
r := resource.MustParse(res)
return (&r).Value()
}
@ -511,7 +511,7 @@ func getAdmissionRequirementList(cpu, memory, pods int) admissionRequirementList
if memory > 0 {
reqs = append(reqs, &admissionRequirement{
resourceName: v1.ResourceMemory,
quantity: parseNonCpuResourceToInt64(fmt.Sprintf("%dMi", memory)),
quantity: parseNonCPUResourceToInt64(fmt.Sprintf("%dMi", memory)),
})
}
if pods > 0 {