-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.go
46 lines (39 loc) · 1.05 KB
/
plugin.go
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
// Package plasmactlrelease implements a release launchr plugin
package plasmactlrelease
import (
"context"
"embed"
"io/fs"
"github.com/launchrctl/launchr"
"github.com/launchrctl/launchr/pkg/action"
)
// Embed an action directory. Tree:
// - action.yaml
// - Dockerfile
// - ...
// The content is available like action/action.yaml
//
//go:embed action
var actionfs embed.FS
func init() {
launchr.RegisterPlugin(&Plugin{})
}
// Plugin is [launchr.Plugin] providing action.
type Plugin struct{}
// PluginInfo implements [launchr.Plugin] interface.
func (p *Plugin) PluginInfo() launchr.PluginInfo {
return launchr.PluginInfo{}
}
// DiscoverActions implements [launchr.ActionDiscoveryPlugin] interface.
func (p *Plugin) DiscoverActions(_ context.Context) ([]*action.Action, error) {
// Use subdirectory so the content is available in the root "./".
subfs, err := fs.Sub(actionfs, "action")
if err != nil {
return nil, err
}
a, err := action.NewYAMLFromFS("platform:release", subfs)
if err != nil {
return nil, err
}
return []*action.Action{a}, nil
}