supermarket_sync 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 818056b410af5497f35e4e401e0d527890627e1be89b43733c8c2572b20fecd1
4
- data.tar.gz: c003e878b9c3986ac4d1996ca37a097af0133475c3913add3c16a5b8b564f0b4
3
+ metadata.gz: e49526e10c933bd481d24189a6ea0d08a11cfe358fbeb4167911417d6b18e6d3
4
+ data.tar.gz: f144b0219e2d50c18bdfceb8633d3d84029d8e93bfac8ae94f8743ccc5cff03a
5
5
  SHA512:
6
- metadata.gz: e5063cfe32685f9f93794fa626608963d2aa1432749f9406d6a6ba5b84492384ccec8e4dd16c089a06200e881237a9da9fe8933da4d230ca91e646b6bc3cb018
7
- data.tar.gz: 9b12d8f1b4dceda17a36783eae45004bd9ff3fa7644ff35e8ab503edba66ad640478432f6a0457723612e66f9bd4cb6c3951c9c190abac5b1f7c271b2f64ac23
6
+ metadata.gz: fb5c4cef8a6e3c413029d6d1b90c9e589bc7ebf06b29c584387ba020e49d8689f5b203bf9bbe90bba565ced34b72c46aafb0fcbb29a66ec480be9ae215d7ef67
7
+ data.tar.gz: bb790be524aa65b246e8bd4747cdfbdd27ce55b34c5fa5b0a3d9e90571ed8f094f20d75eae9d9238fc59e2ed0626386ce77ba1286ac63438e956d31a15688370
@@ -0,0 +1,36 @@
1
+ name: Ruby
2
+ on: [push]
3
+ jobs:
4
+ test:
5
+ name: Build
6
+ runs-on: ubuntu-latest
7
+ container: ruby:3.0
8
+ steps:
9
+ - name: Check out code
10
+ uses: actions/checkout@v2
11
+ with:
12
+ fetch-depth: 0
13
+
14
+ - name: Git Info
15
+ id: git
16
+ run: |
17
+ echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
18
+ echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
19
+ echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
20
+
21
+ - name: Test
22
+ env:
23
+ ABC: '123'
24
+ run: |
25
+ gem install rubocop --no-document
26
+ rubocop
27
+
28
+ - name: Release
29
+ if: startsWith(github.ref, 'refs/tags/')
30
+ env:
31
+ ABC: '123'
32
+ run: |
33
+ gem install dpl --no-document
34
+ find . -type f -exec chmod o--w "{}" \;
35
+
36
+ - run: dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY --gem=supermarket_sync
data/.gitlab-ci.yml CHANGED
@@ -4,8 +4,8 @@ before_script:
4
4
  - gem install bundler --no-document
5
5
  - bundle install --jobs $(nproc) --path vendor/bundle
6
6
 
7
- test:Ruby 2.5:
8
- image: ruby:2.5
7
+ test:Ruby 3.0:
8
+ image: ruby:3.0
9
9
  cache:
10
10
  paths:
11
11
  - .bundle
@@ -13,12 +13,12 @@ test:Ruby 2.5:
13
13
  script:
14
14
  - bundle exec rubocop
15
15
  tags:
16
- - ruby
16
+ - docker
17
17
  except:
18
18
  - tags
19
19
 
20
- release:Ruby 2.5:
21
- image: ruby:2.5
20
+ release:Ruby 3.0:
21
+ image: ruby:3.0
22
22
  cache:
23
23
  paths:
24
24
  - .bundle
@@ -33,6 +33,6 @@ release:Ruby 2.5:
33
33
  paths:
