Skip to content

Commit 7013997

Browse files
mmorel-35thaJeztah
authored andcommitted
fix(ST1016): Use consistent method receiver names
Signed-off-by: Matthieu MOREL <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9e9b6cc commit 7013997

16 files changed

Lines changed: 166 additions & 166 deletions

File tree

api/server/router/build/build.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ func NewRouter(b Backend, d experimentalProvider) router.Router {
2525
}
2626

2727
// Routes returns the available routers to the build controller
28-
func (r *buildRouter) Routes() []router.Route {
29-
return r.routes
28+
func (br *buildRouter) Routes() []router.Route {
29+
return br.routes
3030
}
3131

32-
func (r *buildRouter) initRoutes() {
33-
r.routes = []router.Route{
34-
router.NewPostRoute("/build", r.postBuild),
35-
router.NewPostRoute("/build/prune", r.postPrune),
36-
router.NewPostRoute("/build/cancel", r.postCancel),
32+
func (br *buildRouter) initRoutes() {
33+
br.routes = []router.Route{
34+
router.NewPostRoute("/build", br.postBuild),
35+
router.NewPostRoute("/build/prune", br.postPrune),
36+
router.NewPostRoute("/build/cancel", br.postCancel),
3737
}
3838
}
3939

api/server/router/checkpoint/checkpoint.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router {
2323
}
2424

2525
// Routes returns the available routers to the checkpoint controller
26-
func (r *checkpointRouter) Routes() []router.Route {
27-
return r.routes
26+
func (cr *checkpointRouter) Routes() []router.Route {
27+
return cr.routes
2828
}
2929

30-
func (r *checkpointRouter) initRoutes() {
31-
r.routes = []router.Route{
32-
router.NewGetRoute("/containers/{name:.*}/checkpoints", r.getContainerCheckpoints, router.Experimental),
33-
router.NewPostRoute("/containers/{name:.*}/checkpoints", r.postContainerCheckpoint, router.Experimental),
34-
router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", r.deleteContainerCheckpoint, router.Experimental),
30+
func (cr *checkpointRouter) initRoutes() {
31+
cr.routes = []router.Route{
32+
router.NewGetRoute("/containers/{name:.*}/checkpoints", cr.getContainerCheckpoints, router.Experimental),
33+
router.NewPostRoute("/containers/{name:.*}/checkpoints", cr.postContainerCheckpoint, router.Experimental),
34+
router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", cr.deleteContainerCheckpoint, router.Experimental),
3535
}
3636
}

api/server/router/checkpoint/checkpoint_routes.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/docker/docker/api/types/checkpoint"
99
)
1010

11-
func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
11+
func (cr *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
1212
if err := httputils.ParseForm(r); err != nil {
1313
return err
1414
}
@@ -18,7 +18,7 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R
1818
return err
1919
}
2020

21-
err := s.backend.CheckpointCreate(vars["name"], options)
21+
err := cr.backend.CheckpointCreate(vars["name"], options)
2222
if err != nil {
2323
return err
2424
}
@@ -27,12 +27,12 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R
2727
return nil
2828
}
2929

30-
func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
30+
func (cr *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
3131
if err := httputils.ParseForm(r); err != nil {
3232
return err
3333
}
3434

35-
checkpoints, err := s.backend.CheckpointList(vars["name"], checkpoint.ListOptions{
35+
checkpoints, err := cr.backend.CheckpointList(vars["name"], checkpoint.ListOptions{
3636
CheckpointDir: r.Form.Get("dir"),
3737
})
3838
if err != nil {
@@ -42,12 +42,12 @@ func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.R
4242
return httputils.WriteJSON(w, http.StatusOK, checkpoints)
4343
}
4444

45-
func (s *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
45+
func (cr *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
4646
if err := httputils.ParseForm(r); err != nil {
4747
return err
4848
}
4949

50-
err := s.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{
50+
err := cr.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{
5151
CheckpointDir: r.Form.Get("dir"),
5252
CheckpointID: vars["checkpoint"],
5353
})

api/server/router/distribution/distribution.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ func NewRouter(backend Backend) router.Router {
1818
}
1919

2020
// Routes returns the available routes
21-
func (r *distributionRouter) Routes() []router.Route {
22-
return r.routes
21+
func (dr *distributionRouter) Routes() []router.Route {
22+
return dr.routes
2323
}
2424

2525
// initRoutes initializes the routes in the distribution router
26-
func (r *distributionRouter) initRoutes() {
27-
r.routes = []router.Route{
26+
func (dr *distributionRouter) initRoutes() {
27+
dr.routes = []router.Route{
2828
// GET
29-
router.NewGetRoute("/distribution/{name:.*}/json", r.getDistributionInfo),
29+
router.NewGetRoute("/distribution/{name:.*}/json", dr.getDistributionInfo),
3030
}
3131
}

api/server/router/distribution/distribution_routes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/pkg/errors"
2020
)
2121

22-
func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
22+
func (dr *distributionRouter) getDistributionInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
2323
if err := httputils.ParseForm(r); err != nil {
2424
return err
2525
}
@@ -45,7 +45,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
4545
// For a search it is not an error if no auth was given. Ignore invalid
4646
// AuthConfig to increase compatibility with the existing API.
4747
authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader))
48-
repos, err := s.backend.GetRepositories(ctx, namedRef, authConfig)
48+
repos, err := dr.backend.GetRepositories(ctx, namedRef, authConfig)
4949
if err != nil {
5050
return err
5151
}
@@ -66,7 +66,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
6666
// - https://github.com/moby/moby/blob/12c7411b6b7314bef130cd59f1c7384a7db06d0b/distribution/pull.go#L76-L152
6767
var lastErr error
6868
for _, repo := range repos {
69-
distributionInspect, err := s.fetchManifest(ctx, repo, namedRef)
69+
distributionInspect, err := dr.fetchManifest(ctx, repo, namedRef)
7070
if err != nil {
7171
lastErr = err
7272
continue
@@ -76,7 +76,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
7676
return lastErr
7777
}
7878

79-
func (s *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) {
79+
func (dr *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) {
8080
var distributionInspect registry.DistributionInspect
8181
if canonicalRef, ok := namedRef.(reference.Canonical); !ok {
8282
namedRef = reference.TagNameOnly(namedRef)

api/server/router/network/network.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ func NewRouter(b Backend, c ClusterBackend) router.Router {
2222
}
2323

2424
// Routes returns the available routes to the network controller
25-
func (r *networkRouter) Routes() []router.Route {
26-
return r.routes
25+
func (n *networkRouter) Routes() []router.Route {
26+
return n.routes
2727
}
2828

29-
func (r *networkRouter) initRoutes() {
30-
r.routes = []router.Route{
29+
func (n *networkRouter) initRoutes() {
30+
n.routes = []router.Route{
3131
// GET
32-
router.NewGetRoute("/networks", r.getNetworksList),
33-
router.NewGetRoute("/networks/", r.getNetworksList),
34-
router.NewGetRoute("/networks/{id:.+}", r.getNetwork),
32+
router.NewGetRoute("/networks", n.getNetworksList),
33+
router.NewGetRoute("/networks/", n.getNetworksList),
34+
router.NewGetRoute("/networks/{id:.+}", n.getNetwork),
3535
// POST
36-
router.NewPostRoute("/networks/create", r.postNetworkCreate),
37-
router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect),
38-
router.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect),
39-
router.NewPostRoute("/networks/prune", r.postNetworksPrune),
36+
router.NewPostRoute("/networks/create", n.postNetworkCreate),
37+
router.NewPostRoute("/networks/{id:.*}/connect", n.postNetworkConnect),
38+
router.NewPostRoute("/networks/{id:.*}/disconnect", n.postNetworkDisconnect),
39+
router.NewPostRoute("/networks/prune", n.postNetworksPrune),
4040
// DELETE
41-
router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork),
41+
router.NewDeleteRoute("/networks/{id:.*}", n.deleteNetwork),
4242
}
4343
}

api/server/router/plugin/plugin.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ func NewRouter(b Backend) router.Router {
1818
}
1919

2020
// Routes returns the available routers to the plugin controller
21-
func (r *pluginRouter) Routes() []router.Route {
22-
return r.routes
21+
func (pr *pluginRouter) Routes() []router.Route {
22+
return pr.routes
2323
}
2424

25-
func (r *pluginRouter) initRoutes() {
26-
r.routes = []router.Route{
27-
router.NewGetRoute("/plugins", r.listPlugins),
28-
router.NewGetRoute("/plugins/{name:.*}/json", r.inspectPlugin),
29-
router.NewGetRoute("/plugins/privileges", r.getPrivileges),
30-
router.NewDeleteRoute("/plugins/{name:.*}", r.removePlugin),
31-
router.NewPostRoute("/plugins/{name:.*}/enable", r.enablePlugin),
32-
router.NewPostRoute("/plugins/{name:.*}/disable", r.disablePlugin),
33-
router.NewPostRoute("/plugins/pull", r.pullPlugin),
34-
router.NewPostRoute("/plugins/{name:.*}/push", r.pushPlugin),
35-
router.NewPostRoute("/plugins/{name:.*}/upgrade", r.upgradePlugin),
36-
router.NewPostRoute("/plugins/{name:.*}/set", r.setPlugin),
37-
router.NewPostRoute("/plugins/create", r.createPlugin),
25+
func (pr *pluginRouter) initRoutes() {
26+
pr.routes = []router.Route{
27+
router.NewGetRoute("/plugins", pr.listPlugins),
28+
router.NewGetRoute("/plugins/{name:.*}/json", pr.inspectPlugin),
29+
router.NewGetRoute("/plugins/privileges", pr.getPrivileges),
30+
router.NewDeleteRoute("/plugins/{name:.*}", pr.removePlugin),
31+
router.NewPostRoute("/plugins/{name:.*}/enable", pr.enablePlugin),
32+
router.NewPostRoute("/plugins/{name:.*}/disable", pr.disablePlugin),
33+
router.NewPostRoute("/plugins/pull", pr.pullPlugin),
34+
router.NewPostRoute("/plugins/{name:.*}/push", pr.pushPlugin),
35+
router.NewPostRoute("/plugins/{name:.*}/upgrade", pr.upgradePlugin),
36+
router.NewPostRoute("/plugins/{name:.*}/set", pr.setPlugin),
37+
router.NewPostRoute("/plugins/create", pr.createPlugin),
3838
}
3939
}

api/server/router/session/session.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ func NewRouter(b Backend) router.Router {
1818
}
1919

2020
// Routes returns the available routers to the session controller
21-
func (r *sessionRouter) Routes() []router.Route {
22-
return r.routes
21+
func (sr *sessionRouter) Routes() []router.Route {
22+
return sr.routes
2323
}
2424

25-
func (r *sessionRouter) initRoutes() {
26-
r.routes = []router.Route{
27-
router.NewPostRoute("/session", r.startSession),
25+
func (sr *sessionRouter) initRoutes() {
26+
sr.routes = []router.Route{
27+
router.NewPostRoute("/session", sr.startSession),
2828
}
2929
}

api/server/router/volume/volume.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ func NewRouter(b Backend, cb ClusterBackend) router.Router {
2020
}
2121

2222
// Routes returns the available routes to the volumes controller
23-
func (r *volumeRouter) Routes() []router.Route {
24-
return r.routes
23+
func (v *volumeRouter) Routes() []router.Route {
24+
return v.routes
2525
}
2626

27-
func (r *volumeRouter) initRoutes() {
28-
r.routes = []router.Route{
27+
func (v *volumeRouter) initRoutes() {
28+
v.routes = []router.Route{
2929
// GET
30-
router.NewGetRoute("/volumes", r.getVolumesList),
31-
router.NewGetRoute("/volumes/{name:.*}", r.getVolumeByName),
30+
router.NewGetRoute("/volumes", v.getVolumesList),
31+
router.NewGetRoute("/volumes/{name:.*}", v.getVolumeByName),
3232
// POST
33-
router.NewPostRoute("/volumes/create", r.postVolumesCreate),
34-
router.NewPostRoute("/volumes/prune", r.postVolumesPrune),
33+
router.NewPostRoute("/volumes/create", v.postVolumesCreate),
34+
router.NewPostRoute("/volumes/prune", v.postVolumesPrune),
3535
// PUT
36-
router.NewPutRoute("/volumes/{name:.*}", r.putVolumesUpdate),
36+
router.NewPutRoute("/volumes/{name:.*}", v.putVolumesUpdate),
3737
// DELETE
38-
router.NewDeleteRoute("/volumes/{name:.*}", r.deleteVolumes),
38+
router.NewDeleteRoute("/volumes/{name:.*}", v.deleteVolumes),
3939
}
4040
}

daemon/containerd/image_manifest.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,44 +219,44 @@ func readManifest(ctx context.Context, store content.Provider, desc ocispec.Desc
219219

220220
// ImagePlatform returns the platform of the image manifest.
221221
// If the manifest list doesn't have a platform filled, it will be read from the config.
222-
func (m *ImageManifest) ImagePlatform(ctx context.Context) (ocispec.Platform, error) {
223-
target := m.Target()
222+
func (im *ImageManifest) ImagePlatform(ctx context.Context) (ocispec.Platform, error) {
223+
target := im.Target()
224224
if target.Platform != nil {
225225
return *target.Platform, nil
226226
}
227227

228228
var out ocispec.Platform
229-
err := m.ReadConfig(ctx, &out)
229+
err := im.ReadConfig(ctx, &out)
230230
return out, err
231231
}
232232

233233
// ReadConfig gets the image config and unmarshals it into the provided struct.
234234
// The provided struct should be a pointer to the config struct or its subset.
235-
func (m *ImageManifest) ReadConfig(ctx context.Context, outConfig interface{}) error {
236-
configDesc, err := m.Config(ctx)
235+
func (im *ImageManifest) ReadConfig(ctx context.Context, outConfig interface{}) error {
236+
configDesc, err := im.Config(ctx)
237237
if err != nil {
238238
return err
239239
}
240240

241-
return readJSON(ctx, m.ContentStore(), configDesc, outConfig)
241+
return readJSON(ctx, im.ContentStore(), configDesc, outConfig)
242242
}
243243

244244
// PresentContentSize returns the size of the image's content that is present in the content store.
245-
func (m *ImageManifest) PresentContentSize(ctx context.Context) (int64, error) {
246-
cs := m.ContentStore()
245+
func (im *ImageManifest) PresentContentSize(ctx context.Context) (int64, error) {
246+
cs := im.ContentStore()
247247
var size int64
248248
err := c8dimages.Walk(ctx, presentChildrenHandler(cs, func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
249249
size += desc.Size
250250
return nil, nil
251-
}), m.Target())
251+
}), im.Target())
252252
return size, err
253253
}
254254

255255
// SnapshotUsage returns the disk usage of the image's snapshots.
256-
func (m *ImageManifest) SnapshotUsage(ctx context.Context, snapshotter snapshots.Snapshotter) (snapshots.Usage, error) {
257-
diffIDs, err := m.RootFS(ctx)
256+
func (im *ImageManifest) SnapshotUsage(ctx context.Context, snapshotter snapshots.Snapshotter) (snapshots.Usage, error) {
257+
diffIDs, err := im.RootFS(ctx)
258258
if err != nil {
259-
return snapshots.Usage{}, errors.Wrapf(err, "failed to get rootfs of image %s", m.Name())
259+
return snapshots.Usage{}, errors.Wrapf(err, "failed to get rootfs of image %s", im.Name())
260260
}
261261

262262
imageSnapshotID := identity.ChainID(diffIDs).String()
@@ -266,12 +266,12 @@ func (m *ImageManifest) SnapshotUsage(ctx context.Context, snapshotter snapshots
266266
return snapshots.Usage{Size: 0}, nil
267267
}
268268
log.G(ctx).WithError(err).WithFields(log.Fields{
269-
"image": m.Name(),
270-
"target": m.Target(),
269+
"image": im.Name(),
270+
"target": im.Target(),
271271
"snapshotID": imageSnapshotID,
272272
}).Warn("failed to calculate snapshot usage of image")
273273

274-
return snapshots.Usage{}, errors.Wrapf(err, "failed to calculate snapshot usage of image %s", m.Name())
274+
return snapshots.Usage{}, errors.Wrapf(err, "failed to calculate snapshot usage of image %s", im.Name())
275275
}
276276
return unpackedUsage, nil
277277
}

0 commit comments

Comments
 (0)