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

mendersoftware / deployments / 1197570064

01 Mar 2024 06:24PM UTC coverage: 52.222% (-28.4%) from 80.645%
1197570064

Pull #998

gitlab-ci

web-flow
chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore

Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.9.1...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #998: chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.9.1 to 1.10.0

5218 of 9992 relevant lines covered (52.22%)

0.55 hits per line

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

84.91
/utils/restutil/view/view.go
1
// Copyright 2021 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 view
16

17
import (
18
        "errors"
19
        "fmt"
20
        "net/http"
21
        "strings"
22

23
        "github.com/ant0ine/go-json-rest/rest"
24
        "github.com/mendersoftware/go-lib-micro/log"
25
        "github.com/mendersoftware/go-lib-micro/requestid"
26

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

30
// Headers
31
const (
32
        HttpHeaderLocation = "Location"
33
)
34

35
// Errors
36
var (
37
        ErrNotFound = errors.New("Resource not found")
38
)
39

40
type RESTView struct {
41
}
42

43
func (p *RESTView) RenderSuccessPost(w rest.ResponseWriter, r *rest.Request, id string) {
1✔
44
        w.Header().Add(
1✔
45
                HttpHeaderLocation,
1✔
46
                fmt.Sprintf(".%s/%s", strings.TrimPrefix(strings.TrimPrefix(r.URL.Path, "."), "/api"), id),
1✔
47
        )
1✔
48
        w.WriteHeader(http.StatusCreated)
1✔
49
}
1✔
50

51
func (p *RESTView) RenderSuccessGet(w rest.ResponseWriter, object interface{}) {
1✔
52
        _ = w.WriteJson(object)
1✔
53
}
1✔
54

55
func (p *RESTView) RenderError(
56
        w rest.ResponseWriter,
57
        r *rest.Request,
58
        err error,
59
        status int,
60
        l *log.Logger,
61
) {
1✔
62
        l.Error(err.Error())
1✔
63
        renderErrorWithMsg(w, r, status, err.Error())
1✔
64
}
1✔
65

66
func (p *RESTView) RenderInternalError(
67
        w rest.ResponseWriter,
68
        r *rest.Request,
69
        err error,
70
        l *log.Logger,
71
) {
×
72
        l.F(log.Ctx{}).Error(err.Error())
×
73
        renderErrorWithMsg(w, r, http.StatusInternalServerError, "internal error")
×
74
}
×
75

76
func renderErrorWithMsg(w rest.ResponseWriter, r *rest.Request, status int, msg string) {
1✔
77
        w.WriteHeader(status)
1✔
78
        writeErr := w.WriteJson(map[string]string{
1✔
79
                "error":      msg,
1✔
80
                "request_id": requestid.GetReqId(r),
1✔
81
        })
1✔
82
        if writeErr != nil {
1✔
83
                panic(writeErr)
×
84
        }
85
}
86

87
func (p *RESTView) RenderErrorNotFound(w rest.ResponseWriter, r *rest.Request, l *log.Logger) {
1✔
88
        p.RenderError(w, r, ErrNotFound, http.StatusNotFound, l)
1✔
89
}
1✔
90

91
func (p *RESTView) RenderSuccessDelete(w rest.ResponseWriter) {
1✔
92
        w.WriteHeader(http.StatusNoContent)
1✔
93
}
1✔
94

95
func (p *RESTView) RenderSuccessPut(w rest.ResponseWriter) {
×
96
        w.WriteHeader(http.StatusNoContent)
×
97
}
×
98

99
func (p *RESTView) RenderNoUpdateForDevice(w rest.ResponseWriter) {
1✔
100
        p.RenderEmptySuccessResponse(w)
1✔
101
}
1✔
102

103
// Success response with no data aka. 204 No Content
104
func (p *RESTView) RenderEmptySuccessResponse(w rest.ResponseWriter) {
1✔
105
        w.WriteHeader(http.StatusNoContent)
1✔
106
}
1✔
107

108
func (p *RESTView) RenderDeploymentLog(w rest.ResponseWriter, dlog model.DeploymentLog) {
1✔
109
        h, _ := w.(http.ResponseWriter)
1✔
110

1✔
111
        h.Header().Set("Content-Type", "text/plain")
1✔
112
        h.WriteHeader(http.StatusOK)
1✔
113

1✔
114
        for _, m := range dlog.Messages {
2✔
115
                as := m.String()
1✔
116
                _, _ = h.Write([]byte(as))
1✔
117
                if !strings.HasSuffix(as, "\n") {
2✔
118
                        _, _ = h.Write([]byte("\n"))
1✔
119
                }
1✔
120
        }
121
}
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