obs_deploy 0.2.2 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41cc050c5b998c658f9e490356baecffde0c4d20c8f9856cb3f9d9365e47ff2d
4
- data.tar.gz: 9c4bf4468558287c91bcce67af42af569020d4414d9676fd535bbb6ea503f81d
3
+ metadata.gz: a0f5719e3a953c7cabd13373bb9671b6f9ba030375eddcf6309d0eb4ecc197b8
4
+ data.tar.gz: 726533caf0cc85fa5421d536944c5f7d768b657746f042797119129ecc62ae00
5
5
  SHA512:
6
- metadata.gz: 3935393353a5b72e06bccc8ae92c9dc53f1047fe20d8d7597c8ed80d081e4e1f17a6e816c9f61c5a1fd13c3b1293e51695e1aa2126a23c17d57957a3534124c3
7
- data.tar.gz: acdfdcde737dd62fbdfde71225a4a71878118671f5a3b9c638090478c2ee8cea3cb0e56b35042caf009b8de4e682b169b8929a028dd9142666b28294e210b4cc
6
+ metadata.gz: 234fc276e10b4a7d85bb8ac4e8c27a58846651469c3bec4f40d0aa9c6c109ff7badefdf51bb4422e428a265ebe5671ce925c89ea8db53fb07aeda1cce67edb88
7
+ data.tar.gz: fd1a3f6fd2bbdab8700cf9e50cac99c7d5ad63a185ea338c5793386f04a1c544b2328aa0e991e60d9cafe8accbdcd4c737b5223fb59ce242732c352fcad0029a
@@ -0,0 +1,26 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
11
+
12
+ AllCops:
13
+ Exclude:
14
+ - 'dist/rubygem-obs_deploy.spec'
15
+
16
+ Metrics/BlockLength:
17
+ Enabled: false
18
+
19
+ Layout/LineLength:
20
+ Enabled: false
21
+
22
+ Layout/LineLength:
23
+ Enabled: false
24
+
25
+ Style/Documentation:
26
+ Enabled: false
@@ -0,0 +1,8 @@
1
+ FROM opensuse/tumbleweed
2
+
3
+ RUN zypper --gpg-auto-import-keys refresh
4
+ RUN zypper install -y openssh vim iputils
5
+
6
+ COPY entrypoint.sh /entrypoint.sh
7
+ RUN chmod +x /entrypoint.sh
8
+ ENTRYPOINT ["/entrypoint.sh"]
File without changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- obs_deploy (0.2.2)
4
+ obs_deploy (0.3.1)
5
5
  cheetah
6
6
  dry-cli
7
7
  nokogiri
@@ -16,7 +16,7 @@ GEM
16
16
  cheetah (0.5.2)
17
17
  abstract_method (~> 1.2)
18
18
  coderay (1.1.2)
19
- concurrent-ruby (1.1.6)
19
+ concurrent-ruby (1.1.7)
20
20
  crack (0.4.3)
21
21
  safe_yaml (~> 1.0.0)
22
22
  diff-lcs (1.3)
@@ -25,9 +25,10 @@ GEM
25
25
  hashdiff (1.0.1)
26
26
  jaro_winkler (1.5.4)
27
27
  method_source (1.0.0)
28
- mini_portile2 (2.4.0)
29
- nokogiri (1.10.9)
30
- mini_portile2 (~> 2.4.0)
28
+ mini_portile2 (2.5.0)
29
+ nokogiri (1.11.0)
30
+ mini_portile2 (~> 2.5.0)
31
+ racc (~> 1.4)
31
32
  parallel (1.19.1)
32
33
  parser (2.7.0.5)
33
34
  ast (~> 2.4.0)
@@ -35,6 +36,7 @@ GEM
35
36
  coderay (~> 1.1)
36
37
  method_source (~> 1.0)
37
38
  public_suffix (4.0.3)
39
+ racc (1.5.2)
38
40
  rainbow (3.0.0)
39
41
  rake (13.0.1)
40
42
  rexml (3.2.4)
@@ -0,0 +1,9 @@
1
+ docker-dev:
2
+ docker build -f Dockerfile.dev -t $(USER)/obs_deploy_dev .
3
+ docker run --rm -it -v "$(HOME)/.ssh:/tmp/.ssh:ro" -v "$(PWD):/obs_deploy" $(USER)/obs_deploy_dev bash
4
+
5
+ docker-rpm:
6
+ docker build -f Dockerfile.rpm -t $(USER)/obs_deploy_dev .
7
+ docker run --rm -it -v "$(HOME)/.ssh:/tmp/.ssh:ro" -v "$(PWD):/obs_deploy" $(USER)/obs_deploy_dev bash
8
+
9
+
data/README.md CHANGED
@@ -5,6 +5,9 @@ Simple tool to deploy OBS via zypper to our reference server
5
5
  ## Build Status
