Skip to content

Commit efcb55a

Browse files
committed
fix: GetAttachments incorrect return type #50
1 parent bb961e5 commit efcb55a

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (a *API) GetContent(query ContentQuery) (*ContentSearch, error) {
197197
// GetChildPages returns a content list of child page objects
198198
func (a *API) GetChildPages(id string) (*Search, error) {
199199
var (
200-
results []Results
200+
results []Content
201201
searchResult Search
202202
)
203203

internal.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func NewAPI(location string, username string, token string) (*API, error) {
3030
a.username = username
3131

3232
tr := &http.Transport{
33-
TLSClientConfig: &tls.Config{InsecureSkipVerify: false},
33+
TLSClientConfig: &tls.Config{InsecureSkipVerify: false, MinVersion: tls.VersionTLS12},
3434
}
3535

3636
a.Client = &http.Client{Transport: tr}
@@ -60,6 +60,7 @@ func NewAPIWithClient(location string, client *http.Client) (*API, error) {
6060

6161
// VerifyTLS to enable disable certificate checks
6262
func (a *API) VerifyTLS(set bool) {
63+
// #nosec G402
6364
tr := &http.Transport{
6465
TLSClientConfig: &tls.Config{InsecureSkipVerify: !set},
6566
}

request.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ func (a *API) Request(req *http.Request) ([]byte, error) {
4545
if err != nil {
4646
return nil, err
4747
}
48-
resp.Body.Close()
48+
err = resp.Body.Close()
49+
if err != nil {
50+
return nil, err
51+
}
4952

5053
Debug("====== Response Body ======")
5154
Debug(string(res))
@@ -111,7 +114,11 @@ func (a *API) SendContentAttachmentRequest(ep *url.URL, attachmentName string, a
111114
// setup body for mulitpart file, adding minorEdit option
112115
body := &bytes.Buffer{}
113116
writer := multipart.NewWriter(body)
114-
writer.WriteField("minorEdit", "true")
117+
err := writer.WriteField("minorEdit", "true")
118+
if err != nil {
119+
return nil, err
120+
}
121+
115122
part, err := writer.CreateFormFile("file", attachmentName)
116123
if err != nil {
117124
return nil, err

request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,6 @@ func confluenceRestAPIStub() *httptest.Server {
382382
http.Error(w, string(b), http.StatusInternalServerError)
383383
return
384384
}
385-
w.Write(b)
385+
_, _ = w.Write(b)
386386
}))
387387
}

search.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88

99
// Search results
1010
type Search struct {
11-
Results []Results `json:"results"`
11+
Results []Content `json:"content"`
1212
Start int `json:"start,omitempty"`
1313
Limit int `json:"limit,omitempty"`
1414
Size int `json:"size,omitempty"`
1515
ID string `json:"id,omitempty"`
16-
TotalSize int `json:"totalSize, omitempty"`
16+
TotalSize int `json:"totalSize,omitempty"`
1717
}
1818

1919
// SearchQuery defines query parameters used for searchng
@@ -52,7 +52,7 @@ func addSearchQueryParams(query SearchQuery) *url.Values {
5252
if query.CQLContext != "" {
5353
data.Set("cqlcontext", query.CQLContext)
5454
}
55-
if query.IncludeArchivedSpaces == true {
55+
if query.IncludeArchivedSpaces {
5656
data.Set("includeArchivedSpaces", "true")
5757
}
5858
if query.Limit != 0 {

0 commit comments

Comments
 (0)