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

Function validatePluginSpec

cli/cmd/specs.go:119–135  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
119func 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

Callers 1

validateConfigFunction · 0.85

Calls 1

Tested by

no test coverage detected