@@ -60,6 +60,10 @@ type Interface interface {
60
60
// errorRegex is used to parse Python tracebacks generated by mysql-shell.
61
61
var errorRegex = regexp .MustCompile (`Traceback.*\n(?: (.*)\n){1,}(?P<type>[\w\.]+)\: (?P<message>.*)` )
62
62
63
+ func sanitizeJSON (json []byte ) []byte {
64
+ return bytes .Replace (json , []byte ("\\ '" ), []byte ("'" ), - 1 )
65
+ }
66
+
63
67
// New creates a new MySQL Shell Interface.
64
68
func New (exec utilexec.Interface , uri string ) Interface {
65
69
return & runner {exec : exec , uri : uri }
@@ -101,7 +105,7 @@ func (r *runner) CreateCluster(ctx context.Context, opts Options) (*innodb.Clust
101
105
}
102
106
103
107
status := & innodb.ClusterStatus {}
104
- err = json .Unmarshal ([]byte (jsonData ), status )
108
+ err = json .Unmarshal (sanitizeJSON ( []byte (jsonData ) ), status )
105
109
if err != nil {
106
110
return nil , errors .Wrapf (err , "decoding cluster status output: %q" , output )
107
111
}
@@ -116,7 +120,7 @@ func (r *runner) GetClusterStatus(ctx context.Context) (*innodb.ClusterStatus, e
116
120
}
117
121
118
122
status := & innodb.ClusterStatus {}
119
- err = json .Unmarshal (output , status )
123
+ err = json .Unmarshal (sanitizeJSON ( output ) , status )
120
124
if err != nil {
121
125
return nil , errors .Wrapf (err , "decoding cluster status output: %q" , output )
122
126
}
@@ -132,7 +136,7 @@ func (r *runner) CheckInstanceState(ctx context.Context, uri string) (*innodb.In
132
136
}
133
137
134
138
state := & innodb.InstanceState {}
135
- err = json .Unmarshal (output , state )
139
+ err = json .Unmarshal (sanitizeJSON ( output ) , state )
136
140
if err != nil {
137
141
return nil , fmt .Errorf ("decoding instance state: %v" , err )
138
142
}
0 commit comments