github.com/opentofu/opentofu@v1.7.1/internal/plugin/ui_output.go (about)

     1  // Copyright (c) The OpenTofu Authors
     2  // SPDX-License-Identifier: MPL-2.0
     3  // Copyright (c) 2023 HashiCorp, Inc.
     4  // SPDX-License-Identifier: MPL-2.0
     5  
     6  package plugin
     7  
     8  import (
     9  	"net/rpc"
    10  
    11  	"github.com/opentofu/opentofu/internal/tofu"
    12  )
    13  
    14  // UIOutput is an implementatin of tofu.UIOutput that communicates
    15  // over RPC.
    16  type UIOutput struct {
    17  	Client *rpc.Client
    18  }
    19  
    20  func (o *UIOutput) Output(v string) {
    21  	o.Client.Call("Plugin.Output", v, new(interface{}))
    22  }
    23  
    24  // UIOutputServer is the RPC server for serving UIOutput.
    25  type UIOutputServer struct {
    26  	UIOutput tofu.UIOutput
    27  }
    28  
    29  func (s *UIOutputServer) Output(
    30  	v string,
    31  	reply *interface{}) error {
    32  	s.UIOutput.Output(v)
    33  	return nil
    34  }