foreman_envsync 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 237034826a5908b26cf6c4c6404ff49cc88a328b7b5c6934d9771197026c4860
4
- data.tar.gz: 59c58d3e01675713f92d53a445ccede11fb56324d431598d494144281a7a5aca
3
+ metadata.gz: 9a1b0dd3d8f5949db44605891c54f2d4a937b2b194b182ef0dd5887b8632d6d1
4
+ data.tar.gz: a576b9c27487cba2a37fe9be7bcf6fd96e92cd7fc71a476cccbbe2e210b04b6c
5
5
  SHA512:
6
- metadata.gz: 9eea85c919db3abb85cebefdfd5a87d0ab7e1ecaf12c1733e0e9bbee9c67e9d053a30c0aaeaaa46c6dcdb7319fb36b494407aa598dccc6cd8ee8aa990fb8d37c
7
- data.tar.gz: c917d93841accedb333ff01dd8011663a819e8e9e3303a822c562a174a949a9bf646ee56b6670b36da26127bdbf66b9371b11c3f0d9f698670b0a6e46379fda0
6
+ metadata.gz: ca9ac65592854fadd6601e66167dd999d42205334973a14af4d3105b40c8a4b9b345d4517b5c82f922a51959eaae70aeeb9ff38893395e7d03b866150493a3c8
7
+ data.tar.gz: eede0daddd896ba75db5b30325c1222982abd7e095e2c3e329c4c9538106cd238cee5c92e2f6c118ef28533a0f297d7a318856528da774e88928f6ac8e254c01
@@ -0,0 +1,61 @@
1
+ # based on https://github.com/docker/build-push-action/blob/master/docs/advanced/tags-labels.md
2
+
3
+ name: ci
4
+
5
+ on:
6
+ schedule:
7
+ - cron: '0 10 * * 1'
8
+ push:
9
+ branches:
10
+ - '**'
11
+ tags:
12
+ - 'v*.*.*'
13
+ pull_request:
14
+ branches:
15
+ - 'main'
16
+
17
+ jobs:
18
+ release:
19
+ runs-on: ubuntu-latest
20
+ if: github.repository == 'lsst-it/foreman_envsync'
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v3
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: 3.0
28
+ bundler-cache: true
29
+ - name: Run the default task
30
+ run: bundle exec rake
31
+ - name: Build gem
32
+ run: gem build *.gemspec
33
+ - name: Publish gem to rubygems.org
34
+ if: startsWith(github.ref, 'refs/tags/v')
35
+ run: gem push *.gem
36
+ env:
37
+ GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
38
+
39
+ - name: Docker meta
40
+ id: meta
41
+ uses: docker/metadata-action@v4
42
+ with:
43
+ images: |
44
+ lsstit/foreman_envsync
45
+ - name: Set up QEMU
46
+ uses: docker/setup-qemu-action@v2
47
+ - name: Set up Docker Buildx
48
+ uses: docker/setup-buildx-action@v2
49
+ - name: Login to DockerHub
50
+ if: github.event_name != 'pull_request'
51
+ uses: docker/login-action@v2
52
+ with:
53
+ username: ${{ secrets.DOCKERHUB_LSSTIT_USERNAME }}
54
+ password: ${{ secrets.DOCKERHUB_LSSTIT_PASSWORD }}
55
+ - name: Build and push
56
+ uses: docker/build-push-action@v3
57
+ with:
58
+ context: .
59
+ push: ${{ github.event_name != 'pull_request' }}
60
+ tags: ${{ steps.meta.outputs.tags }}
61
+ labels: ${{ steps.meta.outputs.labels }}
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  Gemfile.lock
10
+ *.gem
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
data/Dockerfile ADDED
@@ -0,0 +1,6 @@
1
+ FROM ruby:3.0
2
+
3
+ COPY *.gem .
4
+ RUN gem install --no-document *.gem
5
+
6
+ ENTRYPOINT ["/usr/local/bundle/bin/foreman_envsync"]
data/README.md CHANGED
@@ -4,6 +4,11 @@ A highly opinionated utility to sync foreman puppet environments with the set
4
4
  of environments known to a `puppetserver` instance *without* also importing the
5
5
  classes within those puppet environments.
6
6
 
