Skip to content

Commit

Permalink
fixup! Add describe object
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbock committed Sep 9, 2024
1 parent f4badb6 commit 07741d2
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions cmd/salesforce-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"sort"
"strconv"

"github.com/canonical/athena-core/pkg/common"
Expand Down Expand Up @@ -217,22 +218,27 @@ func getDescribeGlobal(sfClient common.SalesforceClient) {
func getDescribe(sfClient common.SalesforceClient, objectName string) {
log.Printf("Getting description of '%s'", objectName)
meta := sfClient.SObject(objectName).Describe()
for fieldName, field := range *meta {
if fieldName == "fields" {
log.Println(" Fields:")
if fieldList, ok := field.([]interface{}); ok {
if fields, ok := fieldList[0].(map[string]interface{}); ok {
for subfieldName, subfield := range fields {
log.Printf(" Field %s: %v", subfieldName, subfield)
fieldNames := []string{}
log.Println("Fields")
for metaKey, metaValue := range *meta {
if metaKey == "fields" {
if fields, ok := metaValue.([]interface{}); ok {
for _, field := range fields {
if fieldMap, ok := field.(map[string]interface{}); ok {
for fieldName, fieldValue := range fieldMap {
if fieldName == "name" {
fieldNames = append(fieldNames, fmt.Sprintf("%s", fieldValue))
}
}
}
}
} else {
log.Fatalf("meta[fields] is not of correct type")
}
} else {
log.Printf(" %s: %v", fieldName, field)
}
}
sort.Strings(fieldNames)
for _, field := range fieldNames {
log.Printf(" %s", field)
}
}

func getAllFeedComments(sfClient common.SalesforceClient) {
Expand Down

0 comments on commit 07741d2

Please sign in to comment.