Skip to content

Commit

Permalink
Verify instancestate
Browse files Browse the repository at this point in the history
  • Loading branch information
HemanthDogiparthi12 committed Sep 27, 2024
1 parent 86257a1 commit db39eaa
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions genesyscloud/tfexporter/genesyscloud_resource_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,14 @@ func (g *GenesysCloudResourceExporter) getResourcesForType(resType string, provi
// will block until it can acquire a pooled client config object.
instanceState, err := getResourceState(ctx, res, id, resMeta, meta)

if instanceState == nil {
log.Printf("Resource %s no longer exists. Skipping.", resMeta.Name)
removeChan <- id // Mark for removal from the map
return nil
}

resourceType := ""

if g.isDataSource(resType, resMeta.Name) {
g.exMutex.Lock()
res = provider.DataSourcesMap[resType]
Expand All @@ -1034,8 +1041,10 @@ func (g *GenesysCloudResourceExporter) getResourcesForType(resType string, provi
attributes := make(map[string]string)

for attr, _ := range schemaMap {
if value, ok := instanceState.Attributes[attr]; ok {
attributes[attr] = value
if instanceState.Attributes != nil {
if value, ok := instanceState.Attributes[attr]; ok {
attributes[attr] = value
}
}
}
instanceState.Attributes = attributes
Expand All @@ -1047,12 +1056,6 @@ func (g *GenesysCloudResourceExporter) getResourcesForType(resType string, provi
return fmt.Errorf(errString)
}

if instanceState == nil {
log.Printf("Resource %s no longer exists. Skipping.", resMeta.Name)
removeChan <- id // Mark for removal from the map
return nil
}

resourceChan <- resourceExporter.ResourceInfo{
State: instanceState,
Name: resMeta.Name,
Expand Down

0 comments on commit db39eaa

Please sign in to comment.