MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / testPluginConnection

Function testPluginConnection

cli/cmd/test_connection.go:216–259  ·  view source on GitHub ↗
(ctx context.Context, client plugin.PluginClient, spec map[string]any)

Source from the content-addressed store, hash-verified

214}
215
216func testPluginConnection(ctx context.Context, client plugin.PluginClient, spec map[string]any) (*testConnectionResult, error) {
217 specBytes, err := marshalSpec(spec)
218 if err != nil {
219 return nil, err
220 }
221
222 in := &plugin.TestConnection_Request{
223 Spec: specBytes,
224 }
225
226 resp, err := client.TestConnection(ctx, in)
227 if err != nil {
228 if gRPCErr, ok := grpcstatus.FromError(err); ok {
229 if gRPCErr.Code() == codes.Unimplemented {
230 if !env.IsCloud() {
231 return &testConnectionResult{
232 Success: false,
233 FailureCode: "UNIMPLEMENTED",
234 FailureDescription: gRPCErr.Message(),
235 }, nil
236 }
237 err := initPlugin(ctx, client, spec, false, invocationUUID.String())
238 if err != nil {
239 return &testConnectionResult{
240 Success: false,
241 FailureCode: "OTHER",
242 FailureDescription: secretAwareRedactor.RedactStr(err.Error()),
243 }, nil
244 }
245
246 return &testConnectionResult{
247 Success: true,
248 }, nil
249 }
250 }
251 return nil, err
252 }
253
254 return &testConnectionResult{
255 Success: resp.Success,
256 FailureCode: resp.FailureCode,
257 FailureDescription: secretAwareRedactor.RedactStr(resp.FailureDescription),
258 }, nil
259}

Callers 1

testConnectionFunction · 0.85

Calls 5

RedactStrMethod · 0.80
marshalSpecFunction · 0.70
initPluginFunction · 0.70
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected