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

v3.1.18 release 🚀 #1442

Merged
merged 51 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
cbe8df0
chore(deps-dev): bump eslint-plugin-storybook in /dashboard
dependabot[bot] May 2, 2024
6c5793b
feat: initial
AvineshTripathi May 14, 2024
f9a5f9e
feat: added dialect support
AvineshTripathi May 14, 2024
7d11de0
Merge remote-tracking branch 'origin/develop' into filter-query
AvineshTripathi May 16, 2024
c646d7e
Merge branch 'fix-db-init' into filter-query
AvineshTripathi May 18, 2024
1ba9d64
feat: added resource with filters to controller
AvineshTripathi May 18, 2024
ee420b1
feat: added relation and stats with filters to controller
AvineshTripathi May 19, 2024
8adfb2f
fix: added missing functions in controller
AvineshTripathi May 19, 2024
fd321c3
feat: added raw query support to controller
AvineshTripathi May 22, 2024
1e87448
Merge branch 'develop' into filter-query
AvineshTripathi May 22, 2024
3bdda9a
fix: refactor
AvineshTripathi May 22, 2024
3d7d1ce
feat: added relation filter support
AvineshTripathi May 23, 2024
da96139
fix: lint error
AvineshTripathi May 23, 2024
7bacb2b
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/eslint-…
Azanul May 24, 2024
fc8a689
fix: fix miss makezero bug
alingse May 26, 2024
fa02724
Merge pull request #1428 from alingse-forks/fix-makezero-bug
Azanul May 26, 2024
e74d84f
build(deps): bump @sentry/react from 7.70.0 to 8.5.0 in /dashboard
dependabot[bot] May 27, 2024
7980b02
fix: deprecated browser tracing
Azanul May 28, 2024
b0559a6
fix: deprecated browser tracing
Azanul May 28, 2024
1aef9d9
Merge pull request #1431 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 10, 2024
8da9904
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/eslint-…
Azanul Jun 10, 2024
904ce3d
Merge pull request #1400 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 10, 2024
6d302ff
build(deps-dev): bump eslint-config-next in /dashboard
dependabot[bot] Jun 10, 2024
906a45b
Merge branch 'develop' into filter-query
Azanul Jun 10, 2024
fb7b926
build(deps-dev): bump @commitlint/config-conventional in /dashboard
dependabot[bot] Jun 10, 2024
b5bf2c3
fix: TotalOutput does not have column count
Azanul Jun 10, 2024
ab413a9
Merge pull request #1429 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 11, 2024
929e13d
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/commitl…
Azanul Jun 11, 2024
df8c585
build(deps-dev): bump tailwindcss from 3.4.1 to 3.4.4 in /dashboard
dependabot[bot] Jun 11, 2024
edb7612
Merge pull request #1430 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 11, 2024
b8c3278
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/tailwin…
Azanul Jun 11, 2024
4e7fc9e
build(deps-dev): bump @storybook/preview-api in /dashboard
dependabot[bot] Jun 11, 2024
dff0bb4
Merge pull request #1437 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 11, 2024
5e677b1
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/storybo…
Azanul Jun 11, 2024
3ed8bf3
build(deps-dev): bump @storybook/theming in /dashboard
dependabot[bot] Jun 11, 2024
4f71547
Merge pull request #1436 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 11, 2024
5749eaf
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/storybo…
Azanul Jun 11, 2024
8f64ce5
Merge pull request #1435 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul Jun 11, 2024
2a1f75a
Merge branch 'develop' into develop
Azanul Jun 11, 2024
f4d2011
Merge pull request #1438 from Azanul/develop
Azanul Jun 11, 2024
d80639a
Merge branch 'develop' into filter-query
Azanul Jun 11, 2024
635f03b
Merge pull request #1421 from AvineshTripathi/filter-query
Azanul Jun 11, 2024
75e0f80
fix: unsupported operations by driver
Azanul Jun 12, 2024
08d50ed
fix: uneven ident in queries
Azanul Jun 16, 2024
469619d
Merge pull request #1441 from Azanul/develop
Azanul Jun 16, 2024
ca3a0d5
fix: user controlled queries
Azanul Jun 17, 2024
51d70de
Merge branch 'develop' into develop
Azanul Jun 17, 2024
cc0335e
Merge pull request #1443 from Azanul/develop
Azanul Jun 17, 2024
14e1423
fix: user controlled exclude list in queries
Azanul Jun 19, 2024
9392c74
Merge branch 'develop' into develop
Azanul Jun 19, 2024
909a57b
Merge pull request #1449 from Azanul/develop
Azanul Jun 19, 2024
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
22 changes: 8 additions & 14 deletions controller/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func (ctrl *Controller) ListAccounts(c context.Context) (accounts []models.Account, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &accounts, nil)
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &accounts, nil, "")
return
}

