Skip to content

Commit

Permalink
Merge pull request #51 from Virtomize/fix/search
Browse files Browse the repository at this point in the history
fix: GetAttachments incorrect return type #50
  • Loading branch information
c-seeger authored Nov 25, 2022
2 parents 5112c4f + 830d328 commit 62bd0c2
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion content.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (a *API) GetContent(query ContentQuery) (*ContentSearch, error) {
// GetChildPages returns a content list of child page objects
func (a *API) GetChildPages(id string) (*Search, error) {
var (
results []Results
results []Content
searchResult Search
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/virtomize/confluence-go-api
go 1.13

require (
github.com/magefile/mage v1.10.0
github.com/magefile/mage v1.14.0
github.com/stretchr/testify v1.3.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/magefile/mage v1.8.0 h1:mzL+xIopvPURVBwHG9A50JcjBO+xV3b5iZ7khFRI+5E=
github.com/magefile/mage v1.8.0/go.mod h1:IUDi13rsHje59lecXokTfGX0QIzO45uVPlXnJYsXepA=
github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g=
github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
2 changes: 2 additions & 0 deletions internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func NewAPI(location string, username string, token string) (*API, error) {
a.token = token
a.username = username

// #nosec G402
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: false},
}
Expand Down Expand Up @@ -60,6 +61,7 @@ func NewAPIWithClient(location string, client *http.Client) (*API, error) {

// VerifyTLS to enable disable certificate checks
func (a *API) VerifyTLS(set bool) {
// #nosec G402
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: !set},
}
Expand Down
11 changes: 9 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func (a *API) Request(req *http.Request) ([]byte, error) {
if err != nil {
return nil, err
}
resp.Body.Close()
err = resp.Body.Close()
if err != nil {
return nil, err
}

Debug("====== Response Body ======")
Debug(string(res))
Expand Down Expand Up @@ -111,7 +114,11 @@ func (a *API) SendContentAttachmentRequest(ep *url.URL, attachmentName string, a
// setup body for mulitpart file, adding minorEdit option
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
writer.WriteField("minorEdit", "true")
err := writer.WriteField("minorEdit", "true")
if err != nil {
return nil, err
}

part, err := writer.CreateFormFile("file", attachmentName)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,6 @@ func confluenceRestAPIStub() *httptest.Server {
http.Error(w, string(b), http.StatusInternalServerError)
return
}
w.Write(b)
_, _ = w.Write(b)
}))
}
6 changes: 3 additions & 3 deletions search.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

// Search results
type Search struct {
Results []Results `json:"results"`
Results []Content `json:"content"`
Start int `json:"start,omitempty"`
Limit int `json:"limit,omitempty"`
Size int `json:"size,omitempty"`
ID string `json:"id,omitempty"`
TotalSize int `json:"totalSize, omitempty"`
TotalSize int `json:"totalSize,omitempty"`
}

// SearchQuery defines query parameters used for searchng
Expand Down Expand Up @@ -52,7 +52,7 @@ func addSearchQueryParams(query SearchQuery) *url.Values {
if query.CQLContext != "" {
data.Set("cqlcontext", query.CQLContext)
}
if query.IncludeArchivedSpaces == true {
if query.IncludeArchivedSpaces {
data.Set("includeArchivedSpaces", "true")
}
if query.Limit != 0 {
Expand Down

0 comments on commit 62bd0c2

Please sign in to comment.