Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/sentry/…
Browse files Browse the repository at this point in the history
…react-7.77.0
  • Loading branch information
mlabouardy authored Nov 16, 2023
2 parents 521c58d + e53b263 commit 76c00ce
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,16 @@ function getCustomViewInventoryListAndStats({
}
}
});
} else {
setTimeout(() => router.push(router.pathname), 5000);
return showToast({
hasError: true,
title: `Invalid view`,
message: `We couldn't find this view. Redirecting back to home...`
});
}
}
// TODO: https://github.com/tailwarden/komiser/issues/1208
// else {
// setTimeout(() => router.push(router.pathname), 5000);
// return showToast({
// hasError: true,
// title: `Invalid view`,
// message: `We couldn't find this view. Redirecting back to home...`
// });
// }
}
return null;
}
Expand Down
414 changes: 207 additions & 207 deletions internal/api/v1/template.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ func triggerFetchingWorfklow(ctx context.Context, client providers.ProviderClien
case "Scaleway":
scaleway.FetchResources(ctx, client, db, telemetry, analytics)
case "MongoDBAtlas":
mongodbatlas.FetchResources(ctx, client, db, telemetry, analytics)
mongodbatlas.FetchResources(ctx, client, db, telemetry, analytics, wp)
case "GCP":
gcp.FetchResources(ctx, client, db, telemetry, analytics, wp)
case "OVH":
ovh.FetchResources(ctx, client, db, telemetry, analytics)
ovh.FetchResources(ctx, client, db, telemetry, analytics, wp)
}
}

Expand Down
36 changes: 19 additions & 17 deletions providers/mongodbatlas/mongodbatlas.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ func listOfSupportedServices() []providers.FetchDataFunction {
}
}

func FetchResources(ctx context.Context, client providers.ProviderClient, db *bun.DB, telemetry bool, analytics utils.Analytics) {
func FetchResources(ctx context.Context, client providers.ProviderClient, db *bun.DB, telemetry bool, analytics utils.Analytics, wp *providers.WorkerPool) {
for _, fetchResources := range listOfSupportedServices() {
resources, err := fetchResources(ctx, client)
if err != nil {
log.Printf("[%s][MongoDBAtlas] %s", client.Name, err)
} else {
for _, resource := range resources {
_, err := db.NewInsert().Model(&resource).On("CONFLICT (resource_id) DO UPDATE").Set("cost = EXCLUDED.cost").Exec(context.Background())
if err != nil {
logrus.WithError(err).Errorf("db trigger failed")
wp.SubmitTask(func() {
resources, err := fetchResources(ctx, client)
if err != nil {
log.Printf("[%s][MongoDBAtlas] %s", client.Name, err)
} else {
for _, resource := range resources {
_, err := db.NewInsert().Model(&resource).On("CONFLICT (resource_id) DO UPDATE").Set("cost = EXCLUDED.cost").Exec(context.Background())
if err != nil {
logrus.WithError(err).Errorf("db trigger failed")
}
}
if telemetry {
analytics.TrackEvent("discovered_resources", map[string]interface{}{
"provider": "MongoDBAtlas",
"resources": len(resources),
})
}

}
if telemetry {
analytics.TrackEvent("discovered_resources", map[string]interface{}{
"provider": "MongoDBAtlas",
"resources": len(resources),
})
}
}
})

}
}
36 changes: 19 additions & 17 deletions providers/ovh/ovh.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,26 @@ func listOfSupportedServices() []providers.FetchDataFunction {
}
}

func FetchResources(ctx context.Context, client providers.ProviderClient, db *bun.DB, telemetry bool, analytics utils.Analytics) {
for _, fetchResources := range listOfSupportedServices() {
resources, err := fetchResources(ctx, client)
if err != nil {
log.Printf("[%s][OVH] %s", client.Name, err)
} else {
for _, resource := range resources {
_, err := db.NewInsert().Model(&resource).On("CONFLICT (resource_id) DO UPDATE").Set("cost = EXCLUDED.cost").Exec(context.Background())
if err != nil {
logrus.WithError(err).Errorf("db trigger failed")
func FetchResources(ctx context.Context, client providers.ProviderClient, db *bun.DB, telemetry bool, analytics utils.Analytics, wp *providers.WorkerPool) {
wp.SubmitTask(func() {
for _, fetchResources := range listOfSupportedServices() {
resources, err := fetchResources(ctx, client)
if err != nil {
log.Printf("[%s][OVH] %s", client.Name, err)
} else {
for _, resource := range resources {
_, err := db.NewInsert().Model(&resource).On("CONFLICT (resource_id) DO UPDATE").Set("cost = EXCLUDED.cost").Exec(context.Background())
if err != nil {
logrus.WithError(err).Errorf("db trigger failed")
}
}
if telemetry {
analytics.TrackEvent("discovered_resources", map[string]interface{}{
"provider": "OVH",
"resources": len(resources),
})
}
}
if telemetry {
analytics.TrackEvent("discovered_resources", map[string]interface{}{
"provider": "OVH",
"resources": len(resources),
})
}
}
}
})
}

0 comments on commit 76c00ce

Please sign in to comment.