obs_deploy 0.1.2
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 +7 -0
- data/.circleci/config.yml +22 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +83 -0
- data/README.md +57 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/obs_deploy +8 -0
- data/bin/setup +8 -0
- data/dist/Makefile +6 -0
- data/dist/rubygem-obs_deploy.spec +51 -0
- data/lib/obs_deploy.rb +56 -0
- data/lib/obs_deploy/check_diff.rb +42 -0
- data/lib/obs_deploy/cli/commands.rb +21 -0
- data/lib/obs_deploy/cli/commands/deploy.rb +22 -0
- data/lib/obs_deploy/cli/commands/get_deployed_version.rb +16 -0
- data/lib/obs_deploy/cli/commands/get_package_version.rb +19 -0
- data/lib/obs_deploy/cli/commands/refresh_repositories.rb +21 -0
- data/lib/obs_deploy/cli/commands/version.rb +14 -0
- data/lib/obs_deploy/ssh.rb +26 -0
- data/lib/obs_deploy/version.rb +5 -0
- data/obs_deploy.gemspec +39 -0
- metadata +198 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2bb058921426d313f82510add524de887bc8f2be01379528680bef135c0ab99f
|
|
4
|
+
data.tar.gz: 5a39875b8386d573bf3f4da424c4058eebcd1269dfef8fbe40fe0e104b0d3d4b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dafbd837d3498870b8cccb90d9f486868ad3ee17f7b85ca4febb11700f2f3d56178dd1d18b5c08c8cfc18601bbf6960b8fcddfe98151b08ab8ac3506b3e84f93
|
|
7
|
+
data.tar.gz: b33c174b2c3f6bb7d75e73764024fcdf4f98d8b9a3a3f8b68a16572c5c7ae2f4c2c0767d756b8d2bf0ae3e466c3a68d5e64b2d65e9fbcb4852b165e2c4124e5b
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
orbs:
|
|
3
|
+
ruby: circleci/ruby@0.1.2
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
docker:
|
|
8
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
|
9
|
+
environment:
|
|
10
|
+
BUNDLE_VERSION=2.1.4
|
|
11
|
+
executor: ruby/default
|
|
12
|
+
steps:
|
|
13
|
+
- checkout
|
|
14
|
+
- run:
|
|
15
|
+
name: Install Bundler
|
|
16
|
+
command: gem install bundler:2.1.4
|
|
17
|
+
- run:
|
|
18
|
+
name: Bundle install
|
|
19
|
+
command: bundle install
|
|
20
|
+
- run:
|
|
21
|
+
name: Run spec
|
|
22
|
+
command: bundle exec rake spec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
obs_deploy (0.1.2)
|
|
5
|
+
cheetah
|
|
6
|
+
dry-cli
|
|
7
|
+
nokogiri
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
abstract_method (1.2.1)
|
|
13
|
+
addressable (2.7.0)
|
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
15
|
+
ast (2.4.0)
|
|
16
|
+
cheetah (0.5.2)
|
|
17
|
+
abstract_method (~> 1.2)
|
|
18
|
+
coderay (1.1.2)
|
|
19
|
+
concurrent-ruby (1.1.6)
|
|
20
|
+
crack (0.4.3)
|
|
21
|
+
safe_yaml (~> 1.0.0)
|
|
22
|
+
diff-lcs (1.3)
|
|
23
|
+
dry-cli (0.6.0)
|
|
24
|
+
concurrent-ruby (~> 1.0)
|
|
25
|
+
hashdiff (1.0.1)
|
|
26
|
+
jaro_winkler (1.5.4)
|
|
27
|
+
method_source (1.0.0)
|
|
28
|
+
mini_portile2 (2.4.0)
|
|
29
|
+
nokogiri (1.10.9)
|
|
30
|
+
mini_portile2 (~> 2.4.0)
|
|
31
|
+
parallel (1.19.1)
|
|
32
|
+
parser (2.7.0.5)
|
|
33
|
+
ast (~> 2.4.0)
|
|
34
|
+
pry (0.13.0)
|
|
35
|
+
coderay (~> 1.1)
|
|
36
|
+
method_source (~> 1.0)
|
|
37
|
+
public_suffix (4.0.3)
|
|
38
|
+
rainbow (3.0.0)
|
|
39
|
+
rake (10.5.0)
|
|
40
|
+
rexml (3.2.4)
|
|
41
|
+
rspec (3.9.0)
|
|
42
|
+
rspec-core (~> 3.9.0)
|
|
43
|
+
rspec-expectations (~> 3.9.0)
|
|
44
|
+
rspec-mocks (~> 3.9.0)
|
|
45
|
+
rspec-core (3.9.1)
|
|
46
|
+
rspec-support (~> 3.9.1)
|
|
47
|
+
rspec-expectations (3.9.1)
|
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
49
|
+
rspec-support (~> 3.9.0)
|
|
50
|
+
rspec-mocks (3.9.1)
|
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
52
|
+
rspec-support (~> 3.9.0)
|
|
53
|
+
rspec-support (3.9.2)
|
|
54
|
+
rubocop (0.80.1)
|
|
55
|
+
jaro_winkler (~> 1.5.1)
|
|
56
|
+
parallel (~> 1.10)
|
|
57
|
+
parser (>= 2.7.0.1)
|
|
58
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
59
|
+
rexml
|
|
60
|
+
ruby-progressbar (~> 1.7)
|
|
61
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
62
|
+
ruby-progressbar (1.10.1)
|
|
63
|
+
safe_yaml (1.0.5)
|
|
64
|
+
unicode-display_width (1.6.1)
|
|
65
|
+
webmock (3.8.3)
|
|
66
|
+
addressable (>= 2.3.6)
|
|
67
|
+
crack (>= 0.3.2)
|
|
68
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
69
|
+
|
|
70
|
+
PLATFORMS
|
|
71
|
+
ruby
|
|
72
|
+
|
|
73
|
+
DEPENDENCIES
|
|
74
|
+
bundler (~> 2.0)
|
|
75
|
+
obs_deploy!
|
|
76
|
+
pry
|
|
77
|
+
rake (~> 10.0)
|
|
78
|
+
rspec (~> 3.0)
|
|
79
|
+
rubocop
|
|
80
|
+
webmock
|
|
81
|
+
|
|
82
|
+
BUNDLED WITH
|
|
83
|
+
2.1.4
|
data/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# OBS Deploy tool
|
|
2
|
+
|
|
3
|
+
Simple tool to deploy OBS via zypper to our reference server
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Just run:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'obs_deploy'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### To deploy
|
|
18
|
+
|
|
19
|
+
`obs_deploy deploy --user root --host localhost`
|
|
20
|
+
|
|
21
|
+
### To check which version is deployed
|
|
22
|
+
|
|
23
|
+
`obs_deploy deployed-version [--host <server>]`
|
|
24
|
+
|
|
25
|
+
### To check which package is available to install
|
|
26
|
+
|
|
27
|
+
`obs_deploy available-package [<product>] [<package-name>]`
|
|
28
|
+
|
|
29
|
+
### Deploy dry-run
|
|
30
|
+
|
|
31
|
+
`obs_deploy deploy --user root --host localhost --dry-run`
|
|
32
|
+
|
|
33
|
+
### Refresh Zypper repositories
|
|
34
|
+
|
|
35
|
+
`obs_deploy refresh-repositories`
|
|
36
|
+
|
|
37
|
+
## Development
|
|
38
|
+
|
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
40
|
+
|
|
41
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
42
|
+
|
|
43
|
+
### Run the `bin/obs_deploy` on development:
|
|
44
|
+
|
|
45
|
+
On the checked out source, run the following:
|
|
46
|
+
|
|
47
|
+
`ruby -Ilib bin/obs_deploy -v`
|
|
48
|
+
|
|
49
|
+
## Hacking
|
|
50
|
+
|
|
51
|
+
If you want to add new command to the cli, please read the `dry-cli` documentation https://dry-rb.org/gems/dry-cli/0.4/. The commands are in the `obs_deploy/cli/commands` directory.
|
|
52
|
+
|
|
53
|
+
The commands are being sent via ssh and ssh is being called via `cheetah` https://github.com/openSUSE/cheetah. Please Read the `ssh.rb` file, specially the `SSH#run` method
|
|
54
|
+
|
|
55
|
+
## Contributing
|
|
56
|
+
|
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vpereira/obs_deploy.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'obs_deploy'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/obs_deploy
ADDED
data/bin/setup
ADDED
data/dist/Makefile
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#
|
|
2
|
+
# spec file for package rubygem-obs_deploy
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2020 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# All modifications and additions to the file contributed by third parties
|
|
7
|
+
# remain the property of their copyright owners, unless otherwise agreed
|
|
8
|
+
# upon. The license for this file, and modifications and additions to the
|
|
9
|
+
# file, is the same license as for the pristine package itself (unless the
|
|
10
|
+
# license for the pristine package is not an Open Source License, in which
|
|
11
|
+
# case the license is the MIT License). An "Open Source License" is a
|
|
12
|
+
# license that conforms to the Open Source Definition (Version 1.9)
|
|
13
|
+
# published by the Open Source Initiative.
|
|
14
|
+
|
|
15
|
+
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
%define mod_name obs_deploy
|
|
20
|
+
%define mod_full_name %{mod_name}-%{version}
|
|
21
|
+
Name: rubygem-obs_deploy
|
|
22
|
+
Version: 0.1.1
|
|
23
|
+
Release: 0
|
|
24
|
+
Summary: OBS Deployment tool
|
|
25
|
+
License:
|
|
26
|
+
Group: Development/Languages/Ruby
|
|
27
|
+
URL: https://openbuildservice.org
|
|
28
|
+
Source: https://rubygems.org/gems/%{mod_full_name}.gem
|
|
29
|
+
BuildRequires: %{rubygem gem2rpm}
|
|
30
|
+
BuildRequires: %{ruby}
|
|
31
|
+
BuildRequires: ruby-macros >= 5
|
|
32
|
+
BuildRequires: update-alternatives
|
|
33
|
+
# FIXME: use proper Requires(pre/post/preun/...)
|
|
34
|
+
PreReq: update-alternatives
|
|
35
|
+
|
|
36
|
+
%description
|
|
37
|
+
OBS Deployment tool.
|
|
38
|
+
|
|
39
|
+
%prep
|
|
40
|
+
|
|
41
|
+
%build
|
|
42
|
+
|
|
43
|
+
%install
|
|
44
|
+
%gem_install \
|
|
45
|
+
--symlink-binaries \
|
|
46
|
+
--doc-files="README.md" \
|
|
47
|
+
-f
|
|
48
|
+
|
|
49
|
+
%gem_packages
|
|
50
|
+
|
|
51
|
+
%changelog
|
data/lib/obs_deploy.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
require 'cheetah'
|
|
6
|
+
require 'nokogiri'
|
|
7
|
+
require 'obs_deploy/version'
|
|
8
|
+
require 'obs_deploy/check_diff'
|
|
9
|
+
require 'obs_deploy/ssh'
|
|
10
|
+
|
|
11
|
+
module ObsDeploy
|
|
12
|
+
class Error < StandardError; end
|
|
13
|
+
class Systemctl
|
|
14
|
+
class << self
|
|
15
|
+
def status
|
|
16
|
+
'systemctl status obs-api-support.target'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def list_dependencies
|
|
20
|
+
'systemctl list-dependencies obs-api-support.target'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Zypper
|
|
26
|
+
def update(dry_run: true)
|
|
27
|
+
if dry_run
|
|
28
|
+
run ['zypper'] + update_params + dry_run_params + package_name
|
|
29
|
+
else
|
|
30
|
+
run ['zypper'] + update_params + package_name
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def refresh
|
|
35
|
+
run ['zypper', '--non-interactive', '--gpg-auto-import-keys', 'refresh']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def run(params)
|
|
41
|
+
params
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def package_name
|
|
45
|
+
['obs-api']
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def update_params
|
|
49
|
+
['--non-interactive', 'update', '--best-effort', '--details']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def dry_run_params
|
|
53
|
+
['--dry-run --download-only']
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
class CheckDiff
|
|
5
|
+
def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4')
|
|
6
|
+
@server = server
|
|
7
|
+
@product = product
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def package_version
|
|
11
|
+
doc = Nokogiri::XML(Net::HTTP.get(package_url))
|
|
12
|
+
doc.xpath("//binary[starts-with(@filename, 'obs-api')]/@filename").to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def package_commit
|
|
16
|
+
package_version.match(/obs-api-.*\..*\..*\.(.*)-.*\.rpm/).captures.first
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def obs_running_commit
|
|
20
|
+
doc = Nokogiri::XML(Net::HTTP.get(about_url))
|
|
21
|
+
doc.xpath('//commit/text()').to_s
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def github_diff
|
|
25
|
+
Net::HTTP.get(URI("https://github.com/openSUSE/open-build-service/compare/#{obs_running_commit}...#{package_commit}.diff"))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def has_migration?
|
|
29
|
+
return true if github_diff.nil? || github_diff.empty?
|
|
30
|
+
|
|
31
|
+
!!github_diff.match(%r{db/migrate})
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def package_url
|
|
35
|
+
URI("#{@server}/public/build/OBS:Server:Unstable/#{@product}/x86_64/obs-server")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def about_url
|
|
39
|
+
URI("#{@server}/about")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
module CLI
|
|
5
|
+
module Commands
|
|
6
|
+
extend Dry::CLI::Registry
|
|
7
|
+
autoload :Version, File.join(__dir__, 'commands/version.rb')
|
|
8
|
+
autoload :RefreshRepositories, File.join(__dir__, 'commands/refresh_repositories.rb')
|
|
9
|
+
autoload :Deploy, File.join(__dir__, 'commands/deploy.rb')
|
|
10
|
+
autoload :GetPackageVersion, File.join(__dir__, 'commands/get_package_version.rb')
|
|
11
|
+
autoload :GetDeployedVersion, File.join(__dir__, 'commands/get_deployed_version.rb')
|
|
12
|
+
|
|
13
|
+
# register the commands and its command line
|
|
14
|
+
register 'available-package', GetPackageVersion
|
|
15
|
+
register 'deployed-version', GetDeployedVersion
|
|
16
|
+
register 'version', Version, aliases: ['v', '-v', '--version']
|
|
17
|
+
register 'deploy', Deploy
|
|
18
|
+
register 'refresh-repositories', RefreshRepositories
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
module CLI
|
|
5
|
+
module Commands
|
|
6
|
+
class Deploy < Dry::CLI::Command
|
|
7
|
+
desc 'Deploy obs-api'
|
|
8
|
+
|
|
9
|
+
option :user, type: :string, default: 'root', desc: 'User'
|
|
10
|
+
option :dry_run, type: :bool, default: true, desc: 'Dry run'
|
|
11
|
+
option :host, type: :string, default: 'localhost', desc: 'Set the server address'
|
|
12
|
+
option :port, type: :int, default: 22, desc: 'Set the server port'
|
|
13
|
+
|
|
14
|
+
def call(user:, dry_run:, host:, port:, **)
|
|
15
|
+
ssh_driver = ObsDeploy::SSH.new(user: user, server: host, port: port)
|
|
16
|
+
zypper = ObsDeploy::Zypper.new
|
|
17
|
+
ssh_driver.run(zypper.update(dry_run: dry_run))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
module CLI
|
|
5
|
+
module Commands
|
|
6
|
+
class GetDeployedVersion < Dry::CLI::Command
|
|
7
|
+
desc 'Get the deployed version of OBS'
|
|
8
|
+
option :host, type: :string, default: 'https://api.opensuse.org', desc: 'API server'
|
|
9
|
+
|
|
10
|
+
def call(host:, **)
|
|
11
|
+
puts "Deployed version: #{ObsDeploy::CheckDiff.new(server: host).obs_running_commit}"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
module CLI
|
|
5
|
+
module Commands
|
|
6
|
+
class GetPackageVersion < Dry::CLI::Command
|
|
7
|
+
desc 'Get the available package version'
|
|
8
|
+
option :host, type: :string, default: 'https://api.opensuse.org', desc: 'API server'
|
|
9
|
+
option :package, type: :string, default: 'obs-api', desc: 'Package name'
|
|
10
|
+
option :product, type: :string, default: 'SLE_12_SP4', desc: 'Product name'
|
|
11
|
+
option :architecture, type: :string, default: 'x86_64', desc: 'Architecture'
|
|
12
|
+
|
|
13
|
+
def call(host:, product:, **)
|
|
14
|
+
puts "Available package: #{ObsDeploy::CheckDiff.new(server: host, product: product).package_version}"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
module CLI
|
|
5
|
+
module Commands
|
|
6
|
+
class RefreshRepositories < Dry::CLI::Command
|
|
7
|
+
desc 'Refresh zypper repositories'
|
|
8
|
+
option :user, type: :string, default: 'root', desc: 'User'
|
|
9
|
+
option :dry_run, type: :bool, default: true, desc: 'Dry run'
|
|
10
|
+
option :host, type: :string, default: 'localhost', desc: 'Set the server address'
|
|
11
|
+
option :port, type: :int, default: 22, desc: 'Set the server port'
|
|
12
|
+
|
|
13
|
+
def call(user:, dry_run:, host:, port:, **)
|
|
14
|
+
ssh_driver = ObsDeploy::SSH.new(user: user, server: host, port: port)
|
|
15
|
+
zypper = ObsDeploy::Zypper.new
|
|
16
|
+
ssh_driver.run(zypper.refresh)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ObsDeploy
|
|
4
|
+
class SSH
|
|
5
|
+
attr_reader :user, :server, :port, :identity_file
|
|
6
|
+
|
|
7
|
+
def initialize(opts = {})
|
|
8
|
+
@user = opts[:user] || 'root'
|
|
9
|
+
@server = opts[:server] || 'localhost'
|
|
10
|
+
@port = opts[:port] || 22
|
|
11
|
+
@identity_file = opts[:identity_file]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def build_command
|
|
15
|
+
command_line = ['-tt', "#{@user}@#{@server}", '-p', @port.to_s]
|
|
16
|
+
command_line << ['-i', @identity_file] if @identity_file
|
|
17
|
+
['ssh'] + command_line.flatten
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run(cmd)
|
|
21
|
+
results, errors = Cheetah.run(build_command + cmd, stdout: :capture, stderr: :capture)
|
|
22
|
+
puts results
|
|
23
|
+
puts errors
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/obs_deploy.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require 'obs_deploy/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = 'obs_deploy'
|
|
9
|
+
spec.version = ObsDeploy::VERSION
|
|
10
|
+
spec.authors = ['Victor Pereira']
|
|
11
|
+
spec.email = ['vpereira@suse.de']
|
|
12
|
+
|
|
13
|
+
spec.summary = 'OBS Deployment tool'
|
|
14
|
+
spec.homepage = 'https://openbuildservice.org'
|
|
15
|
+
|
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
17
|
+
|
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/vpereira/obs_deploy.git'
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
spec.bindir = 'bin'
|
|
27
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ['lib']
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
31
|
+
spec.add_development_dependency 'pry'
|
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
34
|
+
spec.add_development_dependency 'rubocop'
|
|
35
|
+
spec.add_development_dependency 'webmock'
|
|
36
|
+
spec.add_dependency 'cheetah'
|
|
37
|
+
spec.add_dependency 'dry-cli'
|
|
38
|
+
spec.add_dependency 'nokogiri'
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: obs_deploy
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Victor Pereira
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-04-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: pry
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: webmock
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: cheetah
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: dry-cli
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: nokogiri
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
description:
|
|
140
|
+
email:
|
|
141
|
+
- vpereira@suse.de
|
|
142
|
+
executables:
|
|
143
|
+
- console
|
|
144
|
+
- obs_deploy
|
|
145
|
+
- setup
|
|
146
|
+
extensions: []
|
|
147
|
+
extra_rdoc_files: []
|
|
148
|
+
files:
|
|
149
|
+
- ".circleci/config.yml"
|
|
150
|
+
- ".gitignore"
|
|
151
|
+
- ".rspec"
|
|
152
|
+
- ".travis.yml"
|
|
153
|
+
- Gemfile
|
|
154
|
+
- Gemfile.lock
|
|
155
|
+
- README.md
|
|
156
|
+
- Rakefile
|
|
157
|
+
- bin/console
|
|
158
|
+
- bin/obs_deploy
|
|
159
|
+
- bin/setup
|
|
160
|
+
- dist/Makefile
|
|
161
|
+
- dist/rubygem-obs_deploy.spec
|
|
162
|
+
- lib/obs_deploy.rb
|
|
163
|
+
- lib/obs_deploy/check_diff.rb
|
|
164
|
+
- lib/obs_deploy/cli/commands.rb
|
|
165
|
+
- lib/obs_deploy/cli/commands/deploy.rb
|
|
166
|
+
- lib/obs_deploy/cli/commands/get_deployed_version.rb
|
|
167
|
+
- lib/obs_deploy/cli/commands/get_package_version.rb
|
|
168
|
+
- lib/obs_deploy/cli/commands/refresh_repositories.rb
|
|
169
|
+
- lib/obs_deploy/cli/commands/version.rb
|
|
170
|
+
- lib/obs_deploy/ssh.rb
|
|
171
|
+
- lib/obs_deploy/version.rb
|
|
172
|
+
- obs_deploy.gemspec
|
|
173
|
+
homepage: https://openbuildservice.org
|
|
174
|
+
licenses: []
|
|
175
|
+
metadata:
|
|
176
|
+
allowed_push_host: https://rubygems.org
|
|
177
|
+
homepage_uri: https://openbuildservice.org
|
|
178
|
+
source_code_uri: https://github.com/vpereira/obs_deploy.git
|
|
179
|
+
post_install_message:
|
|
180
|
+
rdoc_options: []
|
|
181
|
+
require_paths:
|
|
182
|
+
- lib
|
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - ">="
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: '0'
|
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
|
+
requirements:
|
|
190
|
+
- - ">="
|
|
191
|
+
- !ruby/object:Gem::Version
|
|
192
|
+
version: '0'
|
|
193
|
+
requirements: []
|
|
194
|
+
rubygems_version: 3.0.6
|
|
195
|
+
signing_key:
|
|
196
|
+
specification_version: 4
|
|
197
|
+
summary: OBS Deployment tool
|
|
198
|
+
test_files: []
|