7
+ ## OCI Image
8
+
9
+ An OCI image containing this gem is published to docker hub as
10
+ [`lsstit/foreman_envsync`](https://hub.docker.com/repository/docker/lsstit/foreman_envsync).
11
+
7
12
 
8
13
  ## The Problem
9
14
 
data/exe/foreman_envsync CHANGED
@@ -30,7 +30,7 @@ def verbose_list(msg, items)
30
30
 
31
31
  printf(msg, items.count)
32
32
  puts
33
- puts "#{YAML.dump(items)}\n" unless items.empty?
33
+ puts "#{YAML.dump(items.sort)}\n" unless items.empty?
34
34
  end
35
35
 
36
36
  def cert_file(file)
@@ -41,21 +41,21 @@ def key_file(file)
41
41
  OpenSSL::PKey::RSA.new(File.read(file))
42
42
  end
43
43
 
44
- def hammer_cmd(cmd)
44
+ def hammer_cmd(cmd, opt = { ignore_exitstatus: false })
45
45
  stdout, stderr, s = Open3.capture3(cmd)
46
46
  unless s.success?
47
47
  puts "command #{cmd} failed"
48
48
  puts stderr
49
- exit s.exitstatus
49
+ exit s.exitstatus unless opt[:ignore_exitstatus]
50
50
  end
51
51
 
52
52
  stdout
53
53
  end
54
54
 
55
- def hammer_cmd_parse(cmd)
56
- stdout = hammer_cmd(cmd)
55
+ def hammer_cmd_parse(cmd, **opt)
56
+ stdout = hammer_cmd(cmd, opt)
57
57
 
58
- JSON.parse(stdout)
58
+ JSON.parse(stdout) unless stdout.empty?
59
59
  end
60
60
 
61
61
  def collect_one_field(data, field)
@@ -78,7 +78,7 @@ end
78
78
  def foreman_env_delete(name)
79
79
  cmd = "hammer --output=json puppet-environment delete --name #{name}"
80
80
 
81
- hammer_cmd_parse(cmd)
81
+ hammer_cmd_parse(cmd, ignore_exitstatus: true)
82
82
  end
83
83
 
84
84
  def foreman_env_create(name, location_ids, org_ids)
@@ -143,7 +143,7 @@ verbose_list "found %d foreman environment(s) unknown to puppetserver.", extra_e
143
143
  # Remove any foreman envs unknown to puppetserver
144
144
  #
145
145
  report = extra_envs.collect { |x| foreman_env_delete(x) } unless extra_envs.empty?
146
- verbose_list "deleted %d foreman environment(s).", report
146
+ verbose_list "deleted %d foreman environment(s).", report.nil? ? nil : report.compact
147
147
 
148
148
  # update foreman envs if anything was deleted
149
149
  f_envs = foreman_env_list unless report.nil?
@@ -28,10 +28,12 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_runtime_dependency "hammer_cli"
30
30
  spec.add_runtime_dependency "hammer_cli_foreman"
31
+ spec.add_runtime_dependency "hammer_cli_foreman_puppet"
31
32
  spec.add_runtime_dependency "rest-client", "~> 2.0"
32
33
  spec.add_development_dependency "rubocop-rake"
33
34
  spec.add_development_dependency "rubocop-rspec"
34
35
 
35
36
  # For more information and examples about making a new gem, checkout our
36
37
  # guide at: https://bundler.io/guides/creating_gem.html
38
+ spec.metadata["rubygems_mfa_required"] = "true"
37
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanEnvsync
4
- VERSION = "1.0.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_envsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Hoblitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-10 00:00:00.000000000 Z
11
+ date: 2022-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hammer_cli_foreman_puppet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rest-client
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -88,11 +102,12 @@ executables:
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
- - ".github/workflows/main.yml"
105
+ - ".github/workflows/ci.yaml"
92
106
  - ".gitignore"
93
107
  - ".rspec"
94
108
  - ".rubocop.yml"
95
109
  - CHANGELOG.md
110
+ - Dockerfile
96
111
  - Gemfile
97
112
  - LICENSE.txt
98
113
  - README.md
@@ -110,6 +125,7 @@ metadata:
110
125
  homepage_uri: https://github.com/lsst-it/foreman_envsync
111
126
  source_code_uri: https://github.com/lsst-it/foreman_envsync
112
127
  changelog_uri: https://github.com/lsst-it/foreman_envsync/blob/master/CHANGELOG.md
128
+ rubygems_mfa_required: 'true'
113
129
  post_install_message:
114
130
  rdoc_options: []
115
131
  require_paths:
@@ -125,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
141
  - !ruby/object:Gem::Version
126
142
  version: '0'
127
143
  requirements: []
128
- rubygems_version: 3.1.4
144
+ rubygems_version: 3.1.6
129
145
  signing_key:
130
146
  specification_version: 4
131
147
  summary: Sync pupperserver envs with foreman
@@ -1,16 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- uses: ruby/setup-ruby@v1
12
- with:
13
- ruby-version: 2.7.2
14
- bundler-cache: true
15
- - name: Run the default task
16
- run: bundle exec rake