Skip to content

Commit

Permalink
updating fetching resources for civo and tencent
Browse files Browse the repository at this point in the history
Signed-off-by: bishal7679 <[email protected]>
  • Loading branch information
bishal7679 committed Nov 17, 2023
1 parent 9a8b3f1 commit 548721e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions providers/civo/civo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ func listOfSupportedServices() []providers.FetchDataFunction {

func FetchResources(ctx context.Context, client providers.ProviderClient, db *bun.DB, telemetry bool, analytics utils.Analytics, wp *providers.WorkerPool) {
for _, fetchResources := range listOfSupportedServices() {
wp.SubmitTask(func() {
regions, err := client.CivoClient.ListRegions()
regions, err := client.CivoClient.ListRegions()
if err != nil {
log.Printf("[%s][Civo] %s", client.Name, err)
}

for _, region := range regions {
clientWithRegion, err := civogo.NewClient(client.CivoClient.APIKey, region.Code)
if err != nil {
log.Printf("[%s][Civo] %s", client.Name, err)
}

for _, region := range regions {
clientWithRegion, err := civogo.NewClient(client.CivoClient.APIKey, region.Code)
if err != nil {
log.Printf("[%s][Civo] %s", client.Name, err)
}

client.CivoClient = clientWithRegion
client.CivoClient = clientWithRegion

wp.SubmitTask(func() {
resources, err := fetchResources(ctx, client)
if err != nil {
log.Printf("[%s][Civo] %s", client.Name, err)
Expand All @@ -61,7 +61,7 @@ func FetchResources(ctx context.Context, client providers.ProviderClient, db *bu
})
}
}
}
})
})
}
}
}
28 changes: 14 additions & 14 deletions providers/tencent/tencent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ func listOfSupportedServices() []providers.FetchDataFunction {

func FetchResources(ctx context.Context, client providers.ProviderClient, db *bun.DB, telemetry bool, analytics utils.Analytics, wp *providers.WorkerPool) {
for _, fetchResources := range listOfSupportedServices() {
wp.SubmitTask(func() {
regions, err := client.TencentClient.DescribeRegionsWithContext(ctx, tccvm.NewDescribeRegionsRequest())
regions, err := client.TencentClient.DescribeRegionsWithContext(ctx, tccvm.NewDescribeRegionsRequest())
if err != nil {
log.Errorf("[%s][Tencent] Couldn't fetch the list of regions: %s", client.Name, err)
}

for _, region := range regions.Response.RegionSet {
cpf := profile.NewClientProfile()
cpf.Language = "en-US"
clientWithRegion, err := tccvm.NewClient(client.TencentClient.GetCredential(), *region.Region, cpf)
if err != nil {
log.Errorf("[%s][Tencent] Couldn't fetch the list of regions: %s", client.Name, err)
log.Errorf("[%s][Tencent] Couldn't create the Tencent client with region %s: %s", client.Name, *region.Region, err)
}

for _, region := range regions.Response.RegionSet {
cpf := profile.NewClientProfile()
cpf.Language = "en-US"
clientWithRegion, err := tccvm.NewClient(client.TencentClient.GetCredential(), *region.Region, cpf)
if err != nil {
log.Errorf("[%s][Tencent] Couldn't create the Tencent client with region %s: %s", client.Name, *region.Region, err)
}

client.TencentClient = clientWithRegion
client.TencentClient = clientWithRegion

wp.SubmitTask(func() {
resources, err := fetchResources(ctx, client)
if err != nil {
log.Printf("[%s][Tencent] %s", client.Name, err)
Expand All @@ -55,7 +55,7 @@ func FetchResources(ctx context.Context, client providers.ProviderClient, db *bu
})
}
}
}
})
})
}
}
}

0 comments on commit 548721e

Please sign in to comment.