MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / storeManifestFromPluginConfig

Function storeManifestFromPluginConfig

internal/homeplugins/sync.go:553–572  ·  view source on GitHub ↗
(id string, item config.PluginInstanceConfig)

Source from the content-addressed store, hash-verified

551}
552
553func storeManifestFromPluginConfig(id string, item config.PluginInstanceConfig) (sdkpluginstore.Manifest, bool, error) {
554 if item.Raw.Kind == 0 {
555 return sdkpluginstore.Manifest{}, false, nil
556 }
557 storeNode := yamlMappingValue(&item.Raw, "store")
558 if storeNode == nil || storeNode.Kind == 0 {
559 return sdkpluginstore.Manifest{}, false, nil
560 }
561 var manifest sdkpluginstore.Manifest
562 if errDecode := storeNode.Decode(&manifest); errDecode != nil {
563 return sdkpluginstore.Manifest{}, false, fmt.Errorf("home plugins: decode store manifest for %s: %w", id, errDecode)
564 }
565 if strings.TrimSpace(manifest.ID) == "" {
566 manifest.ID = strings.TrimSpace(id)
567 }
568 if errValidate := manifest.Validate(); errValidate != nil {
569 return sdkpluginstore.Manifest{}, false, fmt.Errorf("home plugins: invalid store manifest for %s: %w", id, errValidate)
570 }
571 return manifest, true, nil
572}
573
574func yamlMappingValue(node *yaml.Node, key string) *yaml.Node {
575 if node == nil || node.Kind != yaml.MappingNode {

Callers 1

SyncPlatformWithReportFunction · 0.85

Calls 2

ValidateMethod · 0.95
yamlMappingValueFunction · 0.70

Tested by

no test coverage detected