@@ -11,6 +11,7 @@ import (
1111 "sort"
1212 "time"
1313 "errors"
14+ "reflect"
1415 "strings"
1516 "io/ioutil"
1617 "crypto/md5"
@@ -79,7 +80,7 @@ func SaveQuery(inputStandard, gptTranslated string, shuffleConfig ShuffleConfig)
7980 }
8081
8182 if debug {
82- log .Printf ("[DEBUG] Schemaless: Translation saved to %s" , filename )
83+ log .Printf ("[DEBUG] Schemaless: Translation saved to %s (1) " , filename )
8384 }
8485
8586 return nil
@@ -433,7 +434,7 @@ func SaveTranslation(inputStandard, gptTranslated string, shuffleConfig ShuffleC
433434 }
434435
435436 if debug {
436- log .Printf ("[DEBUG] Schemaless: Translation saved to %s" , filename )
437+ log .Printf ("[DEBUG] Schemaless: Translation saved to %s (2) " , filename )
437438 }
438439
439440 return nil
@@ -462,9 +463,11 @@ func SaveParsedInput(inputStandard string, gptTranslated []byte, shuffleConfig S
462463 return err
463464 }
464465
466+ /*
465467 if debug {
466- log .Printf ("[DEBUG] Schemaless: Translation saved to %s" , filename )
468+ log.Printf("[DEBUG] Schemaless: Response keys saved to %s (3) ", filename)
467469 }
470+ */
468471
469472 return nil
470473}
@@ -528,6 +531,14 @@ func LoadAndSaveStandard(inputStandard string) (error) {
528531 owner := "shuffle"
529532 repo := "standards"
530533 path := "translation_standards"
534+ if os .Getenv ("GIT_DOWNLOAD_USER" ) != "" {
535+ owner = os .Getenv ("GIT_DOWNLOAD_USER" )
536+ }
537+
538+ if os .Getenv ("GIT_DOWNLOAD_REPO" ) != "" {
539+ repo = os .Getenv ("GIT_DOWNLOAD_REPO" )
540+ }
541+
531542 foundFiles , err := LoadStandardFromGithub (* client , owner , repo , path , inputStandard )
532543
533544 if debug {
@@ -645,7 +656,7 @@ func GetExistingStructure(inputStandard string, shuffleConfig ShuffleConfig) ([]
645656}
646657
647658// Recurses to find keys deeper in the thingy
648- // FIXME: Does not support loops yet
659+ // FIXME: Does NOT support loops yet
649660// Should be able to handle jq/shuffle-json format
650661func recurseFindKey (input map [string ]interface {}, key string , depth int ) (string , error ) {
651662 keys := strings .Split (key , "." )
@@ -659,7 +670,10 @@ func recurseFindKey(input map[string]interface{}, key string, depth int) (string
659670 }
660671
661672 if len (keys ) == 1 {
662- if val , ok := v .(string ); ok {
673+ // Check if v is nil
674+ if v == nil {
675+ return "" , nil
676+ } else if val , ok := v .(string ); ok {
663677 return val , nil
664678 } else if val , ok := v .(map [string ]interface {}); ok {
665679 if b , err := json .MarshalIndent (val , "" , "\t " ); err != nil {
@@ -680,7 +694,7 @@ func recurseFindKey(input map[string]interface{}, key string, depth int) (string
680694 } else if val , ok := v .(int ); ok {
681695 return fmt .Sprintf ("%v" , val ), nil
682696 } else {
683- return "" , fmt .Errorf ("Value is not a string or map[string]interface{}" )
697+ return "" , fmt .Errorf ("Value is not a string or map[string]interface{}, but %#v" , reflect . TypeOf ( v ) )
684698 }
685699
686700 return v .(string ), nil
0 commit comments