Skip to content

Commit 1184684

Browse files
committed
fix lint
1 parent 859e166 commit 1184684

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

routers/api/actions/artifactsv4.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ func ArtifactsV4Routes(prefix string) *web.Route {
145145
return m
146146
}
147147

148-
func (ar artifactV4Routes) buildArtifactURL(endp, sig, expires, artifactName string, taskID int64) string {
149-
uploadURL := strings.TrimSuffix(setting.AppURL, "/") + strings.TrimSuffix(ar.prefix, "/") +
148+
func (r artifactV4Routes) buildArtifactURL(endp, sig, expires, artifactName string, taskID int64) string {
149+
uploadURL := strings.TrimSuffix(setting.AppURL, "/") + strings.TrimSuffix(r.prefix, "/") +
150150
"/" + endp + "?sig=" + sig + "&expires=" + url.QueryEscape(expires) + "&artifactName=" + url.QueryEscape(artifactName) + "&taskID=" + fmt.Sprint(taskID)
151151
return uploadURL
152152
}
@@ -210,7 +210,7 @@ func (r *artifactV4Routes) createArtifact(ctx *ArtifactContext) {
210210
}
211211
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf-8")
212212
ctx.Resp.WriteHeader(http.StatusOK)
213-
ctx.Resp.Write(resp)
213+
_, _ = ctx.Resp.Write(resp)
214214
}
215215

216216
func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
@@ -284,9 +284,6 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
284284
}
285285
ctx.JSON(201, "appended")
286286
case "blocklist":
287-
body, _ := io.ReadAll(ctx.Req.Body)
288-
strbody := string(body)
289-
fmt.Print(strbody)
290287
ctx.JSON(201, "created")
291288
}
292289
}
@@ -352,7 +349,7 @@ func (r *artifactV4Routes) finalizeArtifact(ctx *ArtifactContext) {
352349
}
353350
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf-8")
354351
ctx.Resp.WriteHeader(http.StatusOK)
355-
ctx.Resp.Write(resp)
352+
_, _ = ctx.Resp.Write(resp)
356353
}
357354

358355
func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) {
@@ -422,7 +419,7 @@ func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) {
422419
}
423420
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf-8")
424421
ctx.Resp.WriteHeader(http.StatusOK)
425-
ctx.Resp.Write(resp)
422+
_, _ = ctx.Resp.Write(resp)
426423
}
427424

428425
func (r *artifactV4Routes) getSignedArtifactURL(ctx *ArtifactContext) {
@@ -467,7 +464,7 @@ func (r *artifactV4Routes) getSignedArtifactURL(ctx *ArtifactContext) {
467464
}
468465
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf-8")
469466
ctx.Resp.WriteHeader(http.StatusOK)
470-
ctx.Resp.Write(resp)
467+
_, _ = ctx.Resp.Write(resp)
471468
}
472469

473470
func (r *artifactV4Routes) downloadArtifact(ctx *ArtifactContext) {
@@ -522,5 +519,5 @@ func (r *artifactV4Routes) downloadArtifact(ctx *ArtifactContext) {
522519

523520
file, _ := r.fs.Open(artifact.StoragePath)
524521

525-
io.Copy(ctx.Resp, file)
522+
_, _ = io.Copy(ctx.Resp, file)
526523
}

routers/web/repo/actions/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
571571
ctx.Error(http.StatusInternalServerError, err.Error())
572572
return
573573
}
574-
io.Copy(ctx.Resp, f)
574+
_, _ = io.Copy(ctx.Resp, f)
575575
return
576576
}
577577

tests/integration/api_actions_artifact_v4_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"google.golang.org/protobuf/types/known/wrapperspb"
2525
)
2626

27-
func toProtoJson(m protoreflect.ProtoMessage) io.Reader {
27+
func toProtoJSON(m protoreflect.ProtoMessage) io.Reader {
2828
resp, _ := protojson.Marshal(m)
2929
buf := bytes.Buffer{}
3030
buf.Write(resp)
@@ -38,7 +38,7 @@ func TestActionsArtifactV4UploadSingleFile(t *testing.T) {
3838
assert.NoError(t, err)
3939

4040
// acquire artifact upload url
41-
req := NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact", toProtoJson(&actions.CreateArtifactRequest{
41+
req := NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact", toProtoJSON(&actions.CreateArtifactRequest{
4242
Version: 4,
4343
Name: "artifact",
4444
WorkflowRunBackendId: "792",
@@ -64,7 +64,7 @@ func TestActionsArtifactV4UploadSingleFile(t *testing.T) {
6464
sha := sha256.Sum256([]byte(body))
6565

6666
// confirm artifact upload
67-
req = NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/FinalizeArtifact", toProtoJson(&actions.FinalizeArtifactRequest{
67+
req = NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/FinalizeArtifact", toProtoJSON(&actions.FinalizeArtifactRequest{
6868
Name: "artifact",
6969
Size: 1024,
7070
Hash: wrapperspb.String("sha256:" + hex.EncodeToString(sha[:])),
@@ -85,7 +85,7 @@ func TestActionsArtifactV4UploadSingleFileWithRetentionDays(t *testing.T) {
8585
assert.NoError(t, err)
8686

8787
// acquire artifact upload url
88-
req := NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact", toProtoJson(&actions.CreateArtifactRequest{
88+
req := NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact", toProtoJSON(&actions.CreateArtifactRequest{
8989
Version: 4,
9090
ExpiresAt: timestamppb.New(time.Now().Add(5 * 24 * time.Hour)),
9191
Name: "artifactWithRetentionDays",
@@ -112,7 +112,7 @@ func TestActionsArtifactV4UploadSingleFileWithRetentionDays(t *testing.T) {
112112
sha := sha256.Sum256([]byte(body))
113113

114114
// confirm artifact upload
115-
req = NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/FinalizeArtifact", toProtoJson(&actions.FinalizeArtifactRequest{
115+
req = NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/FinalizeArtifact", toProtoJSON(&actions.FinalizeArtifactRequest{
116116
Name: "artifactWithRetentionDays",
117117
Size: 1024,
118118
Hash: wrapperspb.String("sha256:" + hex.EncodeToString(sha[:])),
@@ -133,7 +133,7 @@ func TestActionsArtifactV4DownloadSingle(t *testing.T) {
133133
assert.NoError(t, err)
134134

135135
// acquire artifact upload url
136-
req := NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/ListArtifacts", toProtoJson(&actions.ListArtifactsRequest{
136+
req := NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/ListArtifacts", toProtoJSON(&actions.ListArtifactsRequest{
137137
NameFilter: wrapperspb.String("artifact"),
138138
WorkflowRunBackendId: "792",
139139
WorkflowJobRunBackendId: "193",
@@ -144,7 +144,7 @@ func TestActionsArtifactV4DownloadSingle(t *testing.T) {
144144
assert.Len(t, listResp.Artifacts, 1)
145145

146146
// confirm artifact upload
147-
req = NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/GetSignedArtifactURL", toProtoJson(&actions.GetSignedArtifactURLRequest{
147+
req = NewRequestWithBody(t, "POST", "/twirp/github.actions.results.api.v1.ArtifactService/GetSignedArtifactURL", toProtoJSON(&actions.GetSignedArtifactURLRequest{
148148
Name: "artifact",
149149
WorkflowRunBackendId: "792",
150150
WorkflowJobRunBackendId: "193",

0 commit comments

Comments
 (0)