Sha256: a78ec7cbe90de564bca56b32203a5623e5adbeb7e0c7e7ac7c6c118696766587

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

# takelage docker image tag list module
module DockerImageTagListModule

  # Backend method for docker image tag list local.
  # @return [Array] local docker image tags
  def docker_image_tag_list_local
    tags = []

    cmd_docker_images = 'docker images ' +
        "#{@docker_repo}\/#{@docker_image} " +
        ' --format "{{.Tag}}"'

    stdout_str = run cmd_docker_images

    tags = stdout_str.split("\n")

    VersionSorter.sort(tags)
  end

  # Backend method for docker image tag list remote.
  # @return [Array] remote docker image tags
  def docker_image_tag_list_remote
    log.debug "Getting docker remote tags from \"#{@docker_tagsurl}\""

    begin
      @res = Net::HTTP.get_response URI(@docker_tagsurl)
      unless @res.code.eql? '200'
        log.error "Unable to connect to \"#{@docker_tagsurl}\""
        return false
      end
    rescue SocketError => e
      log.debug e
      return false
    end

    begin
      tags = JSON.parse @res.body
    rescue JSON::ParserError
      log.error 'Unable to parse JSON'
      return false
    end

    VersionSorter.sort(tags['tags'])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
takelage-0.9.0 lib/takelage/docker/image/tag/list/module.rb
takelage-0.8.1 lib/takelage/docker/image/tag/list/module.rb