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.17 release 🚀 #1426

Merged
merged 51 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ae086e4
feat: mark successful triggering of workflow even without any support…
Azanul Feb 27, 2024
e32299e
feat: engines entry
Azanul Mar 2, 2024
79315da
Merge branch 'develop' into develop
Azanul Mar 4, 2024
64650a2
feat: reduce code duplication
Azanul Mar 5, 2024
707ba40
Merge branch 'develop' into develop
Azanul Mar 8, 2024
252bf73
feat: update codeowners
Azanul Mar 8, 2024
22ff31b
Merge branch 'develop' into develop
Azanul Mar 8, 2024
6ccc4ac
feat: Azure cost PoC
Azanul Mar 13, 2024
e57e527
Merge branch 'develop' into develop
Azanul Mar 13, 2024
98186b5
feat: log schema setup err
Azanul Mar 13, 2024
5c7abbf
feat: log usage err
Azanul Mar 15, 2024
a521582
Merge branch 'develop' into develop
Azanul Mar 22, 2024
180eee7
fix: aws config env vars support
Azanul Mar 28, 2024
e31cbcc
Merge branch 'develop' into develop
Azanul Mar 28, 2024
e8e57bd
feat: log schema setup err
Azanul Apr 2, 2024
14be2e1
feat: separate create config
Azanul Apr 5, 2024
a9723eb
feat: use util to create config
Azanul Apr 5, 2024
f1f91f8
Merge branch 'develop' into develop
Azanul Apr 6, 2024
f3d351e
refac: clean code
Azanul Apr 20, 2024
cd1d7d2
refac: seperate errors
Azanul Apr 20, 2024
e5084b4
refac: seperate jobs
Azanul Apr 20, 2024
c68bb50
Merge branch 'develop' into develop
Azanul May 3, 2024
f0a9492
feat: accounts controller
Azanul May 6, 2024
cfe1657
feat: resources controller
Azanul May 6, 2024
6b70baa
feat: tags controller
Azanul May 6, 2024
b99742f
feat: csv controller
Azanul May 8, 2024
72e8aa1
feat: alerts controller
Azanul May 8, 2024
7987186
feat: dashboard controller
Azanul May 8, 2024
724ebb6
feat: stats controller
Azanul May 9, 2024
4d035b0
feat: views controller
Azanul May 9, 2024
29c5bcd
feat: sql -> postgres
Azanul May 9, 2024
b95420c
Merge pull request #1411 from Azanul/develop
Azanul May 10, 2024
11580ca
chore(deps-dev): bump @storybook/nextjs in /dashboard
dependabot[bot] May 13, 2024
08c597f
fix: uninitialized controller and repo
Azanul May 15, 2024
5beea98
feat: handle dialect
Azanul May 15, 2024
25cb058
Merge branch 'develop' into develop
Azanul May 15, 2024
5a75b9a
Merge pull request #1422 from Azanul/develop
Azanul May 16, 2024
9d0135f
fix: db nil error during initiation
AvineshTripathi May 16, 2024
9373e82
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/storybo…
Azanul May 17, 2024
0da0ecd
Merge pull request #1419 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul May 20, 2024
a54a516
Merge branch 'develop' into fix-db-init
Azanul May 20, 2024
83a276f
chore(deps): bump @formbricks/js from 1.6.2 to 2.0.0 in /dashboard
dependabot[bot] May 20, 2024
9c4fbdc
---
dependabot[bot] May 20, 2024
e1cb5f1
Merge pull request #1423 from AvineshTripathi/fix-db-init
Azanul May 21, 2024
7639dca
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/multi-7…
Azanul May 21, 2024
9772a76
feat: migrate formbricks
Azanul May 24, 2024
338895d
fix: formbricks module undetected
Azanul May 24, 2024
3d09fad
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/formbri…
Azanul May 24, 2024
014f032
Merge pull request #1420 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul May 24, 2024
31f664f
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/multi-7…
Azanul May 24, 2024
438711e
Merge pull request #1425 from tailwarden/dependabot/npm_and_yarn/dash…
Azanul May 24, 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
51 changes: 51 additions & 0 deletions controller/accounts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package controller

import (
"context"

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

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

func (ctrl *Controller) CountResources(c context.Context, provider, name string) (output totalOutput, err error) {
conditions := [][3]string{}
if provider != "" {
conditions = append(conditions, [3]string{"provider", "=", provider})
}
if name != "" {
conditions = append(conditions, [3]string{"account", "=", name})
}
_, 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()
}

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()
}

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}})
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}})
return
}
26 changes: 26 additions & 0 deletions controller/alerts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package controller

import (
"context"

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

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()
}

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}})
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}})
return
}
42 changes: 42 additions & 0 deletions controller/controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package controller

import (
"context"
"database/sql"
)

type totalOutput struct {
Total int `bun:"total" json:"total"`
}

type costOutput struct {
Total float64 `bun:"sum" json:"total"`
}

type regionOutput struct {
Region string `bun:"region" json:"region"`
}

type providerOutput struct {
Provider string `bun:"provider" json:"provider"`
}

type serviceOutput struct {
Service string `bun:"service" json:"service"`
}

type accountOutput struct {
Account string `bun:"account" json:"account"`
}

type Repository interface {
HandleQuery(context.Context, string, interface{}, [][3]string) (sql.Result, error)
}

type Controller struct {
repo Repository
}

func New(repo Repository) *Controller {
return &Controller{repo}
}
39 changes: 39 additions & 0 deletions controller/resources.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package controller

import (
"context"
"strings"

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

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}})
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, "[]") + ")"}})
return
}

func (ctrl *Controller) ListResources(c context.Context) (resources []models.Resource, err error) {
_, 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{})
return
}

func (ctrl *Controller) CountRegionsFromAccounts(c context.Context) (accounts totalOutput, err error) {
_, 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{})
return
}
33 changes: 33 additions & 0 deletions controller/stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package controller

import (
"context"

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

func (ctrl *Controller) LocationStatsBreakdown(c context.Context) (groups []models.OutputResources, err error) {
_, 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)
return
}

func (ctrl *Controller) ListProviders(c context.Context) (providers []providerOutput, err error) {
_, 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)
return
}

func (ctrl *Controller) ListAccountNames(c context.Context) (accounts []accountOutput, err error) {
_, err = ctrl.repo.HandleQuery(c, repository.ListAccountsKey, &accounts, nil)
return
}
15 changes: 15 additions & 0 deletions controller/tags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package controller

import (
"context"
"fmt"

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

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)}})
return
}
46 changes: 46 additions & 0 deletions controller/views.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package controller

import (
"context"

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

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}})
return
}

func (ctrl *Controller) ListViews(c context.Context) (views []models.View, err error) {
_, 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()
}

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}})
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}})
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}})
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}})
return
}
Loading
Loading