func (client *cniClient) SetupNS(ctx context.Context,
	cfg *Config,
	timeout time.Duration) (*current.Result, error) {
	derivedCtx, cancel := context.WithTimeout(ctx, timeout)
	defer cancel()

	type output struct {
		result *current.Result
		err    error
	}
	response := make(chan output)
	go func(response chan output) {
		result, err := client.setupNS(cfg)
		response <- output{
			result: result,
			err:    err,
		}
	}(response)

	select {
	case <-derivedCtx.Done():
		return nil, errors.Wrap(derivedCtx.Err(), "cni setup: container namespace setup failed")
	case result := <-response:
		return result.result, result.err
	}
}
func (client *cniClient) SetupNS(ctx context.Context,
	cfg *Config,
	timeout time.Duration) (*current.Result, error) {
	derivedCtx, cancel := context.WithTimeout(ctx, timeout)
	defer cancel()

	type output struct {
		result *current.Result
		err    error
	}
	response := make(chan output)
	go func(response chan output) {
		result, err := client.setupNS(cfg)
		response <- output{
			result: result,
			err:    err,
		}
	}(response)

	select {
	case <-derivedCtx.Done():
		return nil, errors.Wrap(derivedCtx.Err(), "cni setup: container namespace setup failed")
	case result := <-response:
		return result.result, result.err
	}
}
func ( client * cniClient ) SetupNS ( ctx context . Context , cfg * Config , timeout time . Duration ) ( * current . Result , error ) { derivedCtx , cancel := context . WithTimeout ( ctx , timeout ) defer cancel ( ) type output struct { result * current . Result err error } response := make ( chan output ) go func ( response chan output ) { result , err := client . setupNS ( cfg ) response <- output { result : result , err : err , } } ( response ) select { case <- derivedCtx . Done ( ) : return nil , errors . Wrap ( derivedCtx . Err ( ) , " " ) case result := <- response : return result . result , result . err } }
// SetupNS will set up the namespace of container, including create the bridge
// and the veth pair, move the eni to container namespace, setup the routes
SetupNS will set up the namespace of container including create the bridge and the veth pair move the eni to container namespace setup the routes