Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/dashboard/storybo…
Browse files Browse the repository at this point in the history
…ok/addon-links-8.1.11
  • Loading branch information
Azanul authored Jul 18, 2024
2 parents f5397c7 + 7630904 commit 94a9f9b
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 55 deletions.
102 changes: 51 additions & 51 deletions dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"react": "18.3.1",
"react-chartjs-2": "^5.2.0",
"react-cytoscapejs": "^2.0.0",
"react-dom": "18.2.0",
"react-dom": "18.3.1",
"react-drag-drop-files": "^2.3.10",
"react-simple-maps": "3.0.0",
"typescript": "5.2.2"
Expand All @@ -61,7 +61,7 @@
"@types/node": "20.11.21",
"@types/react": "18.3.3",
"@types/react-cytoscapejs": "^1.2.5",
"@types/react-dom": "18.2.18",
"@types/react-dom": "18.3.0",
"@types/react-simple-maps": "^3.0.2",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
Expand All @@ -74,7 +74,7 @@
"husky": "^9.0.11",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.6.4",
"postcss": "^8.4.31",
"postcss": "^8.4.39",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.12",
"storybook": "^8.1.10",
Expand Down
3 changes: 2 additions & 1 deletion dashboard/utils/serviceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const allProvidersServices: { [key in Providers]: string[] } = {
'firewall',
'load balancer',
'databox',
'queue'
'queue',
'local network gateway'
],
civo: [
'compute',
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement v1.1.1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databox/armdatabox v1.0.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.0.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0
github.com/BurntSushi/toml v1.2.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0/go.mod h1:243D9iHbcQXoFUtgHJwL7gl2zx1aDuDMjvBZVGr2uW0=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 h1:Dd+RhdJn0OTtVGaeDLZpcumkIVCtA/3/Fo42+eoYvVM=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0/go.mod h1:5kakwfW5CjC9KK+Q4wjXAg+ShuIm2mBMua0ZFj2C8PE=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.0.0 h1:rycGPpUtVFwM9uLUL2ux8EL8kGfl3qF1u76aEHvB4Qw=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.0.0/go.mod h1:lirt6L2DmxromyM4w5Vd2QPz4PrWRV38Izy43xgkBVI=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
Expand Down
1 change: 1 addition & 0 deletions providers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func listOfSupportedServices() []providers.FetchDataFunction {
networking.ApplicationGateways,
networking.LoadBalancers,
networking.Firewalls,
networking.LocalNetworkGateways,
storage.Queues,
storage.Tables,
storage.Databoxes,
Expand Down
80 changes: 80 additions & 0 deletions providers/azure/networking/local_network_gateways.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package networking

import (
"context"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork"
log "github.com/sirupsen/logrus"
"github.com/tailwarden/komiser/providers/azure/resourcegroup"
"time"

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

func LocalNetworkGateways(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) {
resources := make([]models.Resource, 0)
resourceGroups, err := resourcegroup.ResourceGroups(ctx, client)
if err != nil {
return resources, err
}

if len(resourceGroups) < 1 {
return resources, nil
}

localNetworkGatewayClient, err := armnetwork.NewLocalNetworkGatewaysClient(
client.AzureClient.SubscriptionId,
client.AzureClient.Credentials,
&arm.ClientOptions{},
)
if err != nil {
return resources, err
}

// check resources on each resource group
for _, rg := range resourceGroups {
pager := localNetworkGatewayClient.NewListPager(
rg.Name, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
return resources, err
}

for _, lng := range page.LocalNetworkGatewayListResult.Value {
tags := make([]models.Tag, 0)

for key, value := range lng.Tags {
tags = append(tags, models.Tag{
Key: key,
Value: *value,
})
}

resources = append(resources, models.Resource{
Provider: "Azure",
Account: client.Name,
Service: "Local Network Gateway",
Region: *lng.Location,
ResourceId: *lng.ID,
Cost: 0,
Name: *lng.Name,
FetchedAt: time.Now(),
Tags: tags,
Link: fmt.Sprintf("https://portal.azure.com/#resource%s", *lng.ID),
})
}
}
}

log.WithFields(log.Fields{
"provider": "Azure",
"account": client.Name,
"service": "Local Network Gateway",
"resources": len(resources),
}).Info("Fetched resources")

return resources, nil
}
68 changes: 68 additions & 0 deletions providers/azure/resourcegroup/resource_groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package resourcegroup

import (
"context"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
log "github.com/sirupsen/logrus"
"github.com/tailwarden/komiser/models"
"github.com/tailwarden/komiser/providers"
"time"
)

func ResourceGroups(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) {
resources := make([]models.Resource, 0)

resourceGroupClient, err := armresources.NewResourceGroupsClient(
client.AzureClient.SubscriptionId,
client.AzureClient.Credentials,
&arm.ClientOptions{},
)

if err != nil {
return resources, err
}

pager := resourceGroupClient.NewListPager(nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
return resources, err
}

for _, resourceGroup := range page.ResourceGroupListResult.Value {

tags := make([]models.Tag, 0)

for key, value := range resourceGroup.Tags {
tags = append(tags, models.Tag{
Key: key,
Value: *value,
})
}

resources = append(resources, models.Resource{
Provider: "Azure",
Account: client.Name,
Service: "Resource Group",
Region: *resourceGroup.Location,
ResourceId: *resourceGroup.ID,
Cost: 0,
Name: *resourceGroup.Name,
FetchedAt: time.Now(),
Tags: tags,
Link: fmt.Sprintf("https://portal.azure.com/#resource%s", *resourceGroup.ID),
})
}
}

log.WithFields(log.Fields{
"provider": "Azure",
"account": client.Name,
"service": "Resource Group",
"resources": len(resources),
}).Info("Fetched resource groups")

return resources, nil
}

0 comments on commit 94a9f9b

Please sign in to comment.