Sha256: ab52c72bf5771cef658af056a1e201da12448d82ad0e502c035af3c47e395c2a

Contents?: true

Size: 1.58 KB

Versions: 30

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

# tau ship info lib
module ShipInfoLib
  private

  # Gather takelship information
  def _ship_info_lib_get_takelshipinfo
    log.debug 'Gathering takelship info'
    takelshipinfo = _ship_info_lib_get_info_from_file
    takelshipinfo = _ship_info_lib_get_info_from_docker if takelshipinfo.empty?

    return false if takelshipinfo.nil?

    takelshipinfo
  end

  # Read takelship info from file
  def _ship_info_lib_get_info_from_file
    log.debug 'Reading takelship info from file'
    ship_data_dir = config.active['ship_data_dir']
    yaml_file = format(
      config.active['ship_takelship_yml'],
      pwd: Dir.getwd,
      ship_data_dir: ship_data_dir
    )
    read_yaml_file(yaml_file) || {}
  end

  # Read takelship info from docker run
  def _ship_info_lib_get_info_from_docker
    log.debug 'Reading takelship info from takelship container'
    command = 'info'
    _parse_yaml _ship_container_lib_docker_nonprivileged(command) || {}
  end

  def _ship_info_lib_get_project(project, takelship)
    return '' unless takelship.key? 'default_project'

    project = config.active['ship_default_project'] if project == 'default'
    project = takelship['default_project'] if project == 'default'
    project
  end

  def _ship_info_lib_valid_project?(takelship, project)
    valid_project = false
    takelship_projects = takelship['projects']
    return false if takelship_projects.nil? || takelship_projects.empty?

    takelship_projects.each do |takelship_project|
      valid_project = true if project == takelship_project['name']
    end
    valid_project
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
takeltau-0.45.14 lib/takeltau/ship/info/lib.rb
takeltau-0.45.13 lib/takeltau/ship/info/lib.rb
takeltau-0.45.12 lib/takeltau/ship/info/lib.rb
takeltau-0.45.11 lib/takeltau/ship/info/lib.rb
takeltau-0.45.10 lib/takeltau/ship/info/lib.rb
takeltau-0.45.9 lib/takeltau/ship/info/lib.rb
takeltau-0.45.8 lib/takeltau/ship/info/lib.rb
takeltau-0.45.6 lib/takeltau/ship/info/lib.rb
takeltau-0.45.5 lib/takeltau/ship/info/lib.rb
takeltau-0.45.4 lib/takeltau/ship/info/lib.rb
takeltau-0.45.3 lib/takeltau/ship/info/lib.rb
takeltau-0.45.2 lib/takeltau/ship/info/lib.rb
takeltau-0.45.0 lib/takeltau/ship/info/lib.rb
takeltau-0.44.42 lib/takeltau/ship/info/lib.rb
takeltau-0.44.41 lib/takeltau/ship/info/lib.rb
takeltau-0.44.39 lib/takeltau/ship/info/lib.rb
takeltau-0.44.37 lib/takeltau/ship/info/lib.rb
takeltau-0.44.36 lib/takeltau/ship/info/lib.rb
takeltau-0.44.35 lib/takeltau/ship/info/lib.rb
takeltau-0.44.29 lib/takeltau/ship/info/lib.rb