Skip to content

Commit 1bbaf63

Browse files
committed
cmd/internal/container/mesos: fix some golint warnings
It all started from this: internal/container/mesos/client.go:57:16: exported func Client returns unexported type github.com/google/cadvisor/cmd/internal/container/mesos.mesosAgentClient, which can be annoying to use (golint) func Client() (mesosAgentClient, error) { ^ internal/container/mesos/client_test.go:24:58: exported method ContainerInfo returns unexported type *github.com/google/cadvisor/cmd/internal/container/mesos.containerInfo, which can be annoying to use (golint) func (c *FakeMesosAgentClient) ContainerInfo(id string) (*containerInfo, error) { ^ Now, as the both functions are only used internally, it makes no sense to make them public. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 487189d commit 1bbaf63

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

cmd/internal/container/mesos/client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ type client struct {
4444
}
4545

4646
type mesosAgentClient interface {
47-
ContainerInfo(id string) (*containerInfo, error)
48-
ContainerPid(id string) (int, error)
47+
containerInfo(id string) (*containerInfo, error)
48+
containerPID(id string) (int, error)
4949
}
5050

5151
type containerInfo struct {
5252
cntr *mContainer
5353
labels map[string]string
5454
}
5555

56-
// Client is an interface to query mesos agent http endpoints
57-
func Client() (mesosAgentClient, error) {
56+
// newClient is an interface to query mesos agent http endpoints
57+
func newClient() (mesosAgentClient, error) {
5858
mesosClientOnce.Do(func() {
5959
// Start Client
6060
apiURL := url.URL{
@@ -79,8 +79,8 @@ func Client() (mesosAgentClient, error) {
7979
return mesosClient, nil
8080
}
8181

82-
// ContainerInfo returns the container information of the given container id
83-
func (c *client) ContainerInfo(id string) (*containerInfo, error) {
82+
// containerInfo returns the container information of the given container id
83+
func (c *client) containerInfo(id string) (*containerInfo, error) {
8484
container, err := c.getContainer(id)
8585
if err != nil {
8686
return nil, err
@@ -99,11 +99,11 @@ func (c *client) ContainerInfo(id string) (*containerInfo, error) {
9999
}
100100

101101
// Get the Pid of the container
102-
func (c *client) ContainerPid(id string) (int, error) {
102+
func (c *client) containerPID(id string) (int, error) {
103103
var pid int
104104
err := retry.Retry(
105105
func(attempt uint) error {
106-
c, err := c.ContainerInfo(id)
106+
c, err := c.containerInfo(id)
107107
if err != nil {
108108
return err
109109
}

cmd/internal/container/mesos/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type FakeMesosAgentClient struct {
2121
err error
2222
}
2323

24-
func (c *FakeMesosAgentClient) ContainerInfo(id string) (*containerInfo, error) {
24+
func (c *FakeMesosAgentClient) containerInfo(id string) (*containerInfo, error) {
2525
if c.err != nil {
2626
return nil, c.err
2727
}
@@ -32,7 +32,7 @@ func (c *FakeMesosAgentClient) ContainerInfo(id string) (*containerInfo, error)
3232
return cInfo, nil
3333
}
3434

35-
func (c *FakeMesosAgentClient) ContainerPid(id string) (int, error) {
35+
func (c *FakeMesosAgentClient) containerPID(id string) (int, error) {
3636
if c.err != nil {
3737
return invalidPID, c.err
3838
}

cmd/internal/container/mesos/factory.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (f *mesosFactory) String() string {
6161
}
6262

6363
func (f *mesosFactory) NewContainerHandler(name string, metadataEnvAllowList []string, inHostNamespace bool) (container.ContainerHandler, error) {
64-
client, err := Client()
64+
client, err := newClient()
6565
if err != nil {
6666
return nil, err
6767
}
@@ -109,7 +109,7 @@ func (f *mesosFactory) CanHandleAndAccept(name string) (handle bool, accept bool
109109
// Check if the container is known to mesos and it is active.
110110
id := ContainerNameToMesosId(name)
111111

112-
_, err = f.client.ContainerInfo(id)
112+
_, err = f.client.containerInfo(id)
113113
if err != nil {
114114
return false, true, fmt.Errorf("error getting running container: %v", err)
115115
}
@@ -126,7 +126,7 @@ func Register(
126126
fsInfo fs.FsInfo,
127127
includedMetrics container.MetricSet,
128128
) error {
129-
client, err := Client()
129+
client, err := newClient()
130130

131131
if err != nil {
132132
return fmt.Errorf("unable to create mesos agent client: %v", err)

cmd/internal/container/mesos/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ func newMesosContainerHandler(
7575

7676
id := ContainerNameToMesosId(name)
7777

78-
cinfo, err := client.ContainerInfo(id)
78+
cinfo, err := client.containerInfo(id)
7979

8080
if err != nil {
8181
return nil, err
8282
}
8383

8484
labels := cinfo.labels
85-
pid, err := client.ContainerPid(id)
85+
pid, err := client.containerPID(id)
8686
if err != nil {
8787
return nil, err
8888
}

0 commit comments

Comments
 (0)