Expand All @@ -20,32 +20,26 @@ func (ctrl *Controller) CountResources(c context.Context, provider, name string)
if name != "" {
conditions = append(conditions, [3]string{"account", "=", name})
}
_, err = ctrl.repo.HandleQuery(c, repository.ResourceCountKey, &output, conditions)
_, err = ctrl.repo.HandleQuery(c, repository.ResourceCountKey, &output, conditions, "")
return
}

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) {
_, err = ctrl.repo.HandleQuery(c, repository.DeleteKey, new(models.Account), [][3]string{{"id", "=", accountId}})
_, err = ctrl.repo.HandleQuery(c, repository.DeleteKey, new(models.Account), [][3]string{{"id", "=", accountId}}, "")
return
}

func (ctrl *Controller) UpdateAccount(c context.Context, account models.Account, accountId string) (err error) {
_, err = ctrl.repo.HandleQuery(c, repository.UpdateAccountKey, &account, [][3]string{{"id", "=", accountId}})
_, err = ctrl.repo.HandleQuery(c, repository.UpdateAccountKey, &account, [][3]string{{"id", "=", accountId}}, "")
return
}
11 changes: 4 additions & 7 deletions controller/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ 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
}

func (ctrl *Controller) DeleteAlert(c context.Context, alertId string) (err error) {
_, err = ctrl.repo.HandleQuery(c, repository.DeleteKey, new(models.Alert), [][3]string{{"id", "=", alertId}})
_, err = ctrl.repo.HandleQuery(c, repository.DeleteKey, new(models.Alert), [][3]string{{"id", "=", alertId}}, "")
return
}
6 changes: 4 additions & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package controller

import (
"context"
"database/sql"

"github.com/tailwarden/komiser/models"
)

type totalOutput struct {
Expand Down Expand Up @@ -30,7 +31,8 @@ type accountOutput struct {
}

type Repository interface {
HandleQuery(context.Context, string, interface{}, [][3]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)
}

type Controller struct {
Expand Down
44 changes: 38 additions & 6 deletions controller/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,63 @@ import (
)

func (ctrl *Controller) GetResource(c context.Context, resourceId string) (resource models.Resource, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &resource, [][3]string{{"resource_id", "=", resourceId}})
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &resource, [][3]string{{"resource_id", "=", resourceId}}, "")
return
}

func (ctrl *Controller) GetResources(c context.Context, idList string) (resources []models.Resource, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &resources, [][3]string{{"id", "IN", "(" + strings.Trim(idList, "[]") + ")"}})
resources = make([]models.Resource, 0)
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &resources, [][3]string{{"id", "IN", "(" + strings.Trim(idList, "[]") + ")"}}, "")
return
}

func (ctrl *Controller) ListResources(c context.Context) (resources []models.Resource, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &resources, [][3]string{})
resources = make([]models.Resource, 0)
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &resources, [][3]string{}, "")
return
}

func (ctrl *Controller) CountRegionsFromResources(c context.Context) (regions totalOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.RegionResourceCountKey, &regions, [][3]string{})
_, err = ctrl.repo.HandleQuery(c, repository.RegionResourceCountKey, &regions, [][3]string{}, "")
return
}

func (ctrl *Controller) CountRegionsFromAccounts(c context.Context) (accounts totalOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.AccountsResourceCountKey, &accounts, [][3]string{})
_, err = ctrl.repo.HandleQuery(c, repository.AccountsResourceCountKey, &accounts, [][3]string{}, "")
return
}

func (ctrl *Controller) SumResourceCost(c context.Context) (cost costOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ResourceCostSumKey, &cost, [][3]string{})
_, err = ctrl.repo.HandleQuery(c, repository.ResourceCostSumKey, &cost, [][3]string{}, "")
return
}

func (ctrl *Controller) ResourceWithFilter(c context.Context, view models.View, arguments []int64, queryParameter string) (resources []models.Resource, err error) {
resources = make([]models.Resource, 0)
queries, err := ctrl.repo.GenerateFilterQuery(view, repository.ListResourceWithFilter, arguments, queryParameter)
if err != nil {
return
}
for _, query := range queries {
_, err = ctrl.repo.HandleQuery(c, repository.ListResourceWithFilter, &resources, [][3]string{}, query)
if err != nil {
return
}
}
return
}

func (ctrl *Controller) RelationWithFilter(c context.Context, view models.View, arguments []int64, queryParameter string) (resources []models.Resource, err error) {
resources = make([]models.Resource, 0)
queries, err := ctrl.repo.GenerateFilterQuery(view, repository.ListRelationWithFilter, arguments, queryParameter)
if err != nil {
return
}
for _, query := range queries {
_, err = ctrl.repo.HandleQuery(c, repository.ListRelationWithFilter, &resources, [][3]string{}, query)
if err != nil {
return
}
}
return
}
34 changes: 29 additions & 5 deletions controller/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,50 @@ import (
)

func (ctrl *Controller) LocationStatsBreakdown(c context.Context) (groups []models.OutputResources, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.LocationBreakdownStatKey, &groups, [][3]string{})
_, err = ctrl.repo.HandleQuery(c, repository.LocationBreakdownStatKey, &groups, [][3]string{}, "")
return
}

