(sleep=None, endpoints=None, conditions=None, env_vars=None, wrappers=None, kind_config=None)
This utility provides a convenient way to safely set up and tear down Kind environments.

    :param sleep: Number of seconds to wait before yielding.
    :type sleep: ``float``
    :param endpoints: Endpoints to verify access for before yielding. Shorthand for adding
                      ``conditions.CheckEndpoints(endpoints)`` to the ``conditions`` argument.
    :type endpoints: ``list`` of ``str``, or a single ``str``
    :param conditions: A list of callable objects that will be executed before yielding to check for errors.
    :type conditions: ``callable``
    :param env_vars: A dictionary to update ``os.environ`` with during execution.
    :type env_vars: ``dict``
    :param wrappers: A list of context managers to use during execution.
    :param kind_config: A path to a yaml file that contains the configuration for creating the kind cluster.
    :type kind_config: ``str``
This utility provides a convenient way to safely set up and tear down Kind environments.
This utility provides a convenient way to safely set up and tear down Kind environments .
def kind_run(sleep=None, endpoints=None, conditions=None, env_vars=None, wrappers=None, kind_config=None):
    """
    This utility provides a convenient way to safely set up and tear down Kind environments.

    :param sleep: Number of seconds to wait before yielding.
    :type sleep: ``float``
    :param endpoints: Endpoints to verify access for before yielding. Shorthand for adding
                      ``conditions.CheckEndpoints(endpoints)`` to the ``conditions`` argument.
    :type endpoints: ``list`` of ``str``, or a single ``str``
    :param conditions: A list of callable objects that will be executed before yielding to check for errors.
    :type conditions: ``callable``
    :param env_vars: A dictionary to update ``os.environ`` with during execution.
    :type env_vars: ``dict``
    :param wrappers: A list of context managers to use during execution.
    :param kind_config: A path to a yaml file that contains the configuration for creating the kind cluster.
    :type kind_config: ``str``
    """
    if not which('kind'):
        pytest.skip('Kind not available')

    # An extra level deep because of the context manager
    check_name = get_current_check_name(depth=2)
    # Replace undercores as kubeadm doesn't accept them
    check_name = check_name.replace("_", "-")
    cluster_name = 'cluster-{}-{}'.format(check_name, get_tox_env())

    with TempDir(cluster_name) as temp_dir:
        kubeconfig_path = path_join(temp_dir, 'config')

        if not file_exists(kubeconfig_path):
            create_file(kubeconfig_path)

        with EnvVars({'KUBECONFIG': kubeconfig_path}):
            set_up = KindUp(cluster_name, kind_config)
            tear_down = KindDown(cluster_name)

            with environment_run(
                up=set_up,
                down=tear_down,
                sleep=sleep,
                endpoints=endpoints,
                conditions=conditions,
                env_vars=env_vars,
                wrappers=wrappers,
            ):
                yield kubeconfig_path
def kind_run ( sleep = None , endpoints = None , conditions = None , env_vars = None , wrappers = None , kind_config = None ) : if not which ( 'kind' ) : pytest . skip ( 'Kind not available' ) # An extra level deep because of the context manager check_name = get_current_check_name ( depth = 2 ) # Replace undercores as kubeadm doesn't accept them check_name = check_name . replace ( "_" , "-" ) cluster_name = 'cluster-{}-{}' . format ( check_name , get_tox_env ( ) ) with TempDir ( cluster_name ) as temp_dir : kubeconfig_path = path_join ( temp_dir , 'config' ) if not file_exists ( kubeconfig_path ) : create_file ( kubeconfig_path ) with EnvVars ( { 'KUBECONFIG' : kubeconfig_path } ) : set_up = KindUp ( cluster_name , kind_config ) tear_down = KindDown ( cluster_name ) with environment_run ( up = set_up , down = tear_down , sleep = sleep , endpoints = endpoints , conditions = conditions , env_vars = env_vars , wrappers = wrappers , ) : yield kubeconfig_path