Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixes codeSnip bug in YAML v3. #444

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/gin-gonic/gin/binding"
liberr "github.com/jortel/go-utils/error"
"github.com/konveyor/tackle2-hub/api"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
"io"
"net/http"
"strconv"
Expand Down
30 changes: 21 additions & 9 deletions api/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
// Analysis
input, err := ctx.FormFile(FileField)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
reader, err := input.Open()
if err != nil {
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
Expand All @@ -226,24 +228,28 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
encoding := input.Header.Get(ContentType)
d, err := h.Decoder(ctx, encoding, reader)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
r := Analysis{}
err = d.Decode(&r)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
//
// Issues
input, err = ctx.FormFile(IssueField)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
reader, err = input.Open()
if err != nil {
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
Expand All @@ -253,7 +259,8 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
encoding = input.Header.Get(ContentType)
d, err = h.Decoder(ctx, encoding, reader)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
for {
Expand All @@ -263,7 +270,8 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
if errors.Is(err, io.EOF) {
break
} else {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
}
Expand All @@ -280,11 +288,13 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
// Dependencies
input, err = ctx.FormFile(DepField)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
reader, err = input.Open()
if err != nil {
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
Expand All @@ -294,7 +304,8 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
encoding = input.Header.Get(ContentType)
d, err = h.Decoder(ctx, encoding, reader)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
for {
Expand All @@ -304,7 +315,8 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) {
if errors.Is(err, io.EOF) {
break
} else {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/jortel/go-utils/logr"
reflect "github.com/konveyor/tackle2-hub/api/reflect"
"github.com/konveyor/tackle2-hub/api/reflect"
"github.com/konveyor/tackle2-hub/api/sort"
"github.com/konveyor/tackle2-hub/auth"
"github.com/konveyor/tackle2-hub/model"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
"gorm.io/gorm"
"io"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
14 changes: 10 additions & 4 deletions api/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,23 @@ func (h *BucketOwner) bucketDelete(ctx *gin.Context, id uint) {
func (h *BucketOwner) putDir(ctx *gin.Context, output string) (err error) {
file, err := ctx.FormFile(FileField)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
fileReader, err := file.Open()
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
defer func() {
_ = fileReader.Close()
}()
zipReader, err := gzip.NewReader(fileReader)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
defer func() {
Expand Down Expand Up @@ -468,11 +471,14 @@ func (h *BucketOwner) putFile(ctx *gin.Context, m *model.Bucket) (err error) {
path := pathlib.Join(m.Path, ctx.Param(Wildcard))
input, err := ctx.FormFile(FileField)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
reader, err := input.Open()
if err != nil {
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
defer func() {
Expand Down
5 changes: 4 additions & 1 deletion api/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ func (h FileHandler) Create(ctx *gin.Context) {
var err error
input, err := ctx.FormFile(FileField)
if err != nil {
h.Status(ctx, http.StatusBadRequest)
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
m := &model.File{}
Expand All @@ -94,6 +95,8 @@ func (h FileHandler) Create(ctx *gin.Context) {
}()
reader, err := input.Open()
if err != nil {
err = &BadRequestError{err.Error()}
_ = ctx.Error(err)
return
}
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion auth/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package auth
import (
liberr "github.com/jortel/go-utils/error"
"github.com/konveyor/tackle2-hub/settings"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
"io"
"os"
)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/prometheus/client_golang v1.15.0
github.com/swaggo/swag v1.16.1
golang.org/x/sys v0.7.0
gopkg.in/yaml.v3 v3.0.1
gopkg.in/yaml.v2 v2.4.0
gorm.io/datatypes v1.2.0
gorm.io/driver/sqlite v1.5.2
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55
Expand Down Expand Up @@ -94,7 +94,7 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.4.7 // indirect
k8s.io/component-base v0.25.0 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
Expand Down