Sha256: 10893269f1d638595a50f674848c5d76d12f2efbc3ccd092d5331ff497fd5e5f

Contents?: true

Size: 1.67 KB

Versions: 48

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

# tau docker container login
module DockerContainerLogin
  # Backend method for docker container login.
  def docker_container_login
    log.debug 'Logging in to docker container'

    if _docker_container_lib_check_matrjoschka
      log.error 'You cannot log in to takelage from within takelage'
      return false
    end

    # rubocop:disable Style/IfUnlessModifier
    unless docker_container_check_existing @hostname
      _docker_container_login_create_container @hostname
    end
    # rubocop:enable Style/IfUnlessModifier

    run_and_exit _docker_container_login_enter_container @hostname
  end

  private

  # Create container, network and forward sockets
  def _docker_container_login_create_container(container)
    return false unless _docker_container_lib_create_net_and_ctr container

    _docker_container_lib_start_sockets
    _docker_container_wait_for_sockets
  end

  # Prepare enter existing container command.
  def _docker_container_login_enter_container(container)
    log.debug "Entering container \"#{container}\""

    loginpoint = '/loginpoint.py'
    loginpoint = '/debug/loginpoint.py --debug ' if options[:debug]

    format(
      config.active['cmd_docker_container_enter_container'],
      docker: config.active['cmd_docker'],
      container: container,
      loginpoint: loginpoint,
      username: @username
    )
  end

  # Wait for the sockets to come up
  def _docker_container_wait_for_sockets
    wait_for_sockets = config.active['login_wait_for_sockets'].to_i
    return if wait_for_sockets.zero?

    log.debug "Waiting for #{wait_for_sockets} #{pluralize(wait_for_sockets, 'second', 'seconds')}"
    sleep wait_for_sockets
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
takeltau-0.46.9 lib/takeltau/docker/container/login.rb
takeltau-0.46.8 lib/takeltau/docker/container/login.rb
takeltau-0.46.5 lib/takeltau/docker/container/login.rb
takeltau-0.46.1 lib/takeltau/docker/container/login.rb
takeltau-0.46.0 lib/takeltau/docker/container/login.rb
takeltau-0.45.27 lib/takeltau/docker/container/login.rb
takeltau-0.45.26 lib/takeltau/docker/container/login.rb
takeltau-0.45.24 lib/takeltau/docker/container/login.rb
takeltau-0.45.23 lib/takeltau/docker/container/login.rb
takeltau-0.45.22 lib/takeltau/docker/container/login.rb
takeltau-0.45.21 lib/takeltau/docker/container/login.rb
takeltau-0.45.19 lib/takeltau/docker/container/login.rb
takeltau-0.45.17 lib/takeltau/docker/container/login.rb
takeltau-0.45.16 lib/takeltau/docker/container/login.rb
takeltau-0.45.14 lib/takeltau/docker/container/login.rb
takeltau-0.45.13 lib/takeltau/docker/container/login.rb
takeltau-0.45.12 lib/takeltau/docker/container/login.rb
takeltau-0.45.11 lib/takeltau/docker/container/login.rb
takeltau-0.45.10 lib/takeltau/docker/container/login.rb
takeltau-0.45.9 lib/takeltau/docker/container/login.rb