-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
66 lines (60 loc) · 1.95 KB
/
Copy pathplugin.go
File metadata and controls
66 lines (60 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package warp
// Plugin is a warp resource that declares a repository as a distributable package.
type Plugin struct {
BaseResource `yaml:",inline"`
// Spec holds the Plugin-specific configuration.
Spec PluginSpec `yaml:"spec"`
}
// DeepCopy returns a deep copy of the Plugin.
func (in *Plugin) DeepCopy() *Plugin {
if in == nil {
return nil
}
out := new(Plugin)
out.BaseResource = *in.BaseResource.DeepCopy()
out.Spec = *in.Spec.DeepCopy()
return out
}
// PluginSpec contains the configuration details for a Plugin resource.
type PluginSpec struct {
// Instructions is the Markdown body of the plugin file.
Instructions string `yaml:"instructions,omitempty"`
ResourceDir string `yaml:"resourceDir"` // The relative path within the repository where the loader should look for resources
Exports []string `yaml:"exports"` // Glob patterns defining which resources are exposed to consumers
Hooks *PluginHooks `yaml:"hooks,omitempty"` // Setup and installation hooks
}
// DeepCopy returns a deep copy of the PluginSpec.
func (in *PluginSpec) DeepCopy() *PluginSpec {
if in == nil {
return nil
}
out := new(PluginSpec)
*out = *in
if in.Exports != nil {
out.Exports = make([]string, len(in.Exports))
copy(out.Exports, in.Exports)
}
if in.Hooks != nil {
out.Hooks = in.Hooks.DeepCopy()
}
return out
}
// PluginHooks defines lifecycle commands to run when a plugin is installed.
type PluginHooks struct {
PostInstall [][]string `yaml:"postInstall,omitempty"` // Commands to run after the plugin is downloaded (e.g., ["go", "install", "./..."])
}
// DeepCopy returns a deep copy of the PluginHooks.
func (in *PluginHooks) DeepCopy() *PluginHooks {
if in == nil {
return nil
}
out := new(PluginHooks)
if in.PostInstall != nil {
out.PostInstall = make([][]string, len(in.PostInstall))
for i, v := range in.PostInstall {
out.PostInstall[i] = make([]string, len(v))
copy(out.PostInstall[i], v)
}
}
return out
}