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

mendersoftware / deployments / 856345526

pending completion
856345526

Pull #860

gitlab-ci

Peter Grzybowski
chore: api docs check fix
Pull Request #860: chore: api docs check fix

7044 of 8880 relevant lines covered (79.32%)

69.7 hits per line

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

72.22
/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

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

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

7✔
38
        tenantId := r.PathParam("tenant")
7✔
39
        var devicesIds []string
7✔
40
        if err := r.DecodeJsonPayload(&devicesIds); err != nil {
7✔
41
                l.Errorf("error during DecodeJsonPayload: %s.", err.Error())
×
42
                rest_utils.RestErrWithLog(
×
43
                        w,
×
44
                        r,
×
45
                        l,
×
46
                        errors.Wrap(err, "cannot parse device ids array"),
×
47
                        http.StatusBadRequest,
×
48
                )
×
49
                return
×
50
        }
×
51

52
        l.Debugf("querying %d devices ids", len(devicesIds))
7✔
53
        ctx := r.Context()
7✔
54
        if tenantId != "" {
13✔
55
                ctx = identity.WithContext(
6✔
56
                        ctx,
6✔
57
                        &identity.Identity{
6✔
58
                                Tenant: tenantId,
6✔
59
                        },
6✔
60
                )
6✔
61
        }
6✔
62
        lastDeployments, err := d.app.GetDeviceDeploymentLastStatus(ctx, devicesIds)
7✔
63
        switch err {
7✔
64
        default:
2✔
65
                d.view.RenderInternalError(w, r, err, l)
2✔
66
        case nil:
5✔
67
                l.Infof("outputting: %+v", lastDeployments)
5✔
68
                w.WriteHeader(http.StatusOK)
5✔
69
                _ = w.WriteJson(lastDeployments)
5✔
70
        }
71
}
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