github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/plugin/ui_output.go (about)

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