lib/promscrape/discovery/docker: fix golint warning: struct field Id should be ID

This commit is contained in:
Aliaksandr Valialkin 2021-06-29 13:11:24 +03:00
parent 5506cff76e
commit 9ce211a514
2 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import (
// See https://github.com/moby/moby/blob/314759dc2f4745925d8dec6d15acc7761c6e5c92/docs/api/v1.41.yaml#L4024
type container struct {
Id string
ID string
Names []string
Labels map[string]string
Ports []struct {
@ -99,7 +99,7 @@ func addContainersLabels(containers []container, networkLabels map[string]map[st
}
func addCommonLabels(m map[string]string, c *container, networkLabels map[string]string) {
m["__meta_docker_container_id"] = c.Id
m["__meta_docker_container_id"] = c.ID
m["__meta_docker_container_name"] = c.Names[0]
m["__meta_docker_container_network_mode"] = c.HostConfig.NetworkMode
for k, v := range c.Labels {

View File

@ -117,7 +117,7 @@ func Test_parseContainers(t *testing.T) {
},
want: []container{
{
Id: "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
ID: "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
Names: []string{"/crow-server"},
Labels: map[string]string{
"com.docker.compose.config-hash": "c9f0bd5bb31921f94cff367d819a30a0cc08d4399080897a6c5cd74b983156ec",
@ -161,7 +161,7 @@ func Test_parseContainers(t *testing.T) {
},
},
{
Id: "0e0f72a6eb7d9fb443f0426a66f7b8dd7d3283ab7e3a308b2bed584ac03a33dc",
ID: "0e0f72a6eb7d9fb443f0426a66f7b8dd7d3283ab7e3a308b2bed584ac03a33dc",
Names: []string{"/crow-web"},
Labels: map[string]string{
"com.docker.compose.config-hash": "d99ebd0fde8512366c2d78c367e95ddc74528bb60b7cf0c991c9f4835981e00e",
@ -320,7 +320,7 @@ func Test_addContainerLabels(t *testing.T) {
{
name: "get labels from a container",
c: container{
Id: "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
ID: "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
Names: []string{"/crow-server"},
Labels: map[string]string{
"com.docker.compose.config-hash": "c9f0bd5bb31921f94cff367d819a30a0cc08d4399080897a6c5cd74b983156ec",