chore: bump sdk to v1.5.0
This commit is contained in:
parent
fa883499d0
commit
5a37d05e67
1 changed files with 14 additions and 31 deletions
28
github.go
28
github.go
|
|
@ -6,11 +6,11 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"code.geekeey.de/actions/sdk"
|
||||
)
|
||||
|
||||
type ApiClient interface {
|
||||
|
|
@ -43,24 +43,6 @@ func NewGitHub(client ApiClient) *GitHub {
|
|||
return &GitHub{client: client}
|
||||
}
|
||||
|
||||
func HasContentType(r *http.Response, mimetype string) bool {
|
||||
contentType := r.Header.Get("content-type")
|
||||
if contentType == "" {
|
||||
return mimetype == "application/octet-stream"
|
||||
}
|
||||
|
||||
for _, v := range strings.Split(contentType, ",") {
|
||||
t, _, err := mime.ParseMediaType(v)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
if t == mimetype {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type GitTag struct {
|
||||
Commit struct {
|
||||
Created string `json:"created,omitempty"`
|
||||
|
|
@ -87,7 +69,7 @@ func (gh *GitHub) GetGitTagInfo(repository, tag string, ctx context.Context) (*G
|
|||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if !HasContentType(res, "application/json") {
|
||||
if !sdk.HasContentType(res, "application/json") {
|
||||
return nil, fmt.Errorf("content-type: %q should be %q",
|
||||
res.Header.Get("content-type"), "application/json")
|
||||
}
|
||||
|
|
@ -161,7 +143,7 @@ func (gh *GitHub) CreateRelease(creq *CreateReleaseRequest, ctx context.Context)
|
|||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if !HasContentType(res, "application/json") {
|
||||
if !sdk.HasContentType(res, "application/json") {
|
||||
return nil, fmt.Errorf("content-type: %q should be %q",
|
||||
res.Header.Get("content-type"), "application/json")
|
||||
}
|
||||
|
|
@ -264,7 +246,7 @@ func (gh *GitHub) CreateReleaseArtifact(creq *CreateReleaseArtifactRequest, ctx
|
|||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if !HasContentType(res, "application/json") {
|
||||
if !sdk.HasContentType(res, "application/json") {
|
||||
return nil, fmt.Errorf("content-type: %q should be %q",
|
||||
res.Header.Get("content-type"), "application/json")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue