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

mendersoftware / deployments / 1418500193

19 Aug 2024 01:32PM UTC coverage: 79.694%. Remained the same
1418500193

Pull #1037

gitlab-ci

merlin-northern
fix: explicitly mention how name filtering works for images and releases.

Changelog: Title
Ticket: MEN-7435
Signed-off-by: Peter Grzybowski <peter@northern.tech>
Pull Request #1037: fix: explicitly mention how name filtering works for images and relea…

8124 of 10194 relevant lines covered (79.69%)

34.59 hits per line

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

61.36
/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/pkg/errors"
21

22
        "github.com/ant0ine/go-json-rest/rest"
23

24
        "github.com/mendersoftware/go-lib-micro/identity"
25
        "github.com/mendersoftware/go-lib-micro/requestlog"
26
        "github.com/mendersoftware/go-lib-micro/rest_utils"
27

28
        "github.com/mendersoftware/deployments/model"
29
)
30

31
// device deployments last status handler
32
func (d *DeploymentsApiHandlers) GetDeviceDeploymentLastStatus(
33
        w rest.ResponseWriter,
34
        r *rest.Request,
35
) {
4✔
36
        l := requestlog.GetRequestLogger(r)
4✔
37

4✔
38
        l.Debugf("starting")
4✔
39

4✔
40
        tenantId := r.PathParam("tenant")
4✔
41
        var req model.DeviceDeploymentLastStatusReq
4✔
42
        if err := r.DecodeJsonPayload(&req); err != nil {
4✔
43
                l.Errorf("error during DecodeJsonPayload: %s.", err.Error())
×
44
                rest_utils.RestErrWithLog(
×
45
                        w,
×
46
                        r,
×
47
                        l,
×
48
                        errors.Wrap(err, "cannot parse device ids array"),
×
49
                        http.StatusBadRequest,
×
50
                )
×
51
                return
×
52
        } else if len(req.DeviceIds) == 0 {
4✔
53
                rest_utils.RestErrWithLog(
×
54
                        w,
×
55
                        r,
×
56
                        l,
×
57
                        errors.Wrap(err, "device ids array cannot be empty"),
×
58
                        http.StatusBadRequest,
×
59
                )
×
60
        }
×
61

62
        l.Debugf("querying %d devices ids", len(req.DeviceIds))
4✔
63
        ctx := r.Context()
4✔
64
        if tenantId != "" {
7✔
65
                ctx = identity.WithContext(
3✔
66
                        ctx,
3✔
67
                        &identity.Identity{
3✔
68
                                Tenant: tenantId,
3✔
69
                        },
3✔
70
                )
3✔
71
        }
3✔
72
        lastDeployments, err := d.app.GetDeviceDeploymentLastStatus(ctx, req.DeviceIds)
4✔
73
        switch err {
4✔
74
        default:
1✔
75
                d.view.RenderInternalError(w, r, err, l)
1✔
76
        case nil:
3✔
77
                l.Infof("outputting: %+v", lastDeployments)
3✔
78
                w.WriteHeader(http.StatusOK)
3✔
79
                _ = w.WriteJson(lastDeployments)
3✔
80
        }
81
}
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