MCPcopy Index your code
hub / github.com/devspace-sh/devspace / List

Method List

pkg/devspace/plugin/plugin.go:232–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230}
231
232func (c *client) List() ([]Metadata, error) {
233 pluginFolder, err := c.PluginFolder()
234 if err != nil {
235 return nil, err
236 }
237
238 _, err = os.Stat(pluginFolder)
239 if err != nil {
240 if os.IsNotExist(err) {
241 return []Metadata{}, nil
242 }
243
244 return nil, err
245 }
246
247 plugins, err := os.ReadDir(pluginFolder)
248 if err != nil {
249 return nil, err
250 }
251
252 retMetadatas := []Metadata{}
253 for _, dirEntry := range plugins {
254 plugin, err := dirEntry.Info()
255 if err != nil {
256 continue
257 }
258
259 pFolder := filepath.Join(pluginFolder, plugin.Name())
260 metadataFileContents, err := os.ReadFile(filepath.Join(pFolder, pluginYaml))
261 if os.IsNotExist(err) {
262 _ = os.RemoveAll(filepath.Join(pluginFolder, plugin.Name()))
263 continue
264 }
265
266 metadata := Metadata{}
267 err = yaml.Unmarshal(metadataFileContents, &metadata)
268 if err != nil {
269 c.log.Warnf("Error parsing plugin.yaml for plugin %s: %v", plugin, err)
270 continue
271 }
272
273 metadata.PluginFolder = pFolder
274 retMetadatas = append(retMetadatas, metadata)
275 }
276
277 return retMetadatas, nil
278}
279
280func (c *client) GetByName(name string) (string, *Metadata, error) {
281 pluginFolder, err := c.PluginFolder()

Callers

nothing calls this directly

Calls 4

PluginFolderMethod · 0.95
NameMethod · 0.65
InfoMethod · 0.45
WarnfMethod · 0.45

Tested by

no test coverage detected