6
6
  [![CircleCI](https://circleci.com/gh/vpereira/obs_deploy.svg?style=svg)](https://app.circleci.com/pipelines/github/vpereira/obs_deploy)
7
7
 
8
+ ## Codebeat
9
+ [![codebeat badge](https://codebeat.co/badges/767d7e65-0364-4386-a26e-99ad228dfe31)](https://codebeat.co/projects/github-com-vpereira-obs_deploy-master)
10
+
8
11
 
9
12
  ## Installation
10
13
 
@@ -61,6 +64,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
61
64
 
62
65
  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).
63
66
 
67
+ ### Fixtures
68
+
69
+ To generate the fixtures (located under `spec/fixtures`), we are using `curl -si $URL > $FIXTURE`
70
+
64
71
  ### Run the `bin/obs_deploy` on development:
65
72
 
66
73
  On the checked out source, run the following:
@@ -80,7 +87,7 @@ if you want to run it against the OBS appliance running on VirtualBox:
80
87
  - then run the container as:
81
88
 
82
89
  ```
83
- docker run --rm -it -v "$HOME/.ssh:/tmp/.ssh:ro" $USER/obs_deploy bash
90
+ make docker-dev
84
91
  ```
85
92
  Now you are inside the container and should be able to ping the obs appliance.
86
93
 
@@ -97,6 +104,15 @@ If you want to add new command to the cli, please read the `dry-cli` documentati
97
104
 
98
105
  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
99
106
 
107
+ ## RPM Building
108
+
109
+ Under dist/ we have the necessary files to use to build the gem as rpm. The
110
+ `_service` still not used. Mainly because we need either to build the rubygem
111
+ dependencies or use https://github.com/openSUSE/obs-service-bundle_gems
112
+
113
+ Today as it is, you have to push the gem to rubygems and then generate the spec
114
+ and push it to build service
115
+
100
116
  ## Contributing
101
117
 
102
118
  Bug reports and pull requests are welcome on GitHub at https://github.com/vpereira/obs_deploy.
@@ -1,6 +1,6 @@
1
1
  spec:
2
2
  gem2rpm --fetch obs_deploy > rubygem-obs_deploy.spec
3
3
  rm *.gem
4
- clean:
4
+ spec-clean:
5
5
  spec-cleaner rubygem-obs_deploy.spec > x.spec
6
6
  mv x.spec rubygem-obs_deploy.spec
@@ -1,4 +1,12 @@
1
1
  <services>
2
- <service name="download_files">
2
+ <service name="tar_scm">
3
+ <param name="scm">git</param>
4
+ <param name="url">git://github.com/vpereira/obs_deploy.git</param>
5
+ <param name="revision">master</param>
6
+ <param name="version">0.2.0</param>
3
7
  </service>
8
+ <service name="recompress">
9
+ <param name="file">*.tar</param>
10
+ <param name="compression">xz</param>
11
+ </service>
4
12
  </services>
@@ -18,23 +18,21 @@
18
18
 
19
19
  %define mod_name obs_deploy
20
20
  %define mod_full_name %{mod_name}-%{version}
21
- %define rb_suffix ruby2.6
22
21
  Name: rubygem-obs_deploy
23
- Version: 0.2.0
22
+ Version: 0.3.0
24
23
  Release: 0
25
24
  Summary: OBS Deployment tool
26
- License: MIT
25
+ License:
27
26
  Group: Development/Languages/Ruby
28
27
  URL: https://openbuildservice.org
29
28
  Source: https://rubygems.org/gems/%{mod_full_name}.gem
30
29
  BuildRequires: %{rubygem gem2rpm}
31
30
  BuildRequires: %{ruby}
32
31
  BuildRequires: ruby-macros >= 5
33
- BuildRequires: ruby-common-rails
32
+ BuildRequires: update-alternatives
34
33
  # FIXME: use proper Requires(pre/post/preun/...)
35
34
  PreReq: update-alternatives
36
35
 
37
-
38
36
  %description
39
37
  OBS Deployment tool.
40
38
 
@@ -43,7 +41,6 @@ OBS Deployment tool.
43
41
  %build
44
42
 
45
43
  %install
46
- %rails_fix_ruby_shebang bin/
47
44
  %gem_install \
48
45
  --symlink-binaries \
49
46
  --doc-files="README.md" \
@@ -11,6 +11,8 @@ require 'obs_deploy/check_diff'
11
11
  require 'obs_deploy/ssh'
12
12
  require 'obs_deploy/zypper'
13
13
  require 'obs_deploy/systemctl'
14
+ require 'obs_deploy/apache_sysconfig'
15
+ require 'tempfile'
14
16
 
15
17
  module ObsDeploy
16
18
  class Error < StandardError; end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ObsDeploy
4
+ class ApacheSysconfig
5
+ attr_reader :path
6
+
7
+ def initialize
8
+ @path = '/etc/sysconfig/apache2'
9
+ end
10
+
11
+ def enable_maintenance_mode
12
+ unless maintenance_mode?
13
+ content = File.read(path).gsub(/^#{server_flags}=\"STATUS\"$/,
14
+ apache_status_line(maintenance))
15
+ write_apache_sysconfig(content)
16
+ end
17
+ end
18
+
19
+ def disable_maintenance_mode
20
+ if maintenance_mode?
21
+ content = File.read(path).gsub(/^#{server_flags}=\"STATUS MAINTENANCE\"/,
22
+ apache_status_line(no_maintenance))
23
+ write_apache_sysconfig(content)
24
+ end
25
+ end
26
+
27
+ def maintenance_mode?
28
+ find_server_flags.all? { |r| r.include?('MAINTENANCE') }
29
+ end
30
+
31
+ private
32
+
33
+ def no_maintenance
34
+ 'STATUS'
35
+ end
36
+
37
+ def maintenance
38
+ 'STATUS MAINTENANCE'
39
+ end
40
+
41
+ def server_flags
42
+ 'APACHE_SERVER_FLAGS'
43
+ end
44
+
45
+ def apache_status_line(status)
46
+ "#{server_flags}=\"#{status}\""
47
+ end
48
+
49
+ def find_server_flags
50
+ File.readlines(path).grep(/^#{server_flags}=/)
51
+ end
52
+
53
+ def write_apache_sysconfig(content)
54
+ f = Tempfile.new
55
+ f.write(content)
56
+ begin
57
+ File.rename(f.path, path)
58
+ rescue SystemCallError => e
59
+ puts e.inspect
60
+ ensure
61
+ f.unlink
62
+ f.close
63
+ end
64
+ end
65
+ end
66
+ end
@@ -2,9 +2,10 @@
2
2
 
3
3
  module ObsDeploy
4
4
  class CheckDiff
5
- def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4')
5
+ def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4', project: 'OBS:Server:Unstable')
6
6
  @server = server
7
7
  @product = product
8
+ @project = project
8
9
  end
9
10
 
10
11
  def package_version
@@ -25,10 +26,26 @@ module ObsDeploy
25
26
  Net::HTTP.get(URI("https://github.com/openSUSE/open-build-service/compare/#{obs_running_commit}...#{package_commit}.diff"))
26
27
  end
27
28
 
29
+ def new_version_available?
30
+ obs_running_commit != package_commit
31
+ end
32
+
28
33
  def has_migration?
29
34
  return true if github_diff.nil? || github_diff.empty?
30
35
 
31
- !!github_diff.match(%r{db/migrate})
36
+ github_diff.match?(%r{db/migrate})
37
+ end
38
+
39
+ def has_data_migration?
40
+ return true if github_diff.nil? || github_diff.empty?
41
+
42
+ github_diff.match(%r{db/data})
43
+ end
44
+
45
+ def data_migrations
46
+ return [] unless has_data_migration?
47
+
48
+ github_diff.match(%r{db/data/.*\.rb}).to_a
32
49
  end
33
50
 
34
51
  def migrations
@@ -38,7 +55,7 @@ module ObsDeploy
38
55
  end
39
56
 
40
57
  def package_url
41
- URI("#{@server}/public/build/OBS:Server:Unstable/#{@product}/x86_64/obs-server")
58
+ URI("#{@server}/public/build/#{@project}/#{@product}/x86_64/obs-server")
42
59
  end
43
60
 
44
61
  def about_url
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ObsDeploy
4
+ module CLI
5
+ class GetDiff
6
+ end
7
+ end
8
+ end
@@ -10,6 +10,14 @@ module ObsDeploy
10
10
  run ['systemctl'] + ['list-dependencies'] + target
11
11
  end
12
12
 
13
+ def restart_apache
14
+ run ['systemctl'] + ['restart'] + ['apache2']
15
+ end
16
+
17
+ def status_apache
18
+ run ['systemctl'] + ['status'] + ['apache2']
19
+ end
20
+
13
21
  private
14
22
 
15
23
  def target
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ObsDeploy
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.1'
5
5
  end
@@ -6,17 +6,33 @@ module ObsDeploy
6
6
 
7
7
  def initialize(dry_run: true, package_name: 'obs-api')
8
8
  @dry_run = dry_run
9
+ @package_name = package_name
9
10
  end
10
11
 
11
12
  def update
12
- run ['zypper'] + update_string + package_name
13
+ run %w[zypper] + update_string + package_name
13
14
  end
14
15
 
15
16
  def refresh
16
- run ['zypper', '--non-interactive', '--gpg-auto-import-keys', 'refresh']
17
+ run %w[zypper --non-interactive --gpg-auto-import-keys refresh]
17
18
  end
18
19
 
19
- private
20
+ # TODO
21
+ # check if we want to lock from specific repositories
22
+ def add_lock
23
+ run %w[zypper addlock] + package_name
24
+ end
25
+
26
+ def remove_lock
27
+ run %w[zypper removelock] + package_name
28
+ end
29
+
30
+ def locked?
31
+ # check the return value
32
+ run %w[zypper locks] + package_name
33
+ end
34
+
35
+ private
20
36
 
21
37
  def run(params)
22
38
  params
@@ -31,15 +47,15 @@ module ObsDeploy
31
47
  end
32
48
 
33
49
  def package_name
34
- ['obs-api']
50
+ [@package_name]
35
51
  end
36
52
 
37
53
  def update_params
38
- ['--non-interactive', 'update', '--best-effort', '--details']
54
+ %w[--non-interactive update --best-effort --details]
39
55
  end
40
56
 
41
57
  def dry_run_params
42
- ['--dry-run --download-only']
58
+ %w[--dry-run --download-only]
43
59
  end
44
- end
60
+ end
45
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obs_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pereira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-17 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description:
139
+ description:
140
140
  email:
141
141
  - vpereira@suse.de
142
142
  executables:
@@ -149,10 +149,13 @@ files:
149
149
  - ".circleci/config.yml"
150
150
  - ".gitignore"
151
151
  - ".rspec"
152
+ - ".rubocop.yml"
152
153
  - ".travis.yml"
153
- - Dockerfile
154
+ - Dockerfile.dev
155
+ - Dockerfile.rpm
154
156
  - Gemfile
155
157
  - Gemfile.lock
158
+ - Makefile
156
159
  - README.md
157
160
  - Rakefile
158
161
  - bin/console
@@ -163,10 +166,12 @@ files:
163
166
  - dist/rubygem-obs_deploy.spec
164
167
  - entrypoint.sh
165
168
  - lib/obs_deploy.rb
169
+ - lib/obs_deploy/apache_sysconfig.rb
166
170
  - lib/obs_deploy/check_diff.rb
167
171
  - lib/obs_deploy/cli/commands.rb
168
172
  - lib/obs_deploy/cli/commands/deploy.rb
169
173
  - lib/obs_deploy/cli/commands/get_deployed_version.rb
174
+ - lib/obs_deploy/cli/commands/get_diff.rb
170
175
  - lib/obs_deploy/cli/commands/get_package_version.rb
171
176
  - lib/obs_deploy/cli/commands/get_pending_migration.rb
172
177
  - lib/obs_deploy/cli/commands/refresh_repositories.rb
@@ -183,7 +188,7 @@ metadata:
183
188
  allowed_push_host: https://rubygems.org
184
189
  homepage_uri: https://openbuildservice.org
185
190
  source_code_uri: https://github.com/vpereira/obs_deploy.git
186
- post_install_message:
191
+ post_install_message:
187
192
  rdoc_options: []
188
193
  require_paths:
189
194
  - lib
@@ -199,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
204
  version: '0'
200
205
  requirements: []
201
206
  rubygems_version: 3.0.6
202
- signing_key:
207
+ signing_key:
203
208
  specification_version: 4
204
209
  summary: OBS Deployment tool
205
210
  test_files: []