Setup builtin host plugin with capabilities
This commit is contained in:
parent
c6ad026070
commit
28dd174686
8
builtin/myplugin/host/cap/write_hello.go
Normal file
8
builtin/myplugin/host/cap/write_hello.go
Normal file
@ -0,0 +1,8 @@
|
||||
package cap
|
||||
|
||||
import "io/ioutil"
|
||||
|
||||
func WriteHello() {
|
||||
data := []byte("hello\ngo\n")
|
||||
ioutil.WriteFile("/tmp/dat1", data, 0644)
|
||||
}
|
||||
36
builtin/myplugin/host/osx.go
Normal file
36
builtin/myplugin/host/osx.go
Normal file
@ -0,0 +1,36 @@
|
||||
package host
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||
sdkcore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
||||
"github.com/hashicorp/vagrant/builtin/myplugin/host/cap"
|
||||
)
|
||||
|
||||
type HostConfig struct {
|
||||
}
|
||||
|
||||
// TestOSXHost is a Host implementation for myplugin.
|
||||
type OSXHost struct {
|
||||
config HostConfig
|
||||
|
||||
// Include capability host
|
||||
sdkcore.CapabilityHost
|
||||
}
|
||||
|
||||
// DetectFunc implements component.Host
|
||||
func (h *OSXHost) DetectFunc() interface{} {
|
||||
return h.Detect()
|
||||
}
|
||||
|
||||
func (h *OSXHost) Detect() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *OSXHost) InitializeCapabilities() {
|
||||
h.RegisterCapability("write_hello", cap.WriteHello)
|
||||
}
|
||||
|
||||
var (
|
||||
_ component.Host = (*OSXHost)(nil)
|
||||
_ sdkcore.Host = (*OSXHost)(nil)
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user