github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/kata_builtin_proxy.go (about)

     1  // Copyright (c) 2018 HyperHQ Inc.
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  //
     5  
     6  package virtcontainers
     7  
     8  import "fmt"
     9  
    10  // This is a kata builtin proxy implementation of the proxy interface. Kata proxy
    11  // functionality is implemented inside the virtcontainers library.
    12  type kataBuiltInProxy struct {
    13  	proxyBuiltin
    14  }
    15  
    16  func (p *kataBuiltInProxy) validateParams(params proxyParams) error {
    17  	if len(params.id) == 0 || len(params.agentURL) == 0 || len(params.consoleURL) == 0 {
    18  		return fmt.Errorf("Invalid proxy parameters %+v", params)
    19  	}
    20  
    21  	return nil
    22  }
    23  
    24  // start is the proxy start implementation for kata builtin proxy.
    25  // It starts the console watcher for the guest.
    26  // It returns agentURL to let agent connect directly.
    27  func (p *kataBuiltInProxy) start(params proxyParams) (int, string, error) {
    28  	if err := p.validateParams(params); err != nil {
    29  		return -1, "", err
    30  	}
    31  
    32  	return p.proxyBuiltin.start(params)
    33  }