get.porter.sh/porter@v1.3.0/pkg/portercontext/plugindebugcontext.go (about)

     1  package portercontext
     2  
     3  import (
     4  	"strconv"
     5  )
     6  
     7  type PluginDebugContext struct {
     8  	RunPlugInInDebugger    string
     9  	PlugInWorkingDirectory string
    10  	DebuggerPort           string
    11  }
    12  
    13  func NewPluginDebugContext(c *Context) *PluginDebugContext {
    14  
    15  	runPlugInInDebugger := c.Getenv("PORTER_RUN_PLUGIN_IN_DEBUGGER")
    16  	debugWorkingDirectory := c.Getenv("PORTER_PLUGIN_WORKING_DIRECTORY")
    17  	debuggerPort := c.Getenv("PORTER_DEBUGGER_PORT")
    18  
    19  	port := "2345"
    20  	if _, err := strconv.ParseInt(debuggerPort, 10, 16); err == nil {
    21  		port = debuggerPort
    22  	}
    23  
    24  	return &PluginDebugContext{
    25  		RunPlugInInDebugger:    runPlugInInDebugger,
    26  		DebuggerPort:           port,
    27  		PlugInWorkingDirectory: debugWorkingDirectory,
    28  	}
    29  }