Class: Freighter::DockerRestAPI
- Inherits:
-
Object
- Object
- Freighter::DockerRestAPI
- Defined in:
- lib/freighter/docker_rest_api.rb
Defined Under Namespace
Classes: ResponseObject
Instance Method Summary collapse
-
#authenticate ⇒ Object
authentication should not be necessary if the user is already authenticated with the docker client on the host.
-
#initialize(url) ⇒ DockerRestAPI
constructor
A new instance of DockerRestAPI.
- #list_images ⇒ Object
-
#pull(tag) ⇒ Object
This pulls a specified image def pull(image, repo, tag=‘latest’).
-
#running_containers ⇒ Object
returns all running containers.
Constructor Details
#initialize(url) ⇒ DockerRestAPI
Returns a new instance of DockerRestAPI.
7 8 9 10 |
# File 'lib/freighter/docker_rest_api.rb', line 7 def initialize(url) @base_url = url @http = Excon.new url end |
Instance Method Details
#authenticate ⇒ Object
authentication should not be necessary if the user is already authenticated with the docker client on the host
13 14 15 |
# File 'lib/freighter/docker_rest_api.rb', line 13 def authenticate request { post(path: '/auth', body: JSON.dump({ 'username' => ENV['DOCKER_HUB_USER_NAME'], 'password' => ENV['DOCKER_HUB_PASSWORD'], 'email' => ENV['DOCKER_HUB_EMAIL'] }), headers: { "Content-Type" => "application/json" }) } end |
#list_images ⇒ Object
32 33 34 |
# File 'lib/freighter/docker_rest_api.rb', line 32 def list_images request { get path: '/images/json' } end |
#pull(tag) ⇒ Object
This pulls a specified image def pull(image, repo, tag=‘latest’)
19 20 21 22 23 |
# File 'lib/freighter/docker_rest_api.rb', line 19 def pull(tag) request do post(path: "/images/create", query: { tag: tag }) end end |
#running_containers ⇒ Object
returns all running containers
26 27 28 29 30 |
# File 'lib/freighter/docker_rest_api.rb', line 26 def running_containers request do get(path: '/containers/json') end end |