func (ctrl *Controller) ListRegions(c context.Context) (regions []regionOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListRegionsKey, &regions, nil)
_, err = ctrl.repo.HandleQuery(c, repository.ListRegionsKey, &regions, nil, "")
return
}

func (ctrl *Controller) ListProviders(c context.Context) (providers []providerOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListProvidersKey, &providers, nil)
_, err = ctrl.repo.HandleQuery(c, repository.ListProvidersKey, &providers, nil, "")
return
}

func (ctrl *Controller) ListServices(c context.Context) (services []serviceOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListServicesKey, &services, nil)
_, err = ctrl.repo.HandleQuery(c, repository.ListServicesKey, &services, nil, "")
return
}

func (ctrl *Controller) ListAccountNames(c context.Context) (accounts []accountOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListAccountsKey, &accounts, nil)
_, err = ctrl.repo.HandleQuery(c, repository.ListAccountsKey, &accounts, nil, "")
return
}

func (ctrl *Controller) StatsWithFilter(c context.Context, view models.View, arguments []int64, queryParameter string) (regionCount totalOutput, resourceCount totalOutput, costCount costOutput, err error) {
queries, err := ctrl.repo.GenerateFilterQuery(view, repository.ListStatsWithFilter, arguments, queryParameter)
if err != nil {
return
}
_, err = ctrl.repo.HandleQuery(c, repository.ListStatsWithFilter, &regionCount, [][3]string{}, queries[0])
if err != nil {
return
}

// for resource count
_, err = ctrl.repo.HandleQuery(c, repository.ListStatsWithFilter, &resourceCount, [][3]string{}, queries[1])
if err != nil {
return
}

// for cost sum
_, err = ctrl.repo.HandleQuery(c, repository.ListStatsWithFilter, &costCount, [][3]string{}, queries[2])
if err != nil {
return
}
return
}
2 changes: 1 addition & 1 deletion controller/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import (

func (ctrl *Controller) UpdateTags(c context.Context, tags []models.Tag, resourceId string) (resource models.Resource, err error) {
resource.Tags = tags
_, err = ctrl.repo.HandleQuery(c, repository.UpdateTagsKey, &resource, [][3]string{{"id", "=", fmt.Sprint(resourceId)}})
_, err = ctrl.repo.HandleQuery(c, repository.UpdateTagsKey, &resource, [][3]string{{"id", "=", fmt.Sprint(resourceId)}}, "")
return
}
19 changes: 8 additions & 11 deletions controller/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,36 @@ import (
)

func (ctrl *Controller) GetView(c context.Context, viewId string) (view models.View, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &view, [][3]string{{"id", "=", viewId}})
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &view, [][3]string{{"id", "=", viewId}}, "")
return
}

func (ctrl *Controller) ListViews(c context.Context) (views []models.View, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &views, [][3]string{})
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &views, [][3]string{}, "")
return
}

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) {
_, err = ctrl.repo.HandleQuery(c, repository.UpdateViewKey, &view, [][3]string{{"id", "=", viewId}})
_, err = ctrl.repo.HandleQuery(c, repository.UpdateViewKey, &view, [][3]string{{"id", "=", viewId}}, "")
return
}

func (ctrl *Controller) DeleteView(c context.Context, viewId string) (err error) {
_, err = ctrl.repo.HandleQuery(c, repository.DeleteKey, new(models.View), [][3]string{{"id", "=", viewId}})
_, err = ctrl.repo.HandleQuery(c, repository.DeleteKey, new(models.View), [][3]string{{"id", "=", viewId}}, "")
return
}

func (ctrl *Controller) UpdateViewExclude(c context.Context, view models.View, viewId string) (err error) {
_, err = ctrl.repo.HandleQuery(c, repository.UpdateViewExcludeKey, &view, [][3]string{{"id", "=", viewId}})
_, err = ctrl.repo.HandleQuery(c, repository.UpdateViewExcludeKey, &view, [][3]string{{"id", "=", viewId}}, "")
return
}

func (ctrl *Controller) ListViewAlerts(c context.Context, viewId string) (alerts []models.Alert, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &alerts, [][3]string{{"view_id", "=", viewId}})
_, err = ctrl.repo.HandleQuery(c, repository.ListKey, &alerts, [][3]string{{"view_id", "=", viewId}}, "")
return
}
3 changes: 1 addition & 2 deletions dashboard/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Sentry from '@sentry/react';
import classNames from 'classnames';
import { BrowserTracing } from '@sentry/tracing';
import { useRouter } from 'next/router';
import { ReactNode, useEffect } from 'react';
import settingsService from '@services/settingsService';
Expand Down Expand Up @@ -47,7 +46,7 @@ function Layout({ children }: LayoutProps) {
if (telemetry?.telemetry_enabled && environment.production) {
Sentry.init({
dsn: environment.SENTRY_URL,
integrations: [new BrowserTracing()],
integrations: [Sentry.browserTracingIntegration()],

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
Expand Down
Loading
Loading