From ae086e4a55ddccf6243106773bf35b9cf8817435 Mon Sep 17 00:00:00 2001 From: Azanul Date: Tue, 27 Feb 2024 11:26:14 +0530 Subject: [PATCH 1/8] feat: mark successful triggering of workflow even without any supported resources Signed-off-by: Azanul --- go.mod | 2 +- go.sum | 20 -------------------- internal/internal.go | 1 + 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 666a156d2..56808c5cf 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/apigateway v1.20.2 github.com/aws/aws-sdk-go-v2/service/autoscaling v1.35.1 github.com/aws/aws-sdk-go-v2/service/cloudfront v1.30.2 + github.com/aws/aws-sdk-go-v2/service/cloudtrail v1.38.0 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.30.2 github.com/aws/aws-sdk-go-v2/service/codecommit v1.18.2 github.com/aws/aws-sdk-go-v2/service/codedeploy v1.20.3 @@ -86,7 +87,6 @@ require ( require ( cloud.google.com/go/longrunning v0.4.1 // indirect github.com/apache/arrow/go/v11 v11.0.0 // indirect - github.com/aws/aws-sdk-go-v2/service/cloudtrail v1.38.0 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/google/s2a-go v0.1.4 // indirect diff --git a/go.sum b/go.sum index 732596a4a..b107cb719 100644 --- a/go.sum +++ b/go.sum @@ -62,10 +62,6 @@ github.com/apache/arrow/go/v11 v11.0.0 h1:hqauxvFQxww+0mEU/2XHG6LT7eZternCZq+A5Y github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI= github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= -github.com/aws/aws-sdk-go-v2 v1.23.1 h1:qXaFsOOMA+HsZtX8WoCa+gJnbyW7qyFFBlPqvTSzbaI= -github.com/aws/aws-sdk-go-v2 v1.23.1/go.mod h1:i1XDttT4rnf6vxc9AuskLc6s7XBee8rlLilKlc03uAA= -github.com/aws/aws-sdk-go-v2 v1.25.0 h1:sv7+1JVJxOu/dD/sz/csHX7jFqmP001TIY7aytBWDSQ= -github.com/aws/aws-sdk-go-v2 v1.25.0/go.mod h1:G104G1Aho5WqF+SR3mDIobTABQzpYV0WxMsKxlMggOA= github.com/aws/aws-sdk-go-v2 v1.25.1 h1:P7hU6A5qEdmajGwvae/zDkOq+ULLC9tQBTwqqiwFGpI= github.com/aws/aws-sdk-go-v2 v1.25.1/go.mod h1:Evoc5AsmtveRt1komDwIsjHFyrP5tDuF1D1U+6z6pNo= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.1 h1:ZY3108YtBNq96jNZTICHxN1gSBSbnvIdYwwqnvCV4Mc= @@ -76,16 +72,8 @@ github.com/aws/aws-sdk-go-v2/credentials v1.16.2 h1:0sdZ5cwfOAipTzZ7eOL0gw4LAhk/ github.com/aws/aws-sdk-go-v2/credentials v1.16.2/go.mod h1:sDdvGhXrSVT5yzBDR7qXz+rhbpiMpUYfF3vJ01QSdrc= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.4 h1:9wKDWEjwSnXZre0/O3+ZwbBl1SmlgWYBbrTV10X/H1s= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.4/go.mod h1:t4i+yGHMCcUNIX1x7YVYa6bH/Do7civ5I6cG/6PMfyA= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.4 h1:LAm3Ycm9HJfbSCd5I+wqC2S9Ej7FPrgr5CQoOljJZcE= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.4/go.mod h1:xEhvbJcyUf/31yfGSQBe01fukXwXJ0gxDp7rLfymWE0= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.0 h1:NPs/EqVO+ajwOoq56EfcGKa3L3ruWuazkIw1BqxwOPw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.0/go.mod h1:D+duLy2ylgatV+yTlQ8JTuLfDD0BnFvnQRc+o6tbZ4M= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.1 h1:evvi7FbTAoFxdP/mixmP7LIYzQWAmzBcwNB/es9XPNc= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.1/go.mod h1:rH61DT6FDdikhPghymripNUCsf+uVF4Cnk4c4DBKH64= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.4 h1:4GV0kKZzUxiWxSVpn/9gwR0g21NF1Jsyduzo9rHgC/Q= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.4/go.mod h1:dYvTNAggxDZy6y1AF7YDwXsPuHFy/VNEpEI/2dWK9IU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.0 h1:ks7KGMVUMoDzcxNWUlEdI+/lokMFD136EL6DWmUOV80= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.0/go.mod h1:hL6BWM/d/qz113fVitZjbXR0E+RCTU1+x+1Idyn5NgE= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.1 h1:RAnaIrbxPtlXNVI/OIlh1sidTQ3e1qM6LRjs7N0bE0I= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.1/go.mod h1:nbgAGkH5lk0RZRMh6A4K/oG6Xj11eC/1CyDow+DUAFI= github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 h1:uR9lXYjdPX0xY+NhvaJ4dD8rpSRz5VY81ccIIoNG+lw= @@ -134,16 +122,12 @@ github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.24.2 h1:4pOJ+1slB github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.24.2/go.mod h1:NatT0jYQo0MfgZnIX8ReNWnbsl4rbQjuS+uci1KNkck= github.com/aws/aws-sdk-go-v2/service/iam v1.27.2 h1:Z3a5I5kKGsuVW4kbrtHVnLGUHpEpo19zFyo6dzP2WCM= github.com/aws/aws-sdk-go-v2/service/iam v1.27.2/go.mod h1:CYRyr95Q57xVvrcKJu3vw4jVVCZhmY1SyugM+EWXlzI= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.1 h1:rpkF4n0CyFcrJUG/rNNohoTmhtWlFTRI4BsZOh9PvLs= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.1/go.mod h1:l9ymW25HOqymeU2m1gbUQ3rUIsTwKs8gYHXkqDQUhiI= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.0 h1:a33HuFlO0KsveiP90IUJh8Xr/cx9US2PqkSroaLc+o8= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.0/go.mod h1:SxIkWpByiGbhbHYTo9CMTUnx2G4p4ZQMrDPcRRy//1c= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.3 h1:xbwRyCy7kXrOj89iIKLB6NfE2WCpP9HoKyk8dMDvnIQ= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.3/go.mod h1:R+/S1O4TYpcktbVwddeOYg+uwUfLhADP2S/x4QwsCTM= github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.3 h1:AakYQhCXteXSRHebRAGDKf/P+3kmEWwiyE3Um/d0ecg= github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.3/go.mod h1:wt1Ib9UX0A8fxifnkYLrv7RAlg+ziPR8Fo0NqzuJkHI= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.3 h1:kJOolE8xBAD13xTCgOakByZkyP4D/owNmvEiioeUNAg= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.3/go.mod h1:Owv1I59vaghv1Ax8zz8ELY8DN7/Y0rGS+WWAmjgi950= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.0 h1:SHN/umDLTmFTmYfI+gkanz6da3vK8Kvj/5wkqnTHbuA= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.0/go.mod h1:l8gPU5RYGOFHJqWEpPMoRTP0VoaWQSkJdKo+hwWnnDA= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.3 h1:KV0z2RDc7euMtg8aUT1czv5p29zcLlXALNFsd3jkkEc= @@ -186,10 +170,6 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0 h1:/XiEU7VIFcVWRDQLabyrSjBo github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0/go.mod h1:dWqm5G767qwKPuayKfzm4rjzFmVjiBFbOJrpSPnAMDs= github.com/aws/aws-sdk-go-v2/service/sts v1.25.3 h1:M2w4kiMGJCCM6Ljmmx/l6mmpfa3gPJVpBencfnsgvqs= github.com/aws/aws-sdk-go-v2/service/sts v1.25.3/go.mod h1:4EqRHDCKP78hq3zOnmFXu5k0j4bXbRFfCh/zQ6KnEfQ= -github.com/aws/smithy-go v1.17.0 h1:wWJD7LX6PBV6etBUwO0zElG0nWN9rUhp0WdYeHSHAaI= -github.com/aws/smithy-go v1.17.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= -github.com/aws/smithy-go v1.20.0 h1:6+kZsCXZwKxZS9RfISnPc4EXlHoyAkm2hPuM8X2BrrQ= -github.com/aws/smithy-go v1.20.0/go.mod h1:uo5RKksAl4PzhqaAbjd4rLgFoq5koTsQKYuGe7dklGc= github.com/aws/smithy-go v1.20.1 h1:4SZlSlMr36UEqC7XOyRVb27XMeZubNcBNN+9IgEPIQw= github.com/aws/smithy-go v1.20.1/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= diff --git a/internal/internal.go b/internal/internal.go index 75a43ac6e..368ab6bad 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -300,6 +300,7 @@ func fetchResources(ctx context.Context, clients []providers.ProviderClient, reg } else if client.OVHClient != nil { workflowTrigger(client, "OVH") } + log.Println("Workflow triggered for client:", client.Name) } wwg.Wait() From e32299e802adba5d6b60ef7443173fd82a336be4 Mon Sep 17 00:00:00 2001 From: Azanul Date: Sat, 2 Mar 2024 11:34:58 +0530 Subject: [PATCH 2/8] feat: engines entry Signed-off-by: Azanul --- dashboard/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dashboard/package.json b/dashboard/package.json index 312ba57c8..5ae685ecd 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -2,6 +2,9 @@ "name": "komiser-dashboard", "version": "3.1.0", "private": true, + "engines": { + "node": ">=14.21.3" + }, "scripts": { "dev": "next dev -p 3002", "build": "next build", From 64650a2a20a612406dc94e88cefd70722aa283f0 Mon Sep 17 00:00:00 2001 From: Azanul Date: Tue, 5 Mar 2024 17:03:25 +0530 Subject: [PATCH 3/8] feat: reduce code duplication Signed-off-by: Azanul --- dashboard/pages/onboarding/choose-database.tsx | 4 ++-- dashboard/utils/providerHelper.ts | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dashboard/pages/onboarding/choose-database.tsx b/dashboard/pages/onboarding/choose-database.tsx index 3976a3767..e27771001 100644 --- a/dashboard/pages/onboarding/choose-database.tsx +++ b/dashboard/pages/onboarding/choose-database.tsx @@ -111,14 +111,14 @@ export default function ChooseDatabase() { diff --git a/dashboard/utils/providerHelper.ts b/dashboard/utils/providerHelper.ts index e4155e737..2077ba5df 100644 --- a/dashboard/utils/providerHelper.ts +++ b/dashboard/utils/providerHelper.ts @@ -48,12 +48,11 @@ export const allProviders: { [key in ProviderKey]: Provider } = { }; export type DBProvider = 'postgres' | 'sqlite'; -type DBProviderKey = 'POSTGRES' | 'SQLITE'; -export const allDBProviders: { [key in DBProviderKey]: DBProvider } = { - POSTGRES: 'postgres', - SQLITE: 'sqlite' -}; +export enum allDBProviders { + POSTGRES = 'postgres', + SQLITE = 'sqlite' +} export enum IntegrationProvider { SLACK = 'slack', From 252bf731318ca33dd33dc6c9ae8603b8d7bec5e0 Mon Sep 17 00:00:00 2001 From: Azanul Date: Fri, 8 Mar 2024 10:00:43 +0530 Subject: [PATCH 4/8] feat: update codeowners Signed-off-by: Azanul --- .github/CODEOWNERS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0d3c9b20d..d354b4ae6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ -* @mlabouardy @ShubhamPalriwala @AvineshTripathi @greghub @Traxmaxx @Kolawole99 @Azanul @jakepage91 -docs @jakepage91 -README.md @jakepage91 -CONTRIBUTING.md @jakepage91 +* @mlabouardy @AvineshTripathi @greghub @Azanul +docs @mlabouardy +README.md @mlabouardy +CONTRIBUTING.md @mlabouardy From 6ccc4acdaf86bc3037c700b75870396346e4dd33 Mon Sep 17 00:00:00 2001 From: Azanul Date: Wed, 13 Mar 2024 12:22:36 +0530 Subject: [PATCH 5/8] feat: Azure cost PoC Signed-off-by: Azanul --- go.mod | 19 ++++++----- go.sum | 37 ++++++++++++--------- providers/azure/compute/virtual_machines.go | 28 +++++++++++++++- 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 56808c5cf..3901459b9 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( cloud.google.com/go/monitoring v1.13.0 cloud.google.com/go/redis v1.11.0 cloud.google.com/go/storage v1.30.0 - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4 v4.1.0 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 @@ -68,7 +68,7 @@ require ( github.com/siruspen/logrus v1.7.1 github.com/slack-go/slack v0.12.1 github.com/spf13/cobra v1.6.1 - github.com/stretchr/testify v1.8.3 + github.com/stretchr/testify v1.8.4 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.582 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.582 github.com/uptrace/bun v1.1.8 @@ -89,6 +89,7 @@ require ( github.com/apache/arrow/go/v11 v11.0.0 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.0 // indirect github.com/google/s2a-go v0.1.4 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect @@ -99,8 +100,9 @@ require ( cloud.google.com/go/certificatemanager v1.6.0 cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v0.13.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement v1.1.1 + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect github.com/andybalholm/brotli v1.0.4 // indirect github.com/apache/thrift v0.16.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.1 // indirect @@ -143,7 +145,6 @@ require ( github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v2.0.8+incompatible // indirect @@ -151,7 +152,7 @@ require ( github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.1.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect @@ -178,7 +179,7 @@ require ( github.com/openlyinc/pointy v1.2.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pierrec/lz4/v4 v4.1.15 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect @@ -196,7 +197,7 @@ require ( golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/net v0.19.0 // indirect golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect diff --git a/go.sum b/go.sum index b107cb719..f3558b11d 100644 --- a/go.sum +++ b/go.sum @@ -26,16 +26,18 @@ cloud.google.com/go/redis v1.11.0 h1:JoAd3SkeDt3rLFAAxEvw6wV4t+8y4ZzfZcZmddqphQ8 cloud.google.com/go/redis v1.11.0/go.mod h1:/X6eicana+BWcUda5PpwZC48o37SiFVTFSs0fWAJ7uQ= cloud.google.com/go/storage v1.30.0 h1:g1yrbxAWOrvg/594228pETWkOi00MLTrOWfh56veU5o= cloud.google.com/go/storage v1.30.0/go.mod h1:xAVretHSROm1BQX4IIsoVgJqw0LqOyX+I/O2GzRAzdE= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.1 h1:gVXuXcWd1i4C2Ruxe321aU+IKGaStvGB/S90PUPB/W8= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.1/go.mod h1:DffdKW9RFqa5VgmsjUOsS7UE7eiA5iAvYUs63bhKQ0M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 h1:sO0/P7g68FrryJzljemN+6GTssUXdANk6aJ7T1ZxnsQ= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v3 v3.0.1 h1:H3g2mkmu105ON0c/Gqx3Bm+bzoIijLom8LmV9Gjn7X0= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v3 v3.0.1/go.mod h1:EAc3kjhZf9soch7yLID8PeKcE6VfKvQTllSBHYVdXd8= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4 v4.1.0 h1:Vjq3Uy3JAU1DTxbA+uX6BegIhgO2pyFltbfbmDa9KdI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4 v4.1.0/go.mod h1:Q3u+T/qw3Kb1Wf3DFKiFwEZlyaAyPb4yBgWm9wq7yh8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement v1.1.1 h1:ehSLdbLah6kk6HTVc6e/lrbmbz7MMbpNxkOd3OYlhB0= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement v1.1.1/go.mod h1:Am1cUioOk0HdZIsjpXJkQ4RIeQbwYsW6LkNIc5z/5XY= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databox/armdatabox v1.0.0 h1:s55dRuEFkOZTkZNbaiwkTa7qv8un39PTo/YPUpciQY0= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databox/armdatabox v1.0.0/go.mod h1:43obBGNGAM/4TLKn6H25WZgNyASDm7CgnTfTDlibyvI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.0.0 h1:lMW1lD/17LUA5z1XTURo7LcVG2ICBPlyMHjIUrcFZNQ= @@ -48,8 +50,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.0.0 h1:rycGP 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= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0/go.mod h1:c+Lifp3EDEamAkPVzMooRNOK6CZjNSdEnf1A7jsI9u4= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -268,8 +270,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -320,8 +322,9 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= @@ -432,8 +435,8 @@ github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0 github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -482,8 +485,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.582 h1:Td+y4Y5xkPq5pa7DgMK09ycp5lPnx2UZ7GMLMvhW7Ns= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.582/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.582 h1:I9ihQehFbwNzVA23auWISoKc57BcyZSdsXznEoQLb94= @@ -566,8 +570,8 @@ golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= @@ -606,6 +610,7 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/providers/azure/compute/virtual_machines.go b/providers/azure/compute/virtual_machines.go index 67b715423..22e86812b 100644 --- a/providers/azure/compute/virtual_machines.go +++ b/providers/azure/compute/virtual_machines.go @@ -6,7 +6,10 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement" log "github.com/sirupsen/logrus" "github.com/tailwarden/komiser/models" @@ -21,6 +24,11 @@ func VirtualMachines(ctx context.Context, client providers.ProviderClient) ([]mo return resources, err } + costClient, err := armcostmanagement.NewQueryClient(client.AzureClient.Credentials, &policy.ClientOptions{}) + if err != nil { + return resources, err + } + pager := svc.NewListAllPager(nil) for pager.More() { page, err := pager.NextPage(ctx) @@ -30,6 +38,24 @@ func VirtualMachines(ctx context.Context, client providers.ProviderClient) ([]mo for _, vm := range page.VirtualMachineListResult.Value { tags := make([]models.Tag, 0) + queryResult, err := costClient.Usage(ctx, "subscriptions/"+client.AzureClient.SubscriptionId, armcostmanagement.QueryDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypeUsage), + Dataset: &armcostmanagement.QueryDataset{ + Aggregation: map[string]*armcostmanagement.QueryAggregation{ + "totalCost": { + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), + }, + }, + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + }, nil) + if err != nil { + return resources, err + } + + cost := queryResult.Properties.Rows[0][0].(float64) for key, value := range vm.Tags { tags = append(tags, models.Tag{ @@ -44,7 +70,7 @@ func VirtualMachines(ctx context.Context, client providers.ProviderClient) ([]mo Service: "Virtual Machine", Region: *vm.Location, ResourceId: *vm.ID, - Cost: 0, + Cost: cost, Name: *vm.Name, FetchedAt: time.Now(), Tags: tags, From 98186b582b154b847ab0f6a8fb8d45c5b50d870f Mon Sep 17 00:00:00 2001 From: Azanul Date: Wed, 13 Mar 2024 16:57:39 +0530 Subject: [PATCH 6/8] feat: log schema setup err Signed-off-by: Azanul --- utils/database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/database.go b/utils/database.go index 74239fc6c..84f3daf16 100644 --- a/utils/database.go +++ b/utils/database.go @@ -35,7 +35,7 @@ func SetupSchema(db *bun.DB, c *models.Config, accounts []models.Account) error account.Status = "CONNECTED" _, err = db.NewInsert().Model(&account).Exec(context.Background()) if err != nil { - log.Warnf("%s account cannot be inserted to database", account.Provider) + log.Warnf("%s account cannot be inserted to database\n%v", account.Provider, err) } } From 5c7abbfbfaa46f157350171dddb5862d9210dd89 Mon Sep 17 00:00:00 2001 From: Azanul Date: Sat, 16 Mar 2024 04:24:09 +0530 Subject: [PATCH 7/8] feat: log usage err Signed-off-by: Azanul --- providers/azure/compute/virtual_machines.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/azure/compute/virtual_machines.go b/providers/azure/compute/virtual_machines.go index 22e86812b..48f308449 100644 --- a/providers/azure/compute/virtual_machines.go +++ b/providers/azure/compute/virtual_machines.go @@ -52,7 +52,7 @@ func VirtualMachines(ctx context.Context, client providers.ProviderClient) ([]mo Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { - return resources, err + log.Warnf("failed to query usage: %v\n", err) } cost := queryResult.Properties.Rows[0][0].(float64) From 180eee721d6e16341b21a248759524bb5aceddb3 Mon Sep 17 00:00:00 2001 From: Azanul Date: Thu, 28 Mar 2024 15:17:18 +0530 Subject: [PATCH 8/8] fix: aws config env vars support Signed-off-by: Azanul --- handlers/helper.go | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/handlers/helper.go b/handlers/helper.go index ca22e10f6..e26ccfbd9 100644 --- a/handlers/helper.go +++ b/handlers/helper.go @@ -370,10 +370,14 @@ func populateConfigFromAccount(account models.Account, config *models.Config) er switch account.Provider { case "aws": awsConfig := models.AWSConfig{ - Name: account.Name, - Profile: account.Credentials["profile"], - Path: account.Credentials["path"], - Source: account.Credentials["source"], + Name: account.Name, + Source: account.Credentials["source"], + } + if account.Credentials["source"] == "credentials-file" { + awsConfig.Profile = account.Credentials["profile"] + if path, ok := account.Credentials["path"]; ok && len(path) > 0 { + awsConfig.Path = account.Credentials["path"] + } } config.AWS = append(config.AWS, awsConfig) @@ -443,38 +447,38 @@ func populateConfigFromAccount(account models.Account, config *models.Config) er case "mongodb": mongoDBAtlasConfig := models.MongoDBAtlasConfig{ - Name: account.Name, - PublicApiKey: account.Credentials["publicKey"], - PrivateApiKey: account.Credentials["privateKey"], + Name: account.Name, + PublicApiKey: account.Credentials["publicKey"], + PrivateApiKey: account.Credentials["privateKey"], OrganizationID: account.Credentials["organizationId"], } config.MongoDBAtlas = append(config.MongoDBAtlas, mongoDBAtlasConfig) case "gcp": gcpConfig := models.GCPConfig{ - Name: account.Name, + Name: account.Name, ServiceAccountKeyPath: account.Credentials["accountKey"], } config.GCP = append(config.GCP, gcpConfig) case "ovh": ovhConfig := models.OVHConfig{ - Name: account.Name, - Endpoint: account.Credentials["endpoint"], - ApplicationKey: account.Credentials["applicationKey"], + Name: account.Name, + Endpoint: account.Credentials["endpoint"], + ApplicationKey: account.Credentials["applicationKey"], ApplicationSecret: account.Credentials["applicationSecret"], - ConsumerKey: account.Credentials["consumerKey"], + ConsumerKey: account.Credentials["consumerKey"], } config.OVH = append(config.OVH, ovhConfig) default: - return fmt.Errorf("Illegle provider") + return fmt.Errorf("illegle provider") } return nil } -func updateConfig(path string, cfg *models.Config) error { +func updateConfig(path string, cfg *models.Config) error { mu.Lock() defer mu.Unlock() @@ -491,4 +495,4 @@ func updateConfig(path string, cfg *models.Config) error { return err } return nil -} \ No newline at end of file +}