Skip to content

Commit

Permalink
fix: addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
drochow committed Sep 25, 2024
1 parent 3d6cc8a commit 0a86391
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
15 changes: 6 additions & 9 deletions internal/api/graphql/graph/baseResolver/component_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cloudoperators/heureka/internal/api/graphql/graph/model"
"github.com/cloudoperators/heureka/internal/app"
"github.com/cloudoperators/heureka/internal/entity"
"github.com/samber/lo"
"github.com/cloudoperators/heureka/internal/util"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -86,14 +86,11 @@ func ComponentVersionBaseResolver(app app.Heureka, ctx context.Context, filter *
componentId = []*int64{pid}
}
} else {
componentId = lo.Map(filter.ComponentID, func(id *string, _ int) *int64 {
i, err := ParseCursor(id)
if err != nil {
logrus.WithField("componentId", filter.ComponentID).Error("ComponentVersionBaseResolver: Error while parsing parameter 'componentId'")
return nil
}
return i
})
componentId, err = util.ConvertStrToIntSlice(filter.ComponentID)

if err != nil {
return nil, NewResolverError("ComponentVersionBaseResolver", "Bad Request - Error while parsing filter component ID")
}
}

f := &entity.ComponentVersionFilter{
Expand Down
8 changes: 4 additions & 4 deletions internal/app/component_version/component_version_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
package component_version

import (
"errors"
"fmt"
"strings"

"github.com/cloudoperators/heureka/internal/app/common"
"github.com/cloudoperators/heureka/internal/app/event"
"github.com/cloudoperators/heureka/internal/database"
Expand Down Expand Up @@ -118,10 +117,11 @@ func (cv *componentVersionHandler) CreateComponentVersion(componentVersion *enti
newComponent, err := cv.database.CreateComponentVersion(componentVersion)

if err != nil {
if strings.HasPrefix(err.Error(), "Error 1062") {
l.Error(err)
duplicateEntryError := &database.DuplicateEntryDatabaseError{}
if errors.As(err, &duplicateEntryError) {
return nil, NewComponentVersionHandlerError("Entry already Exists")
}
l.Error(err)
return nil, NewComponentVersionHandlerError("Internal error while creating componentVersion.")
}

Expand Down
8 changes: 4 additions & 4 deletions internal/app/issue/issue_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
package issue

import (
"errors"
"fmt"
"strings"

"github.com/cloudoperators/heureka/internal/app/common"
"github.com/cloudoperators/heureka/internal/app/event"
"github.com/cloudoperators/heureka/internal/database"
Expand Down Expand Up @@ -248,10 +247,11 @@ func (is *issueHandler) AddComponentVersionToIssue(issueId, componentVersionId i
err := is.database.AddComponentVersionToIssue(issueId, componentVersionId)

if err != nil {
if strings.HasPrefix(err.Error(), "Error 1062") {
l.Error(err)
duplicateEntryError := &database.DuplicateEntryDatabaseError{}
if errors.As(err, &duplicateEntryError) {
return nil, NewIssueHandlerError("Entry already Exists")
}
l.Error(err)
return nil, NewIssueHandlerError("Internal error while adding component version to issue.")
}

Expand Down
5 changes: 1 addition & 4 deletions scanner/k8s-assets/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ func (p *Processor) getSupportGroup(ctx context.Context, serviceInfo scanner.Ser

// Return the first item
if listSupportGroupsResp.SupportGroups.TotalCount > 0 {
for _, sg := range listSupportGroupsResp.SupportGroups.Edges {
supportGroupId = sg.Node.Id
break
}
supportGroupId = listSupportGroupsResp.SupportGroups.Edges[0].Node.Id
} else {
return "", fmt.Errorf("ListSupportGroups returned no SupportGroupID")
}
Expand Down

0 comments on commit 0a86391

Please sign in to comment.