validatePluginSpec encompasses spec validation against a plugin obtained over gRPC. Schema acquisition and validation are kept lenient so that a buggy or out-of-date plugin cannot block validation entirely: 1. Get spec schema from the plugin. If the call isn't implemented, just skip the validation.
(ctx context.Context, client plugin.PluginClient, spec any)
| 117 | // 3. If the schema isn't empty but not valid, print the error message & skip the validation. |
| 118 | // 4. Finally, return the validation result. |
| 119 | func validatePluginSpec(ctx context.Context, client plugin.PluginClient, spec any) error { |
| 120 | schema, err := client.GetSpecSchema(ctx, &plugin.GetSpecSchema_Request{}) |
| 121 | if err != nil { |
| 122 | st, ok := status.FromError(err) |
| 123 | if !ok { |
| 124 | // not a gRPC-compatible error |
| 125 | log.Err(err).Msg("failed to get spec schema") |
| 126 | return err |
| 127 | } |
| 128 | if st.Code() != codes.Unimplemented { |
| 129 | // unimplemented is OK, treat as empty schema |
| 130 | log.Err(err).Msg("failed to get spec schema") |
| 131 | return err |
| 132 | } |
| 133 | } |
| 134 | return validateSpecAgainstSchema(schema.GetJsonSchema(), spec) |
| 135 | } |
| 136 | |
| 137 | // validateSpecAgainstSchema validates spec against a JSON schema string. |
| 138 | // Mirrors the lenient gRPC-side semantics: an empty or unparseable schema |
no test coverage detected