def _get_exec_driver():
    '''
    Get the method to be used in shell commands
    '''
    contextkey = 'docker.exec_driver'
    if contextkey not in __context__:
        from_config = __salt__['config.get'](contextkey, None)
        # This if block can be removed once we make docker-exec a default
        # option, as it is part of the logic in the commented block above.
        if from_config is not None:
            __context__[contextkey] = from_config
            return from_config

        # The execution driver was removed in Docker 1.13.1, docker-exec is now
        # the default.
        driver = info().get('ExecutionDriver', 'docker-exec')
        if driver == 'docker-exec':
            __context__[contextkey] = driver
        elif driver.startswith('lxc-'):
            __context__[contextkey] = 'lxc-attach'
        elif driver.startswith('native-') and HAS_NSENTER:
            __context__[contextkey] = 'nsenter'
        elif not driver.strip() and HAS_NSENTER:
            log.warning(
                'ExecutionDriver from \'docker info\' is blank, falling '
                'back to using \'nsenter\'. To squelch this warning, set '
                'docker.exec_driver. See the Salt documentation for the '
                'docker module for more information.'
            )
            __context__[contextkey] = 'nsenter'
        else:
            raise NotImplementedError(
                'Unknown docker ExecutionDriver \'{0}\', or didn\'t find '
                'command to attach to the container'.format(driver)
            )
    return __context__[contextkey]
def _get_exec_driver ( ) : contextkey = 'docker.exec_driver' if contextkey not in __context__ : from_config = __salt__ [ 'config.get' ] ( contextkey , None ) if from_config is not None : __context__ [ contextkey ] = from_config return from_config driver = info ( ) . get ( 'ExecutionDriver' , 'docker-exec' ) if driver == 'docker-exec' : __context__ [ contextkey ] = driver elif driver . startswith ( 'lxc-' ) : __context__ [ contextkey ] = 'lxc-attach' elif driver . startswith ( 'native-' ) and HAS_NSENTER : __context__ [ contextkey ] = 'nsenter' elif not driver . strip ( ) and HAS_NSENTER : log . warning ( 'ExecutionDriver from \'docker info\' is blank, falling ' 'back to using \'nsenter\'. To squelch this warning, set ' 'docker.exec_driver. See the Salt documentation for the ' 'docker module for more information.' ) __context__ [ contextkey ] = 'nsenter' else : raise NotImplementedError ( 'Unknown docker ExecutionDriver \'{0}\', or didn\'t find ' 'command to attach to the container' . format ( driver ) ) return __context__ [ contextkey ]
Get the method to be used in shell commands