Rename to alwaystrue host

This commit is contained in:
sophia 2021-04-27 14:38:49 -05:00 committed by Paul Hinze
parent be08dfde85
commit 768dcf07da
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 12 additions and 12 deletions

View File

@ -9,29 +9,29 @@ import (
type HostConfig struct {
}
// TestOSXHost is a Host implementation for myplugin.
type OSXHost struct {
// AlwaysTrueHost is a Host implementation for myplugin.
type AlwaysTrueHost struct {
config HostConfig
sdkcore.CapabilityHost
}
// DetectFunc implements component.Host
func (h *OSXHost) DetectFunc() interface{} {
return h.Detect()
func (h *AlwaysTrueHost) DetectFunc() interface{} {
return h.Detect
}
func (h *OSXHost) Detect() bool {
// h.InitializeCapabilities()
func (h *AlwaysTrueHost) Detect() bool {
h.InitializeCapabilities()
return true
}
func (h *OSXHost) InitializeCapabilities() (err error) {
func (h *AlwaysTrueHost) InitializeCapabilities() (err error) {
err = h.RegisterCapability("write_hello", cap.WriteHelloFunc)
return
}
var (
_ component.Host = (*OSXHost)(nil)
_ sdkcore.Host = (*OSXHost)(nil)
_ component.Host = (*AlwaysTrueHost)(nil)
_ sdkcore.Host = (*AlwaysTrueHost)(nil)
)

View File

@ -2,15 +2,13 @@ package cap
import (
"io/ioutil"
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
)
func WriteHelloFunc() interface{} {
return WriteHello
}
func WriteHello(trm terminal.UI) {
func WriteHello() {
data := []byte("hello\ngo\n")
ioutil.WriteFile("/tmp/dat1", data, 0644)
}

View File

@ -3,6 +3,7 @@ package myplugin
import (
sdk "github.com/hashicorp/vagrant-plugin-sdk"
"github.com/hashicorp/vagrant/builtin/myplugin/command"
"github.com/hashicorp/vagrant/builtin/myplugin/host"
)
//go:generate protoc -I ../../.. --go_opt=plugins=grpc --go_out=../../.. vagrant-ruby/builtin/myplugin/plugin.proto
@ -12,5 +13,6 @@ var CommandOptions = []sdk.Option{
sdk.WithComponents(
&Provider{},
&command.Command{},
&host.AlwaysTrueHost{},
),
}