MCPcopy Create free account
hub / github.com/jetify-com/devbox / getConfigIfAny

Function getConfigIfAny

internal/plugin/files.go:17–41  ·  view source on GitHub ↗
(inc Includable, projectDir string)

Source from the content-addressed store, hash-verified

15)
16
17func getConfigIfAny(inc Includable, projectDir string) (*Config, error) {
18 switch includable := inc.(type) {
19 case *devpkg.Package:
20 return getBuiltinPluginConfigIfExists(includable, projectDir)
21 case *githubPlugin:
22 content, err := includable.Fetch()
23 if err != nil {
24 return nil, errors.WithStack(err)
25 }
26 return buildConfig(includable, projectDir, string(content))
27 case *gitPlugin:
28 content, err := includable.Fetch()
29 if err != nil {
30 return nil, errors.WithStack(err)
31 }
32 return buildConfig(includable, projectDir, string(content))
33 case *LocalPlugin:
34 content, err := os.ReadFile(includable.Path())
35 if err != nil && !os.IsNotExist(err) {
36 return nil, errors.WithStack(err)
37 }
38 return buildConfig(includable, projectDir, string(content))
39 }
40 return nil, errors.Errorf("unknown plugin type %T", inc)
41}
42
43func getBuiltinPluginConfigIfExists(
44 pkg *devpkg.Package,

Callers 2

ReadmeFunction · 0.85
LoadConfigFromIncludeFunction · 0.85

Calls 4

buildConfigFunction · 0.85
FetchMethod · 0.65
PathMethod · 0.45

Tested by

no test coverage detected