From 3b239492dff9315695dd04c351518ee95ab2a11a Mon Sep 17 00:00:00 2001 From: Jeff Ortel Date: Fri, 9 Aug 2024 14:17:37 -0700 Subject: [PATCH] checkpoint Signed-off-by: Jeff Ortel --- api/analysis.go | 11 ++--------- hack/add/analysis.sh | 4 ++-- hack/add/file.sh | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/api/analysis.go b/api/analysis.go index 2a3e9c19b..733e1f187 100644 --- a/api/analysis.go +++ b/api/analysis.go @@ -53,11 +53,6 @@ const ( AppAnalysisIssuesRoot = AppAnalysisRoot + "/issues" ) -const ( - IssueField = "issues" - DepField = "dependencies" -) - // AnalysisHandler handles analysis resource routes. type AnalysisHandler struct { BaseHandler @@ -375,8 +370,7 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) { defer func() { _ = reader.Close() }() - encoding := ctx.Request.Header.Get(ContentType) - d, err := h.Decoder(ctx, encoding, reader) + d, err := h.Decoder(ctx, file.Encoding, reader) if err != nil { err = &BadRequestError{err.Error()} _ = ctx.Error(err) @@ -421,8 +415,7 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) { defer func() { _ = reader.Close() }() - encoding = ctx.Request.Header.Get(ContentType) - d, err = h.Decoder(ctx, encoding, reader) + d, err = h.Decoder(ctx, file.Encoding, reader) if err != nil { err = &BadRequestError{err.Error()} _ = ctx.Error(err) diff --git a/hack/add/analysis.sh b/hack/add/analysis.sh index af1658af1..a842e9ffb 100755 --- a/hack/add/analysis.sh +++ b/hack/add/analysis.sh @@ -197,7 +197,7 @@ echo "Report (files) GENERATED" # # Post issues. -code=$(curl -kSs -o ${tmp} -w "%{http_code}" -F "file=@${iPath}" http://${host}/files/issues) +code=$(curl -kSs -o ${tmp} -w "%{http_code}" -F "file=@${iPath};type=application/x-yaml" http://${host}/files/issues) if [ ! $? -eq 0 ] then exit $? @@ -214,7 +214,7 @@ case ${code} in esac # # Post deps. -code=$(curl -kSs -o ${tmp} -w "%{http_code}" -F "file=@${dPath}" http://${host}/files/deps) +code=$(curl -kSs -o ${tmp} -w "%{http_code}" -F "file=@${dPath};application/x-yaml" http://${host}/files/deps) if [ ! $? -eq 0 ] then exit $? diff --git a/hack/add/file.sh b/hack/add/file.sh index b733babc6..6c52fe4bf 100755 --- a/hack/add/file.sh +++ b/hack/add/file.sh @@ -4,5 +4,5 @@ host="${HOST:-localhost:8080}" path="${1:-/etc/hosts}" name=$(basename ${path}) -curl -F "file=@${path};type=application/x-yaml" http://${host}/files/${name} | jq . +curl -F "file=@${path}" http://${host}/files/${name} | jq .