34
34
  - ./*.gem
35
35
  tags:
36
- - ruby
36
+ - docker
37
37
  only:
38
38
  - tags
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.5.3
1
+ ruby-3.0.2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@ SupermarketSync Changelog
2
2
  =========================
3
3
  This file is used to list changes made in each version of the `supermarket_sync` gem.
4
4
 
5
- v0.1.0 (2016-11-09)
5
+ v0.1.3 (2019-8-2)
6
6
  -------------------
7
- - Initial Release TBD
7
+ - Ignore cookbook category due to deprecation
8
+
9
+ v0.1.2 (2018-11-12)
10
+ -------------------
11
+ - Expose more configuration via environment variables
12
+
13
+ v0.1.1 (2018-11-12)
14
+ -------------------
15
+ - Fix for non-existing cookbooks
16
+ - Rename function to avoid potential namespace collision
17
+ - Add a read-only mode for testing purposes
18
+
19
+ v0.1.0 (2018-11-09)
20
+ -------------------
21
+ - Initial Release
data/README.md CHANGED
@@ -2,25 +2,9 @@
2
2
  * Ruby Gem to programmatically synchronize Chef Supermarkets
3
3
 
4
4
  ## Background
5
- This gem was built from a need to synchronize a private, internal Chef Supermarket from the Public Chef Supermarket.
5
+ This gem was built from a need to synchronize approved cookbooks to a private, internal Chef Supermarket from the Public Chef Supermarket.
6
6
 
7
- At the same time, being able to send notifications of changes and deprecations was also desired.
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'supermarket_sync'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install supermarket_sync
7
+ It was also desired to send notifications upon changes and deprecations.
24
8
 
25
9
  ## Usage
26
10
 
@@ -30,15 +14,21 @@ Usage: supermarket_sync (options)
30
14
  --cookbooks-json CONFIG List of cookbooks to synchronize
31
15
  ```
32
16
 
33
- You can supply individual configuration for supermarkets invidivually via the configuration file.
17
+ * Supermarkets can be configured individually via the configuration file.
34
18
 
35
- Otherwise, you can configure global Chef parameters via environment variables. This may prove handy in a CI pipeline scenario.
19
+ * If left unspecified, global Supermarket parameters can be passed in via environment variables.
36
20
 
37
21
  ```
22
+ # Set Supermarket Globals
38
23
  export SM_USER='supermarket_user'
39
24
  export SM_KEY='/path/to/my/key.pem'
25
+
26
+ # Sync the Supermarkets
27
+ supermarket_sync -c config.json --cookbooks-json cookbooks.json
40
28
  ```
41
29
 
30
+ * Slack notifications are optional and can be configured via notification hash in `config.json`.
31
+
42
32
  #### Configuration Samples
43
33
 
44
34
  `config.json`
@@ -77,7 +67,21 @@ export SM_KEY='/path/to/my/key.pem'
77
67
  }
78
68
  ```
79
69
 
80
- ####
70
+ ## Installation
71
+
72
+ Add this line to your application's Gemfile:
73
+
74
+ ```ruby
75
+ gem 'supermarket_sync'
76
+ ```
77
+
78
+ And then execute:
79
+
80
+ $ bundle
81
+
82
+ Or install it yourself as:
83
+
84
+ $ gem install supermarket_sync
81
85
 
82
86
 
83
87
  ## Development
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # The MIT License (MIT)
7
7
  #
8
- # Copyright:: 2018, Brian Dwyer - Broadridge Financial Solutions
8
+ # Copyright:: 2021, Brian Dwyer - Broadridge Financial Solutions
9
9
  #
10
10
 
11
11
  require 'mixlib/cli'
@@ -60,6 +60,7 @@ module SupermarketSync
60
60
  cfg.notification = config[:notification]
61
61
  cfg.supermarkets = config[:supermarkets]
62
62
  cfg.source = config[:source]
63
+ cfg.read_only = config[:read_only]
63
64
  end
64
65
 
65
66
  # => Start the Sync
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # The MIT License (MIT)
7
7
  #
8
- # Copyright:: 2018, Brian Dwyer - Broadridge Financial Solutions
8
+ # Copyright:: 2021, Brian Dwyer - Broadridge Financial Solutions
9
9
  #
10
10
 
11
11
  require 'supermarket_sync/helpers/configuration'
@@ -25,10 +25,10 @@ module SupermarketSync
25
25
  define_setting :author, 'Brian Dwyer - Broadridge Financial Services'
26
26
 
27
27
  # => Config File
28
- define_setting :config_file, File.join(root, 'config', 'config.json')
28
+ define_setting :config_file, ENV['SM_SYNC_CONFIG'] || File.join(root, 'config', 'config.json')
29
29
 
30
30
  # => Cookbooks File
31
- define_setting :cookbooks_file, File.join(root, 'config', 'cookbooks.json')
31
+ define_setting :cookbooks_file, ENV['SM_SYNC_COOKBOOKS'] || File.join(root, 'config', 'cookbooks.json')
32
32
 
33
33
  # => Supermarket Configuration
34
34
  define_setting :supermarkets, {}
@@ -44,6 +44,9 @@ module SupermarketSync
44
44
  user: ENV['SM_USER'],
45
45
  key: ENV['SM_KEY']
46
46
 
47
+ # => Read-Only Mode
48
+ define_setting :read_only, ENV['SM_SYNC_READONLY']
49
+
47
50
  #
48
51
  # Facilitate Dynamic Addition of Configuration Values
49
52
  #
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # The MIT License (MIT)
7
7
  #
8
- # Copyright:: 2018, Brian Dwyer - Broadridge Financial Solutions
8
+ # Copyright:: 2021, Brian Dwyer - Broadridge Financial Solutions
9
9
  #
10
10
 
11
11
  require 'slack-notifier'
@@ -5,14 +5,14 @@
5
5
  #
6
6
  # The MIT License (MIT)
7
7
  #
8
- # Copyright:: 2018, Brian Dwyer - Broadridge Financial Solutions
8
+ # Copyright:: 2021, Brian Dwyer - Broadridge Financial Solutions
9
9
  #
10
10
 
11
11
  require 'chef/http/json_input'
12
12
  require 'chef/http/json_output'
13
13
  require 'chef/http/remote_request_id'
14
14
  require 'chef/http/simple_json'
15
- require 'chef/cookbook_site_streaming_uploader'
15
+ require 'chef/knife/core/cookbook_site_streaming_uploader'
16
16
  require 'mixlib/cli'
17
17
  require 'supermarket_sync/notifier'
18
18
 
@@ -38,7 +38,7 @@ module SupermarketSync
38
38
  puts "Checking #{cookbook}"
39
39
  # => Grab Source Metadata
40
40
  source_meta = begin
41
- source.get("/api/v1/cookbooks/#{cookbook}")
41
+ src.get("/api/v1/cookbooks/#{cookbook}")
42
42
  rescue Net::HTTPServerException => e
43
43
  raise e unless e.response.code == '404'
44
44
  puts 'Cookbook not available on Source Supermarket'
@@ -53,7 +53,7 @@ module SupermarketSync
53
53
  rescue Net::HTTPServerException => e
54
54
  raise e unless e.response.code == '404'
55
55
  # => Cookbook not found -- Initial Upload
56
- {}['latest_version'] = '0.0.0'
56
+ { 'latest_version' => '0.0.0' }
57
57
  end
58
58
  # => Determine Current Version
59
59
  current = ::Gem::Version.new(::File.basename(dest_meta['latest_version']))
@@ -64,10 +64,10 @@ module SupermarketSync
64
64
  puts "Destination: #{current}"
65
65
 
66
66
  # => Retrieve the Cookbook
67
- tgz = source.streaming_request("/api/v1/cookbooks/#{cookbook}/versions/#{latest}/download")
67
+ tgz = src.streaming_request("/api/v1/cookbooks/#{cookbook}/versions/#{latest}/download")
68
68
 
69
69
  # => Upload the Cookbook
70
- upload(source_meta['category'], tgz)
70
+ upload('other', tgz) unless Config.read_only
71
71
 
72
72
  # => Remove the Tempfile
73
73
  begin
@@ -112,18 +112,18 @@ module SupermarketSync
112
112
  end
113
113
  end
114
114
 
115
- source context[:source] || Config.source
116
- dest context[:url]
115
+ src context[:source] || Config.source
116
+ dest context[:url]
117
117
  end
118
118
 
119
119
  #
120
120
  # => API Clients
121
121
  #
122
- private def source(url = nil)
123
- url ||= @source&.url
122
+ def src(url = nil)
123
+ url ||= @src&.url
124
124
  raise ArgumentError, 'No URL supplied!' unless url
125
- return @source if @source&.url == url
126
- @source = Chef::HTTP::SimpleJSON.new(url)
125
+ return @src if @src&.url == url
126
+ @src = Chef::HTTP::SimpleJSON.new(url)
127
127
  end
128
128
 
129
129
  private def dest(url = nil)
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # The MIT License (MIT)
7
7
  #
8
- # Copyright:: 2018, Brian Dwyer - Broadridge Financial Solutions
8
+ # Copyright:: 2021, Brian Dwyer - Broadridge Financial Solutions
9
9
  #
10
10
 
11
11
  require 'json'
@@ -1,3 +1,3 @@
1
1
  module SupermarketSync
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -28,12 +28,13 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  # => Dependencies
31
- spec.add_runtime_dependency 'chef', '> 12.19.36'
32
- spec.add_runtime_dependency 'slack-notifier', '~> 2.3.2'
31
+ spec.add_runtime_dependency 'knife', '>= 17.1', '< 18.0'
32
+ spec.add_runtime_dependency 'mixlib-cli', '>= 2.1.1', '< 3.0'
33
+ spec.add_runtime_dependency 'slack-notifier', '~> 2.4.0'
33
34
 
34
35
  # => Development Dependencies
35
- spec.add_development_dependency 'bundler', '~> 1.12'
36
- spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'bundler', '~> 2.0'
37
+ spec.add_development_dependency 'rake', '>= 12.3.3'
37
38
  spec.add_development_dependency 'rspec', '~> 3.0'
38
39
  spec.add_development_dependency 'rubocop', '= 0.55'
39
40
  end
metadata CHANGED
@@ -1,71 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supermarket_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dwyer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-10 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: chef
14
+ name: knife
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 12.19.36
19
+ version: '17.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '18.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ">"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '17.1'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 12.19.36
32
+ version: '18.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: mixlib-cli
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.1.1
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.1.1
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3.0'
27
53
  - !ruby/object:Gem::Dependency
28
54
  name: slack-notifier
29
55
  requirement: !ruby/object:Gem::Requirement
30
56
  requirements:
31
57
  - - "~>"
32
58
  - !ruby/object:Gem::Version
33
- version: 2.3.2
59
+ version: 2.4.0
34
60
  type: :runtime
35
61
  prerelease: false
36
62
  version_requirements: !ruby/object:Gem::Requirement
37
63
  requirements:
38
64
  - - "~>"
39
65
  - !ruby/object:Gem::Version
40
- version: 2.3.2
66
+ version: 2.4.0
41
67
  - !ruby/object:Gem::Dependency
42
68
  name: bundler
43
69
  requirement: !ruby/object:Gem::Requirement
44
70
  requirements:
45
71
  - - "~>"
46
72
  - !ruby/object:Gem::Version
47
- version: '1.12'
73
+ version: '2.0'
48
74
  type: :development
49
75
  prerelease: false
50
76
  version_requirements: !ruby/object:Gem::Requirement
51
77
  requirements:
52
78
  - - "~>"
53
79
  - !ruby/object:Gem::Version
54
- version: '1.12'
80
+ version: '2.0'
55
81
  - !ruby/object:Gem::Dependency
56
82
  name: rake
57
83
  requirement: !ruby/object:Gem::Requirement
58
84
  requirements:
59
- - - "~>"
85
+ - - ">="
60
86
  - !ruby/object:Gem::Version
61
- version: '10.0'
87
+ version: 12.3.3
62
88
  type: :development
63
89
  prerelease: false
64
90
  version_requirements: !ruby/object:Gem::Requirement
65
91
  requirements:
66
- - - "~>"
92
+ - - ">="
67
93
  - !ruby/object:Gem::Version
68
- version: '10.0'
94
+ version: 12.3.3
69
95
  - !ruby/object:Gem::Dependency
70
96
  name: rspec
71
97
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +120,7 @@ dependencies:
94
120
  - - '='
95
121
  - !ruby/object:Gem::Version
96
122
  version: '0.55'
97
- description:
123
+ description:
98
124
  email:
99
125
  - chef@broadridge.com
100
126
  executables:
@@ -102,6 +128,7 @@ executables:
102
128
  extensions: []
103
129
  extra_rdoc_files: []
104
130
  files:
131
+ - ".github/workflows/ruby.yml"
105
132
  - ".gitignore"
106
133
  - ".gitlab-ci.yml"
107
134
  - ".rubocop.yml"
@@ -131,7 +158,7 @@ licenses:
131
158
  - MIT
132
159
  metadata:
133
160
  allowed_push_host: https://rubygems.org
134
- post_install_message:
161
+ post_install_message:
135
162
  rdoc_options: []
136
163
  require_paths:
137
164
  - lib
@@ -146,9 +173,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
173
  - !ruby/object:Gem::Version
147
174
  version: '0'
148
175
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.7.8
151
- signing_key:
176
+ rubygems_version: 3.2.22
177
+ signing_key:
152
178
  specification_version: 4
153
179
  summary: Utility to synchronize Chef Supermarkets
154
180
  test_files: []