@@ -999,14 +999,20 @@ func configureVCR(t *testing.T, h *create.Harness) {
999
999
result = strings .Replace (result , os .Getenv ("TEST_ORG_ID" ), "123450001" , - 1 )
1000
1000
}
1001
1001
1002
- // Replace user info
1003
- obj := make (map [string ]any )
1004
- if err := json .Unmarshal ([]byte (s ), & obj ); err == nil {
1005
- toReplace , _ , _ := unstructured .NestedString (obj , "user" )
1006
- if len (toReplace ) != 0 {
1007
- result = strings .
Replace (
result ,
toReplace ,
"[email protected] " ,
- 1 )
1002
+ addReplacement := func (path string , newValue string ) {
1003
+ tokens := strings .Split (path , "." )
1004
+ obj := make (map [string ]any )
1005
+ if err := json .Unmarshal ([]byte (s ), & obj ); err == nil {
1006
+ toReplace , found , _ := unstructured .NestedString (obj , tokens ... )
1007
+ if found {
1008
+ result = strings .Replace (result , toReplace , newValue , - 1 )
1009
+ }
1008
1010
}
1009
1011
}
1012
+ // Replace user info
1013
+ addReplacement (
"user" ,
"[email protected] " )
1014
+ // Replace billing account name
1015
+ addReplacement ("billingAccountName" , "billingAccounts/123456-777777-000001" )
1010
1016
return result
1011
1017
}
1012
1018
0 commit comments