Sha256: 0079e9e73533fcbf8a91507125126fe536f0a1c9f46c64b10670c7c197fe594f

Contents?: true

Size: 1.67 KB

Versions: 40

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'

    return false unless docker_check_daemon

    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'],
      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

40 entries across 40 versions & 1 rubygems

Version Path
takeltau-0.43.6 lib/takeltau/docker/container/login.rb
takeltau-0.43.4 lib/takeltau/docker/container/login.rb
takeltau-0.43.2 lib/takeltau/docker/container/login.rb
takeltau-0.43.1 lib/takeltau/docker/container/login.rb
takeltau-0.42.7 lib/takeltau/docker/container/login.rb
takeltau-0.42.5 lib/takeltau/docker/container/login.rb
takeltau-0.42.4 lib/takeltau/docker/container/login.rb
takeltau-0.42.3 lib/takeltau/docker/container/login.rb
takeltau-0.42.0 lib/takeltau/docker/container/login.rb
takeltau-0.41.10 lib/takeltau/docker/container/login.rb
takeltau-0.41.9 lib/takeltau/docker/container/login.rb
takeltau-0.41.0 lib/takeltau/docker/container/login.rb
takeltau-0.40.11 lib/takeltau/docker/container/login.rb
takeltau-0.40.9 lib/takeltau/docker/container/login.rb
takeltau-0.40.7 lib/takeltau/docker/container/login.rb
takeltau-0.40.6 lib/takeltau/docker/container/login.rb
takeltau-0.40.4 lib/takeltau/docker/container/login.rb
takeltau-0.40.3 lib/takeltau/docker/container/login.rb
takeltau-0.40.1 lib/takeltau/docker/container/login.rb
takeltau-0.40.0 lib/takeltau/docker/container/login.rb