2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 10:33:06 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2016-01-24 20:10:52 -06:00
|
|
|
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
|
|
|
)
|
|
|
|
|
2023-09-26 12:09:27 -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) {
|
2016-01-24 20:10:52 -06:00
|
|
|
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
|
|
|
|
}
|