mrm 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a91fe5210d931c16738313765e6e306f4244b89d
4
+ data.tar.gz: fd22ca1edb7cecca7a385bbbb48d096d520d37ea
5
+ SHA512:
6
+ metadata.gz: 881161a8ab8fec6f70cff2169b7be3569d6851e311edb08c24f7a3226928a1104cc00ec46634b4147a12d1bf1737992d17902d770f4fd7012a405dbe8c30a865
7
+ data.tar.gz: 217ee9038c320e970001b500382ff47d6d97774363465273c872a479bf9222401c9bfb32fdda2fbd1d92c7e42745da1f2dd31e067b2d6c3ef031c931c2e6f7f0
data/bin/mrm ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mrm'
4
+ require 'optparse'
5
+ require 'ostruct'
6
+
7
+ options = OpenStruct.new
8
+ client = MRM::Client.new
9
+
10
+ OptionParser.new do |opts|
11
+ opts.banner = 'Usage: mrm [options]'
12
+
13
+ opts.on('-v', '--version', 'Prints gem version') do |v|
14
+ options.v = true
15
+ end
16
+ end.parse!
17
+
18
+ if options.v
19
+ puts MRM::Version.to_s
20
+ end
21
+
22
+ #opts.on('check', 'Checks if Docker Registry is reachable and accessible') do |c|
23
+ #end
24
+
25
+ if ARGV[0] == 'check'
26
+ puts client.version_check
27
+ end
28
+
29
+ p options
data/lib/mrm/api.rb ADDED
@@ -0,0 +1,37 @@
1
+ module MRM
2
+ class Api
3
+ def initialize(url, login, pass)
4
+ @url, @login, @pass = url, login, pass
5
+ end
6
+
7
+ def version_check
8
+ response = request("#{url}/v2/")
9
+ if response.code == '200'
10
+ puts '--> Repository is reachable and accessible.'
11
+ else
12
+ raise ResponseError, response.body
13
+ end
14
+ end
15
+
16
+ def list_repositories
17
+ response = request("#{url}/v2/_catalog")
18
+ if response.code == '200'
19
+ JSON.parse(response.body)
20
+ else
21
+ raise ResponseError, response.body
22
+ end
23
+ end
24
+
25
+ private
26
+ attr_reader :url, :login, :pass
27
+
28
+ def request(url)
29
+ uri = URI(url)
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ http.use_ssl = uri.scheme == 'https'
32
+ request = Net::HTTP::Get.new(uri.request_uri)
33
+ request.basic_auth(login, pass)
34
+ http.request(request)
35
+ end
36
+ end
37
+ end
data/lib/mrm/client.rb ADDED
@@ -0,0 +1,26 @@
1
+ module MRM
2
+ class Client
3
+ def initialize
4
+ @config = YAML.load_file('config.yml')
5
+ end
6
+
7
+ def version_check
8
+ api.version_check
9
+ end
10
+
11
+ def list_repositories
12
+ api.list_repositories
13
+ end
14
+
15
+ private
16
+ attr_reader :config
17
+
18
+ def api
19
+ @api ||= Api.new(
20
+ config['REGISTRY_URL'],
21
+ config['REGISTRY_LOGIN'],
22
+ config['REGISTRY_PASS']
23
+ )
24
+ end
25
+ end
26
+ end
data/lib/mrm/error.rb ADDED
@@ -0,0 +1,3 @@
1
+ module MRM
2
+ class ResponseError < StandardError; end
3
+ end
@@ -0,0 +1,14 @@
1
+ module MRM
2
+ class Version
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 0
6
+ PRE = nil
7
+
8
+ class << self
9
+ def to_s
10
+ [MAJOR, MINOR, PATCH, PRE].compact.join('.')
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/mrm.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'net/http'
2
+ require 'openssl'
3
+ require 'base64'
4
+ require 'cgi'
5
+ require 'json'
6
+ require 'yaml'
7
+ require 'mrm/client'
8
+ require 'mrm/api'
9
+ require 'mrm/error'
10
+ require 'mrm/version'
11
+
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mrm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rustam A. Gasanov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Allows to manipulate Docker Registry and more.
14
+ email: rustamagasanov@gmail.com
15
+ executables:
16
+ - mrm
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/mrm
21
+ - lib/mrm.rb
22
+ - lib/mrm/api.rb
23
+ - lib/mrm/client.rb
24
+ - lib/mrm/error.rb
25
+ - lib/mrm/version.rb
26
+ homepage: http://rubygems.org/gems/mrm
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.5.1
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Multipurpose Registry Manager
50
+ test_files: []