Skip to content

Instantly share code, notes, and snippets.

@ncdc
Created November 17, 2017 19:53
Show Gist options
  • Save ncdc/88b9b5bb4818fe6b6353cc8bf2da81fe to your computer and use it in GitHub Desktop.
Save ncdc/88b9b5bb4818fe6b6353cc8bf2da81fe to your computer and use it in GitHub Desktop.
Sample Heptio Ark plugin
package main
import (
plugin "github.com/hashicorp/go-plugin"
"github.com/heptio/ark/pkg/cloudprovider"
"github.com/heptio/ark/pkg/cloudprovider/aws"
arkplugin "github.com/heptio/ark/pkg/plugin"
"github.com/sirupsen/logrus"
)
func main() {
objectStore := &MyObjectStore{
ObjectStore: aws.NewObjectStore(),
log: arkplugin.NewPluginLogger(),
}
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: arkplugin.Handshake,
Plugins: map[string]plugin.Plugin{
string(arkplugin.PluginKindBlockStore): arkplugin.NewObjectStorePlugin(objectStore),
},
GRPCServer: plugin.DefaultGRPCServer,
})
}
type MyObjectStore struct {
cloudprovider.ObjectStore
log logrus.FieldLogger
}
func (mos *MyObjectStore) Init(config map[string]string) error {
mos.log.Info("HELLO FROM MyObjectStore!!!")
return mos.ObjectStore.Init(config)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment