opentofu/internal/plugin/ui_output.go

35 lines
678 B
Go
Raw Normal View History

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package plugin
2014-10-04 11:11:51 -05:00
import (
"net/rpc"
2023-09-20 07:16:53 -05:00
"github.com/opentofu/opentofu/internal/tofu"
2014-10-04 11:11:51 -05:00
)
// UIOutput is an implementatin of tofu.UIOutput that communicates
2014-10-04 11:11:51 -05:00
// over RPC.
type UIOutput struct {
Client *rpc.Client
}
func (o *UIOutput) Output(v string) {
o.Client.Call("Plugin.Output", v, new(interface{}))
2014-10-04 11:11:51 -05:00
}
// UIOutputServer is the RPC server for serving UIOutput.
type UIOutputServer struct {
2023-09-20 07:16:53 -05:00
UIOutput tofu.UIOutput
2014-10-04 11:11:51 -05:00
}
func (s *UIOutputServer) Output(
v string,
reply *interface{}) error {
s.UIOutput.Output(v)
return nil
}