Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/go_modules/github.com/Azure/az…
Browse files Browse the repository at this point in the history
…ure-sdk-for-go/sdk/azidentity-1.6.0
  • Loading branch information
Azanul authored Jul 2, 2024
2 parents 595f5ce + 2b7e8fd commit b191486
Show file tree
Hide file tree
Showing 11 changed files with 1,443 additions and 1,384 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
version: "~> v1"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
14 changes: 4 additions & 10 deletions controller/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@ func (ctrl *Controller) CountResources(c context.Context, provider, name string)
}

func (ctrl *Controller) InsertAccount(c context.Context, account models.Account) (lastId int64, err error) {
result, err := ctrl.repo.HandleQuery(c, repository.InsertKey, &account, nil, "")
if err != nil {
return
}
return result.LastInsertId()
lastId, err = ctrl.repo.HandleQuery(c, repository.InsertKey, &account, nil, "")
return
}

func (ctrl *Controller) RescanAccount(c context.Context, account *models.Account, accountId string) (rows int64, err error) {
res, err := ctrl.repo.HandleQuery(c, repository.ReScanAccountKey, account, [][3]string{{"id", "=", accountId}, {"status", "=", "CONNECTED"}}, "")
if err != nil {
return 0, err
}
return res.RowsAffected()
rows, err = ctrl.repo.HandleQuery(c, repository.ReScanAccountKey, account, [][3]string{{"id", "=", accountId}, {"status", "=", "CONNECTED"}}, "")
return
}

func (ctrl *Controller) DeleteAccount(c context.Context, accountId string) (err error) {
Expand Down
9 changes: 3 additions & 6 deletions controller/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import (
)

func (ctrl *Controller) InsertAlert(c context.Context, alert models.Alert) (alertId int64, err error) {
result, err := ctrl.repo.HandleQuery(c, repository.InsertKey, &alert, nil, "")
if err != nil {
return
}
return result.LastInsertId()
alertId, err = ctrl.repo.HandleQuery(c, repository.InsertKey, &alert, nil, "")
return
}

func (ctrl *Controller) UpdateAlert(c context.Context, alert models.Alert, alertId string) (err error) {
_, err = ctrl.repo.HandleQuery(c, repository.UpdateAlertKey, &alert, [][3]string{{"id", "=", alertId}},"")
_, err = ctrl.repo.HandleQuery(c, repository.UpdateAlertKey, &alert, [][3]string{{"id", "=", alertId}}, "")
return
}

Expand Down
3 changes: 1 addition & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controller

import (
"context"
"database/sql"

"github.com/tailwarden/komiser/models"
)
Expand Down Expand Up @@ -32,7 +31,7 @@ type accountOutput struct {
}

type Repository interface {
HandleQuery(context.Context, string, interface{}, [][3]string, string) (sql.Result, error)
HandleQuery(context.Context, string, interface{}, [][3]string, string) (int64, error)
GenerateFilterQuery(view models.View, queryTitle string, arguments []int64, queryParameter string) ([]string, error)
}

Expand Down
7 changes: 2 additions & 5 deletions controller/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ func (ctrl *Controller) ListViews(c context.Context) (views []models.View, err e
}

func (ctrl *Controller) InsertView(c context.Context, view models.View) (viewId int64, err error) {
result, err := ctrl.repo.HandleQuery(c, repository.InsertKey, &view, nil, "")
if err != nil {
return
}
return result.LastInsertId()
viewId, err = ctrl.repo.HandleQuery(c, repository.InsertKey, &view, nil, "")
return
}

func (ctrl *Controller) UpdateView(c context.Context, view models.View, viewId string) (err error) {
Expand Down
Loading

0 comments on commit b191486

Please sign in to comment.