(ctx context.Context, client plugin.PluginClient, spec map[string]any)
| 214 | } |
| 215 | |
| 216 | func 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 | } |
no test coverage detected