• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 1899590412

01 Jul 2025 09:26AM UTC coverage: 65.694% (-0.04%) from 65.731%
1899590412

push

gitlab-ci

bahaa-ghazal
refactor: Remove unused ant0ine/go-json-rest utilities from deployments

Signed-off-by: Bahaa Aldeen Ghazal <bahaa.ghazal@northern.tech>

32420 of 49350 relevant lines covered (65.69%)

1.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/backend/services/deployments/api/http/api_deployments_last_status.go
1
// Copyright 2023 Northern.tech AS
2
//
3
//        Licensed under the Apache License, Version 2.0 (the "License");
4
//        you may not use this file except in compliance with the License.
5
//        You may obtain a copy of the License at
6
//
7
//            http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//        Unless required by applicable law or agreed to in writing, software
10
//        distributed under the License is distributed on an "AS IS" BASIS,
11
//        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//        See the License for the specific language governing permissions and
13
//        limitations under the License.
14

15
package http
16

17
import (
18
        "net/http"
19

20
        "github.com/gin-gonic/gin"
21
        "github.com/pkg/errors"
22

23
        "github.com/mendersoftware/mender-server/pkg/identity"
24
        "github.com/mendersoftware/mender-server/pkg/log"
25

26
        "github.com/mendersoftware/mender-server/services/deployments/model"
27
)
28

29
// device deployments last status handler
30
func (d *DeploymentsApiHandlers) GetDeviceDeploymentLastStatus(
31
        c *gin.Context,
32
) {
3✔
33
        ctx := c.Request.Context()
3✔
34
        l := log.FromContext(ctx)
3✔
35

3✔
36
        l.Debugf("starting")
3✔
37

3✔
38
        tenantId := c.Param("tenant")
3✔
39
        var req model.DeviceDeploymentLastStatusReq
3✔
40
        if err := c.ShouldBindJSON(&req); err != nil {
4✔
41
                l.Errorf("error during DecodeJsonPayload: %s.", err.Error())
1✔
42
                d.view.RenderError(
1✔
43
                        c,
1✔
44
                        errors.Wrap(err, "cannot parse device ids array"),
1✔
45
                        http.StatusBadRequest,
1✔
46
                )
1✔
47
                return
1✔
48
        } else if len(req.DeviceIds) == 0 {
3✔
49
                d.view.RenderError(
×
50
                        c,
×
51
                        errors.Wrap(err, "device ids array cannot be empty"),
×
52
                        http.StatusBadRequest,
×
53
                )
×
54
        }
×
55

56
        l.Debugf("querying %d devices ids", len(req.DeviceIds))
2✔
57
        if tenantId != "" {
3✔
58
                ctx = identity.WithContext(
1✔
59
                        ctx,
1✔
60
                        &identity.Identity{
1✔
61
                                Tenant: tenantId,
1✔
62
                        },
1✔
63
                )
1✔
64
        }
1✔
65
        lastDeployments, err := d.app.GetDeviceDeploymentLastStatus(ctx, req.DeviceIds)
2✔
66
        switch err {
2✔
67
        default:
1✔
68
                d.view.RenderInternalError(c, err)
1✔
69
        case nil:
2✔
70
                l.Infof("outputting: %+v", lastDeployments)
2✔
71
                c.JSON(http.StatusOK, lastDeployments)
2✔
72
        }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc