pdksync 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +84 -0
- data/.rubocop_todo.yml +0 -0
- data/.travis.yml +25 -0
- data/CHANGELOG.md +33 -0
- data/Gemfile +8 -0
- data/LICENSE +202 -0
- data/README.md +155 -0
- data/Rakefile +41 -0
- data/lib/pdksync.rb +322 -0
- data/lib/pdksync/constants.rb +12 -0
- data/managed_modules.yml +30 -0
- data/pdksync.gemspec +29 -0
- data/spec/lib/pdksync_spec.rb +68 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5260a9b4d496039fb943d35a3505fd6491b67981
|
4
|
+
data.tar.gz: ae071b8c16b894de1afe41b9a972132fdee4471f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 429b87f768527fedfb9c9d72712995c61364c159c35a67f6639c7be1db497a8feebb79a87c7b2b8ffc3a5b8d1cc9eb3e91ddffb9358a6836fbb703d32b7315fb
|
7
|
+
data.tar.gz: c5c52a3fe2e4389cebcbc5ff314991cf47cbf003962d0b41451cb834039156ba1aae54520a843a22cf954c71c10748c1b966fccbbb843aad72d5bc5974ef508a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
DisplayCopNames: true
|
4
|
+
TargetRubyVersion: '2.1'
|
5
|
+
Include:
|
6
|
+
- "./**/*.rb"
|
7
|
+
Exclude:
|
8
|
+
- bin/*
|
9
|
+
- ".vendor/**/*"
|
10
|
+
- Gemfile
|
11
|
+
- Rakefile
|
12
|
+
- pkg/**/*
|
13
|
+
- spec/fixtures/**/*
|
14
|
+
- vendor/**/*
|
15
|
+
- modules_pdksync/**/*
|
16
|
+
Metrics/LineLength:
|
17
|
+
Description: People have wide screens, use them.
|
18
|
+
Max: 200
|
19
|
+
Style/BlockDelimiters:
|
20
|
+
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
|
21
|
+
be consistent then.
|
22
|
+
EnforcedStyle: braces_for_chaining
|
23
|
+
Style/ClassAndModuleChildren:
|
24
|
+
Description: Compact style reduces the required amount of indentation.
|
25
|
+
EnforcedStyle: compact
|
26
|
+
Style/EmptyElse:
|
27
|
+
Description: Enforce against empty else clauses, but allow `nil` for clarity.
|
28
|
+
EnforcedStyle: empty
|
29
|
+
Style/FormatString:
|
30
|
+
Description: Following the main puppet project's style, prefer the % format format.
|
31
|
+
EnforcedStyle: percent
|
32
|
+
Style/FormatStringToken:
|
33
|
+
Description: Following the main puppet project's style, prefer the simpler template
|
34
|
+
tokens over annotated ones.
|
35
|
+
EnforcedStyle: template
|
36
|
+
Style/Lambda:
|
37
|
+
Description: Prefer the keyword for easier discoverability.
|
38
|
+
EnforcedStyle: literal
|
39
|
+
Style/RegexpLiteral:
|
40
|
+
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
|
41
|
+
EnforcedStyle: percent_r
|
42
|
+
Style/TernaryParentheses:
|
43
|
+
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
|
44
|
+
on complex expressions for better readability, but seriously consider breaking
|
45
|
+
it up.
|
46
|
+
EnforcedStyle: require_parentheses_when_complex
|
47
|
+
Style/TrailingCommaInArguments:
|
48
|
+
Description: Prefer always trailing comma on multiline argument lists. This makes
|
49
|
+
diffs, and re-ordering nicer.
|
50
|
+
EnforcedStyleForMultiline: comma
|
51
|
+
Style/SymbolArray:
|
52
|
+
Description: Using percent style obscures symbolic intent of array's contents.
|
53
|
+
EnforcedStyle: brackets
|
54
|
+
inherit_from: ".rubocop_todo.yml"
|
55
|
+
Style/CollectionMethods:
|
56
|
+
Enabled: true
|
57
|
+
Style/MethodCalledOnDoEndBlock:
|
58
|
+
Enabled: true
|
59
|
+
Style/StringMethods:
|
60
|
+
Enabled: true
|
61
|
+
Layout/EndOfLine:
|
62
|
+
Enabled: false
|
63
|
+
Metrics/AbcSize:
|
64
|
+
Enabled: false
|
65
|
+
Metrics/BlockLength:
|
66
|
+
Enabled: false
|
67
|
+
Metrics/ClassLength:
|
68
|
+
Enabled: false
|
69
|
+
Metrics/CyclomaticComplexity:
|
70
|
+
Enabled: false
|
71
|
+
Metrics/MethodLength:
|
72
|
+
Enabled: false
|
73
|
+
Metrics/ModuleLength:
|
74
|
+
Enabled: false
|
75
|
+
Metrics/ParameterLists:
|
76
|
+
Enabled: false
|
77
|
+
Metrics/PerceivedComplexity:
|
78
|
+
Enabled: false
|
79
|
+
Style/AsciiComments:
|
80
|
+
Enabled: false
|
81
|
+
Style/IfUnlessModifier:
|
82
|
+
Enabled: false
|
83
|
+
Style/SymbolProc:
|
84
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
File without changes
|
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
dist: trusty
|
4
|
+
language: ruby
|
5
|
+
cache: bundler
|
6
|
+
before_install:
|
7
|
+
- bundle -v
|
8
|
+
- rm -f Gemfile.lock
|
9
|
+
- gem update --system
|
10
|
+
- gem --version
|
11
|
+
- bundle -v
|
12
|
+
script:
|
13
|
+
- 'bundle exec $CHECK'
|
14
|
+
rvm:
|
15
|
+
- 2.4.1
|
16
|
+
matrix:
|
17
|
+
fast_finish: true
|
18
|
+
include:
|
19
|
+
- env: CHECK='rubocop'
|
20
|
+
- env: CHECK='rspec spec'
|
21
|
+
branches:
|
22
|
+
only:
|
23
|
+
- master
|
24
|
+
- /^v\d/
|
25
|
+
- release
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Change log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
|
4
|
+
|
5
|
+
## [0.1.0](https://github.com/puppetlabs/pdksync/tree/0.1.0) (2018-05-23)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/puppetlabs/pdksync/compare/73bf282b297781bc26562bfb51b91b4f7b1632d1...0.1.0)
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Add function to automatically fix validation issues [\#36](https://github.com/puppetlabs/pdksync/pull/36) ([HelenCampbell](https://github.com/HelenCampbell))
|
12
|
+
- \(MODULES-7158\) Add in a delete branch method for cleanup purposes [\#33](https://github.com/puppetlabs/pdksync/pull/33) ([david22swan](https://github.com/david22swan))
|
13
|
+
- \(MODULES-7021\) - Write README for pdksync [\#28](https://github.com/puppetlabs/pdksync/pull/28) ([david22swan](https://github.com/david22swan))
|
14
|
+
- \(MODULES-7121\) Addition of error handling inside functions [\#27](https://github.com/puppetlabs/pdksync/pull/27) ([HelenCampbell](https://github.com/HelenCampbell))
|
15
|
+
- \(MODULES-7085\) Notation added through the module [\#26](https://github.com/puppetlabs/pdksync/pull/26) ([david22swan](https://github.com/david22swan))
|
16
|
+
- \(MODULES-7005\) - Add a test for adding files and update test titles [\#25](https://github.com/puppetlabs/pdksync/pull/25) ([pmcmaw](https://github.com/pmcmaw))
|
17
|
+
- \(MODULES-7092\) - Read in managed\_modules.yml list [\#23](https://github.com/puppetlabs/pdksync/pull/23) ([david22swan](https://github.com/david22swan))
|
18
|
+
- \(MODULES-7007\) Added basic iteration to the module. [\#22](https://github.com/puppetlabs/pdksync/pull/22) ([david22swan](https://github.com/david22swan))
|
19
|
+
- \(MODULES-7049\) - Introduce pdk version and template url [\#21](https://github.com/puppetlabs/pdksync/pull/21) ([pmcmaw](https://github.com/pmcmaw))
|
20
|
+
- \(MODULES-7030\) - Introduce constants.rb [\#20](https://github.com/puppetlabs/pdksync/pull/20) ([david22swan](https://github.com/david22swan))
|
21
|
+
- Addition of PR creation [\#10](https://github.com/puppetlabs/pdksync/pull/10) ([HelenCampbell](https://github.com/HelenCampbell))
|
22
|
+
- Basic Functionality Added [\#5](https://github.com/puppetlabs/pdksync/pull/5) ([david22swan](https://github.com/david22swan))
|
23
|
+
- Setup of Files [\#1](https://github.com/puppetlabs/pdksync/pull/1) ([david22swan](https://github.com/david22swan))
|
24
|
+
|
25
|
+
### Fixed
|
26
|
+
|
27
|
+
- Update travis and change ssh to https for git clone [\#51](https://github.com/puppetlabs/pdksync/pull/51) ([HelenCampbell](https://github.com/HelenCampbell))
|
28
|
+
- Change push command to use git ruby [\#13](https://github.com/puppetlabs/pdksync/pull/13) ([HelenCampbell](https://github.com/HelenCampbell))
|
29
|
+
- PDK Update fix [\#8](https://github.com/puppetlabs/pdksync/pull/8) ([david22swan](https://github.com/david22swan))
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in pdksync.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'github_changelog_generator', git: 'https://github.com/skywinder/github-changelog-generator', ref: 'master'
|
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
# Pdksync
|
2
|
+
|
3
|
+
Table of Contents
|
4
|
+
-----------------
|
5
|
+
|
6
|
+
1. [Overview](#overview)
|
7
|
+
2. [Usage](#usage)
|
8
|
+
3. [How it works](#how-it-works)
|
9
|
+
4. [Installing](#installing)
|
10
|
+
5. [Workflow](#workflow)
|
11
|
+
6. [Migrating from modulesync to pdksync](#migrating-from-modulesync-to-pdksync)
|
12
|
+
7. [Contributing](#contributing)
|
13
|
+
|
14
|
+
### Overview
|
15
|
+
--------
|
16
|
+
|
17
|
+
Pdksync is an efficient way to run a `pdk update` command against the various repositories that we manage — keeping them up-to-date with the changes made to PDK. It is a solution for converted modules that no longer run with modulesync.
|
18
|
+
|
19
|
+
### Usage
|
20
|
+
----------
|
21
|
+
|
22
|
+
> Note: This tool creates a 'live' pull request against the master branch of the module it is running against — defined in `managed_modules.yml`. Before running this tool, ensure this file reflects the modules you wish it to run against, and that `constants.rb` is up-to-date with the correct namespace your modules reside in.
|
23
|
+
|
24
|
+
1. To use pdksync, clone the GitHub repo or install it as a gem. Set up the environment by exporting a GitHub token:
|
25
|
+
```
|
26
|
+
export GITHUB_TOKEN=<access_token>
|
27
|
+
```
|
28
|
+
2. Before the script will run, you need to install the gems:
|
29
|
+
```
|
30
|
+
bundle install --path .bundle/gems/
|
31
|
+
```
|
32
|
+
3. Once this is complete, call the built-in rake task to run the module:
|
33
|
+
```
|
34
|
+
bundle exec rake pdksync
|
35
|
+
```
|
36
|
+
|
37
|
+
### How it works
|
38
|
+
------------
|
39
|
+
|
40
|
+
Pdksync is a gem that works to clone, update, and push module repositories. It is activated from within the pdksync module.
|
41
|
+
|
42
|
+
The gem takes in a file, `managed_modules.yml`, stored within the gem that lists all the repositories that need to be updated. It then clones them, one after another, so that a local copy exists. The update command is ran against this local copy, with the subsequent changes being added into a commit on a unique branch. It is then pushed back to the remote master — where the local copy was originally cloned. The commit is merged to the master via a pull request, causing the gem to begin to clone the next repository.
|
43
|
+
|
44
|
+
### Workflow
|
45
|
+
--------
|
46
|
+
|
47
|
+
It currently runs without additional arguments. To alter how it runs, make alterations to either the `constants.rb` or `managed_modules.yml`.
|
48
|
+
|
49
|
+
### Managed modules
|
50
|
+
----------
|
51
|
+
|
52
|
+
This module runs through a pre-set array of modules, with this array set within the `managed_modules.yml` file. This file makes use of a simple `yaml` style format to set out the different module names, for example:
|
53
|
+
|
54
|
+
```
|
55
|
+
---
|
56
|
+
- puppetlabs-motd
|
57
|
+
- puppetlabs-stdlib
|
58
|
+
- puppetlabs-mysql
|
59
|
+
```
|
60
|
+
To add a module, add it to the list. To remove a module, remove it from the list.
|
61
|
+
|
62
|
+
### Migrating from modulesync to pdksync
|
63
|
+
--------
|
64
|
+
|
65
|
+
If your modules are currently managed by modulesync, and you want to use PDK and keep your modules up-to-date, read the following.
|
66
|
+
|
67
|
+
#### Terminology
|
68
|
+
- `pdk convert` - A command to convert your module, for example, to make it compatible with the PDK.
|
69
|
+
- `convert_report.txt` - A report that shows the changes PDK will make to your module when `pdk convert` is ran.
|
70
|
+
- `pdk update` - A command to consume any changes that have been made to the pdk-template used to convert the module.
|
71
|
+
- `update_report.txt` - A report that shows the changes PDK will make to your module when `pdk update` is ran.
|
72
|
+
- `pdk validate` - A command to run basic validation checks on your module.
|
73
|
+
- `pdk test unit` - A command to run all available unit tests on your module.
|
74
|
+
- `.sync.yml` - A file that lists all of of your module customizations — and will require work before module conversion.
|
75
|
+
|
76
|
+
##### Prerequisites
|
77
|
+
* Unit tests are in a good state — with no failures. Check by running `pdk test unit`.
|
78
|
+
* The module is in good shape. Check by running `pdk validate`.
|
79
|
+
|
80
|
+
When you're confident everything is in good shape, you can start converting your module to make it compatible with PDK.
|
81
|
+
|
82
|
+
##### Getting started
|
83
|
+
|
84
|
+
1) Run `pdk convert --noop`. This will output to the console a high level overview of the changes that PDK is planning to make to your files.
|
85
|
+
|
86
|
+
> Note: For an in-depth diff, see the convert_report.txt that is output in the module root directory.
|
87
|
+
|
88
|
+
2) Make changes to your .sync.yml. State any configuration that the custom [pdk-templates](https://github.com/puppetlabs/pdk-templates) plan to remove.
|
89
|
+
|
90
|
+
Useful commands via the .sync.yml:
|
91
|
+
|
92
|
+
- Add additional gem dependencies:
|
93
|
+
```
|
94
|
+
Gemfile:
|
95
|
+
required:
|
96
|
+
':system_tests':
|
97
|
+
- gem 'octokit'
|
98
|
+
platforms: ruby
|
99
|
+
```
|
100
|
+
- Make changes to your travis configuration:
|
101
|
+
```
|
102
|
+
.travis.yml:
|
103
|
+
branches:
|
104
|
+
- release
|
105
|
+
```
|
106
|
+
- Delete files that you don't want to exist in the repo:
|
107
|
+
```
|
108
|
+
.gitlab-ci.yml:
|
109
|
+
delete: true
|
110
|
+
```
|
111
|
+
- Unmanage files that you don't want to be managed:
|
112
|
+
```
|
113
|
+
.gitlab-ci.yml:
|
114
|
+
unmanaged: true
|
115
|
+
```
|
116
|
+
> Note: It is unlikely your module will work out of the box.
|
117
|
+
|
118
|
+
3) When you are finished customizing your .sync.yml file, run `pdk convert --noop` and confirm the changes that PDK will make when you convert. Changes can be found in the `convert_report.txt`
|
119
|
+
|
120
|
+
4) Run `pdk convert` to convert. You will be prompted to pass in Y/N — type Y and all your changes will be applied.
|
121
|
+
|
122
|
+
> Note: If you have any concerns it is not too late — type N.
|
123
|
+
|
124
|
+
5) Run your unit tests to confirm that nothing has broken. If there are breakages, you might need to require a library or include a missing gem — address this issue before you continue.
|
125
|
+
|
126
|
+
6) Run `pdk validate` to ensure there are no failures.
|
127
|
+
|
128
|
+
7) Commit the changes that the `pdk convert` has made and create your pull request.
|
129
|
+
|
130
|
+
8) Remove your module from being managed via `modulesync`, and start using `pdksync` going forward — no more manually creating pull requests.
|
131
|
+
|
132
|
+
For more information on keeping your module up to date with the PDK check out [Helens blog post](https://puppet.com/blog/guide-converting-module-pdk).
|
133
|
+
|
134
|
+
### Compatibility
|
135
|
+
----------
|
136
|
+
|
137
|
+
This tool has been developed and tested on OSX and Linux. **It currently does not run on Windows.**
|
138
|
+
|
139
|
+
### Contributing
|
140
|
+
--------
|
141
|
+
|
142
|
+
1. Fork the repo
|
143
|
+
2. Create your feature branch:
|
144
|
+
```
|
145
|
+
git checkout -b my-new-feature
|
146
|
+
```
|
147
|
+
3. Commit your changes:
|
148
|
+
```
|
149
|
+
git commit -am 'Add some feature'
|
150
|
+
```
|
151
|
+
4. Push to the branch:
|
152
|
+
```
|
153
|
+
git push origin my-new-feature
|
154
|
+
```
|
155
|
+
5. Create a new pull request
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'lib/pdksync'
|
2
|
+
require 'github_changelog_generator/task'
|
3
|
+
|
4
|
+
|
5
|
+
desc 'Run pdk update'
|
6
|
+
task :pdksync do
|
7
|
+
PdkSync::run_pdksync
|
8
|
+
puts "The script has run."
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Run pdksync cleanup'
|
12
|
+
task :pdksync_cleanup do
|
13
|
+
PdkSync::clean_branches
|
14
|
+
puts "The script has run."
|
15
|
+
end
|
16
|
+
|
17
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
18
|
+
config.user = 'puppetlabs'
|
19
|
+
config.project = 'pdksync'
|
20
|
+
# config.since_tag = '1.1.1'
|
21
|
+
config.future_release = '0.1.0'
|
22
|
+
config.exclude_labels = ['maintenance']
|
23
|
+
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
|
24
|
+
config.add_pr_wo_labels = true
|
25
|
+
config.issues = false
|
26
|
+
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
|
27
|
+
config.configure_sections = {
|
28
|
+
"Changed" => {
|
29
|
+
"prefix" => "### Changed",
|
30
|
+
"labels" => ["backwards-incompatible"],
|
31
|
+
},
|
32
|
+
"Added" => {
|
33
|
+
"prefix" => "### Added",
|
34
|
+
"labels" => ["feature", "enhancement"],
|
35
|
+
},
|
36
|
+
"Fixed" => {
|
37
|
+
"prefix" => "### Fixed",
|
38
|
+
"labels" => ["bugfix"],
|
39
|
+
},
|
40
|
+
}
|
41
|
+
end
|
data/lib/pdksync.rb
ADDED
@@ -0,0 +1,322 @@
|
|
1
|
+
# !/usr/bin/env ruby
|
2
|
+
require 'git'
|
3
|
+
require 'open3'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rake'
|
6
|
+
require 'pdk'
|
7
|
+
require 'octokit'
|
8
|
+
require 'pdksync/constants'
|
9
|
+
require 'json'
|
10
|
+
require 'yaml'
|
11
|
+
|
12
|
+
# @summary
|
13
|
+
# This module set's out and controls the pdksync process
|
14
|
+
# @param [String] @access_token
|
15
|
+
# The token used to access github, must be exported locally.
|
16
|
+
# @param [String] @namspace
|
17
|
+
# The namespace of the repositories we are updating.
|
18
|
+
# @param [String] @pdksync_dir
|
19
|
+
# The local directory the repositories are to be copied to.
|
20
|
+
# @param [String] @push_file_destination
|
21
|
+
# The remote that the pull requests are to be made against.
|
22
|
+
# @param [String] @create_pr_against
|
23
|
+
# The branch the the pull requests are to be made against.
|
24
|
+
# @param [String] @managed_modules
|
25
|
+
# The file that the array of managed modules is to be retrieved from.
|
26
|
+
module PdkSync
|
27
|
+
include Constants
|
28
|
+
@access_token = Constants::ACCESS_TOKEN
|
29
|
+
@namespace = Constants::NAMESPACE
|
30
|
+
@pdksync_dir = Constants::PDKSYNC_DIR
|
31
|
+
@push_file_destination = Constants::PUSH_FILE_DESTINATION
|
32
|
+
@create_pr_against = Constants::CREATE_PR_AGAINST
|
33
|
+
@managed_modules = Constants::MANAGED_MODULES
|
34
|
+
|
35
|
+
# @summary
|
36
|
+
# When a new instance of this module is called, this method will be run in order to start the pdksync process.
|
37
|
+
def self.run_pdksync
|
38
|
+
puts 'Beginning pdksync run'
|
39
|
+
create_filespace
|
40
|
+
@client = setup_client
|
41
|
+
@module_names = return_modules
|
42
|
+
# The current directory is saved for cleanup purposes
|
43
|
+
@main_path = Dir.pwd
|
44
|
+
|
45
|
+
# Run an iterative loop for each @module_name
|
46
|
+
@module_names.each do |module_name|
|
47
|
+
puts '*************************************'
|
48
|
+
puts "Syncing #{module_name}"
|
49
|
+
sync(module_name, @client)
|
50
|
+
# Cleanup used to ensure that the current directory is reset after each run.
|
51
|
+
Dir.chdir(@main_path) unless Dir.pwd == @main_path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# @summary
|
56
|
+
# This method when called will create a directory identified by the set global variable '@pdksync_dir', on the condition that it does not already exist.
|
57
|
+
def self.create_filespace
|
58
|
+
FileUtils.mkdir @pdksync_dir unless Dir.exist?(@pdksync_dir)
|
59
|
+
end
|
60
|
+
|
61
|
+
# @summary
|
62
|
+
# This method when called will create and return an octokit client with access to the upstream git repositories.
|
63
|
+
# @return [Octokit::Client] client
|
64
|
+
# The octokit client that has been created.
|
65
|
+
def self.setup_client
|
66
|
+
client = Octokit::Client.new(access_token: @access_token.to_s)
|
67
|
+
client.user.login
|
68
|
+
puts 'Client login has been successful.'
|
69
|
+
client
|
70
|
+
rescue ArgumentError
|
71
|
+
raise "Access Token not set up correctly - Use export 'GITHUB_TOKEN=<put your token here>' to set it."
|
72
|
+
end
|
73
|
+
|
74
|
+
# @summary
|
75
|
+
# This method when called will access a file set by the global variable '@managed_modules' and retrieve the information within as an array.
|
76
|
+
# @return [Array]
|
77
|
+
# An array of different module names.
|
78
|
+
def self.return_modules
|
79
|
+
YAML.safe_load(File.open(@managed_modules))
|
80
|
+
end
|
81
|
+
|
82
|
+
# @summary
|
83
|
+
# This method when called will take in a module name and an octokit client and use them to run the pdksync process on the given module.
|
84
|
+
# If @git_repo is not set the clone will have failed, in which case we avoid further action. If the pdk update fails it will move to the
|
85
|
+
# next module.
|
86
|
+
# @param [String] module_name
|
87
|
+
# The name of the module to be put through the process
|
88
|
+
# @param [Octokit::Client] client
|
89
|
+
# The client used to access github.
|
90
|
+
def self.sync(module_name, client)
|
91
|
+
@repo_name = "#{@namespace}/#{module_name}"
|
92
|
+
@output_path = "#{@pdksync_dir}/#{module_name}"
|
93
|
+
clean_env(@output_path) if Dir.exist?(@output_path)
|
94
|
+
@git_repo = clone_directory(@namespace, module_name, @output_path)
|
95
|
+
|
96
|
+
return if @git_repo.nil?
|
97
|
+
return unless pdk_update(@output_path) == 0 # rubocop:disable Style/NumericPredicate
|
98
|
+
|
99
|
+
@template_ref = return_template_ref
|
100
|
+
checkout_branch(@git_repo, @template_ref)
|
101
|
+
@pdk_version = return_pdk_version
|
102
|
+
add_staged_files(@git_repo)
|
103
|
+
commit_staged_files(@git_repo, @template_ref)
|
104
|
+
push_staged_files(@git_repo, @template_ref, @repo_name)
|
105
|
+
create_pr(client, @repo_name, @template_ref, @pdk_version)
|
106
|
+
end
|
107
|
+
|
108
|
+
# @summary
|
109
|
+
# This method when called will call the delete function against the given repository if it exists.
|
110
|
+
# @param [String] output_path
|
111
|
+
# The repository that is to be deleted.
|
112
|
+
def self.clean_env(output_path)
|
113
|
+
puts 'Cleaning your environment.'
|
114
|
+
# If a local copy already exists it is removed
|
115
|
+
FileUtils.rm_rf(output_path)
|
116
|
+
end
|
117
|
+
|
118
|
+
# @summary
|
119
|
+
# This method when called will clone a given repository into a local location that has also been set.
|
120
|
+
# @param [String] namespace
|
121
|
+
# The namespace the repository is located in.
|
122
|
+
# @param [String] module_name
|
123
|
+
# The name of the repository.
|
124
|
+
# @param [String] output_path
|
125
|
+
# The location the repository is to be cloned to.
|
126
|
+
# @return [Git::Base]
|
127
|
+
# A git object representing the local repository.
|
128
|
+
def self.clone_directory(namespace, module_name, output_path)
|
129
|
+
puts "Cloning #{module_name} to #{output_path}."
|
130
|
+
Git.clone("https://github.com/#{namespace}/#{module_name}.git", output_path.to_s) # is returned
|
131
|
+
rescue Git::GitExecuteError
|
132
|
+
puts "(FAILURE) Cloning #{module_name} has failed - check the module name and namespace are correct."
|
133
|
+
end
|
134
|
+
|
135
|
+
# @summary
|
136
|
+
# This method when called will run the 'pdk convert' command at the given location, with an error message being thrown if it is not successful.
|
137
|
+
# @param [String] output_path
|
138
|
+
# The location that the command is to be run from.
|
139
|
+
# @return [Integer]
|
140
|
+
# The status code of the pdk converty run.
|
141
|
+
def self.pdk_convert(output_path)
|
142
|
+
Dir.chdir(output_path) unless Dir.pwd == output_path
|
143
|
+
_stdout, stderr, status = Open3.capture3('pdk convert --force --template-url https://github.com/puppetlabs/pdk-templates')
|
144
|
+
if status != 0
|
145
|
+
puts "(FAILURE) Unable to run `pdk convert`: #{stderr}"
|
146
|
+
else
|
147
|
+
puts 'PDK convert has run.'
|
148
|
+
end
|
149
|
+
status
|
150
|
+
end
|
151
|
+
|
152
|
+
# @summary
|
153
|
+
# This method when called will run the 'pdk update --force' command at the given location, with an error message being thrown if it is not successful.
|
154
|
+
# @param [String] output_path
|
155
|
+
# The location that the command is to be run from.
|
156
|
+
# @return [Integer]
|
157
|
+
# The status code of the pdk update run.
|
158
|
+
def self.pdk_update(output_path)
|
159
|
+
# Runs the pdk update command
|
160
|
+
Dir.chdir(output_path) unless Dir.pwd == output_path
|
161
|
+
stdout, stderr, status = Open3.capture3('pdk update --force')
|
162
|
+
if status != 0
|
163
|
+
puts "(FAILURE) Unable to run `pdk update`: #{stderr}"
|
164
|
+
else
|
165
|
+
puts 'PDK update has run.'
|
166
|
+
end
|
167
|
+
return status unless status == 0 && stdout.include?('No changes required.') # rubocop:disable Style/NumericPredicate
|
168
|
+
puts 'No commits since last run.'
|
169
|
+
end
|
170
|
+
|
171
|
+
# @summary
|
172
|
+
# This method when called will run the 'pdk validate -a' command at the given location, with an error message being thrown if it is not successful.
|
173
|
+
# @param [String] output_path
|
174
|
+
# The location that the command is to be run from.
|
175
|
+
# @return [Integer]
|
176
|
+
# The status code of the pdk validate run.
|
177
|
+
def self.validate_autofix
|
178
|
+
# Runs the pdk validate command
|
179
|
+
_stdout, stderr, status = Open3.capture3('pdk validate -a')
|
180
|
+
if status != 0
|
181
|
+
puts "(FAILURE) Something went wrong with the validate: #{stderr}"
|
182
|
+
else
|
183
|
+
puts 'Validate has run successfully.'
|
184
|
+
end
|
185
|
+
status
|
186
|
+
end
|
187
|
+
|
188
|
+
# @summary
|
189
|
+
# This method when called will retrieve the template ref of the current module, i.e. the one that was navigated into in the 'pdk_update' method.
|
190
|
+
# @param [String] metadata_file
|
191
|
+
# An optional input that can be used to set the location of the metadata file.
|
192
|
+
# @return [String]
|
193
|
+
# A string value that represents the current pdk template.
|
194
|
+
def self.return_template_ref(metadata_file = 'metadata.json')
|
195
|
+
file = File.read(metadata_file)
|
196
|
+
data_hash = JSON.parse(file)
|
197
|
+
data_hash['template-ref']
|
198
|
+
end
|
199
|
+
|
200
|
+
# @summary
|
201
|
+
# This method when called will checkout a new local branch of the given repository.
|
202
|
+
# @param [Git::Base] git_repo
|
203
|
+
# A git object representing the local repository to be branched.
|
204
|
+
# @param [String] template_ref
|
205
|
+
# The unique template_ref that is used as part of the branch name.
|
206
|
+
def self.checkout_branch(git_repo, template_ref)
|
207
|
+
puts "Creating the following branch: pdksync_#{template_ref}."
|
208
|
+
git_repo.branch("pdksync_#{template_ref}".to_s).checkout
|
209
|
+
end
|
210
|
+
|
211
|
+
# @summary
|
212
|
+
# This method when called will retrieve the pdk_version of the current module, i.e. the one that was navigated into in the 'pdk_update' method.
|
213
|
+
# @param [String] metadata_file
|
214
|
+
# An optional input that can be used to set the location of the metadata file.
|
215
|
+
# @return [String]
|
216
|
+
# A string value that represents the current pdk version.
|
217
|
+
def self.return_pdk_version(metadata_file = 'metadata.json')
|
218
|
+
file = File.read(metadata_file)
|
219
|
+
data_hash = JSON.parse(file)
|
220
|
+
data_hash['pdk-version']
|
221
|
+
end
|
222
|
+
|
223
|
+
# @summary
|
224
|
+
# This method when called will stage all changed files within the given repository, conditional on them being managed via the pdk.
|
225
|
+
# @param [Git::Base] git_repo
|
226
|
+
# A git object representing the local repository to be staged.
|
227
|
+
def self.add_staged_files(git_repo)
|
228
|
+
git_repo.add(all: true)
|
229
|
+
puts 'All files have been staged.'
|
230
|
+
end
|
231
|
+
|
232
|
+
# @summary
|
233
|
+
# This method when called will create a commit containing all currently staged files, with the name of the commit containing the template ref as a unique identifier.
|
234
|
+
# @param [Git::Base] git_repo
|
235
|
+
# A git object representing the local repository against which the commit is to be made.
|
236
|
+
# @param [String] template_ref
|
237
|
+
# The unique template_ref that is used as part of the commit name.
|
238
|
+
def self.commit_staged_files(git_repo, template_ref)
|
239
|
+
git_repo.commit("pdksync_#{template_ref}")
|
240
|
+
puts "Creating the following commit: pdksync_#{template_ref}."
|
241
|
+
end
|
242
|
+
|
243
|
+
# @summary
|
244
|
+
# This method when called will push the given local commit to local repository's origin.
|
245
|
+
# @param [Git::Base] git_repo
|
246
|
+
# A git object representing the local repository againt which the push is to be made.
|
247
|
+
# @param [String] template_ref
|
248
|
+
# The unique reference that that represents the template the update has ran against.
|
249
|
+
# @param [String] repo_name
|
250
|
+
# The name of the repository on which the commit is to be made.
|
251
|
+
def self.push_staged_files(git_repo, template_ref, repo_name)
|
252
|
+
git_repo.push(@push_file_destination, "pdksync_#{template_ref}")
|
253
|
+
puts 'All staged files have been pushed to the repo, bon voyage!'
|
254
|
+
rescue StandardError
|
255
|
+
puts "(FAILURE) Pushing to #{@push_file_destination} for #{repo_name} has failed."
|
256
|
+
end
|
257
|
+
|
258
|
+
# @summary
|
259
|
+
# This method when called will create a pr on the given repository that will create a pr to merge the given commit into the master with the pdk version as an identifier.
|
260
|
+
# @param [Octokit::Client] client
|
261
|
+
# The octokit client used to gain access to and manipulate the repository.
|
262
|
+
# @param [String] repo_name
|
263
|
+
# The name of the repository on which the commit is to be made.
|
264
|
+
# @param [String] template_ref
|
265
|
+
# The unique reference that that represents the template the update has ran against.
|
266
|
+
# @param [String] pdk_version
|
267
|
+
# The current version of the pdk on which the update is run.
|
268
|
+
def self.create_pr(client, repo_name, template_ref, pdk_version)
|
269
|
+
pr = client.create_pull_request(repo_name, @create_pr_against,
|
270
|
+
"pdksync_#{template_ref}".to_s,
|
271
|
+
"pdksync - Update using #{pdk_version}",
|
272
|
+
"pdk version: `#{pdk_version}` \n pdk template ref: `#{template_ref}`")
|
273
|
+
puts 'The PR has been created.'
|
274
|
+
pr
|
275
|
+
rescue StandardError
|
276
|
+
puts "(FAILURE) PR creation for #{repo_name} has failed."
|
277
|
+
end
|
278
|
+
|
279
|
+
# @summary
|
280
|
+
# This method when called will retrieve a list of module names and then proceed to iterate
|
281
|
+
# through them, removing any branch that contains the word 'pdksync'.
|
282
|
+
def self.clean_branches
|
283
|
+
puts 'Beginning pdksync cleanup run'
|
284
|
+
@client = setup_client
|
285
|
+
@module_names = return_modules
|
286
|
+
|
287
|
+
@module_names.each do |module_name|
|
288
|
+
puts '*************************************'
|
289
|
+
puts "Cleaning #{module_name}"
|
290
|
+
@repo_name = "#{@namespace}/#{module_name}"
|
291
|
+
retrieve_branches(@client, @repo_name).each do |branch|
|
292
|
+
delete_branch(@client, @repo_name, branch.name) if branch.name.include? 'pdksync'
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# @summary
|
298
|
+
# This method when called will retrieve any and all branches from the given repository.
|
299
|
+
# @param [Octokit::Client] client
|
300
|
+
# The octokit client used to gain access to and manipulate the repository.
|
301
|
+
# @param [String] repo_name
|
302
|
+
# The name of the repository from which the branches are to be retrieved.
|
303
|
+
# @return [Array]
|
304
|
+
# An array containing all existing branches
|
305
|
+
def self.retrieve_branches(client, repo_name)
|
306
|
+
puts "Retrieving branches from #{repo_name}"
|
307
|
+
client.branches(repo_name)
|
308
|
+
end
|
309
|
+
|
310
|
+
# @summary
|
311
|
+
# This method when called will delete any preexisting branch on the given repository that matches the given name.
|
312
|
+
# @param [Octokit::Client] client
|
313
|
+
# The octokit client used to gain access to and manipulate the repository.
|
314
|
+
# @param [String] repo_name
|
315
|
+
# The name of the repository from which the branch is to be deleted.
|
316
|
+
# @param [String] branch_name
|
317
|
+
# The name of the branch that is to be deleted.
|
318
|
+
def self.delete_branch(client, repo_name, branch_name)
|
319
|
+
puts "Removing '#{branch_name}' from '#{repo_name}'"
|
320
|
+
client.delete_branch(repo_name, branch_name)
|
321
|
+
end
|
322
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# @summary
|
2
|
+
# A module used to contain a set of variables that are expected to remain constant across all iterations of the main pdksync module.
|
3
|
+
module PdkSync # rubocop:disable Style/ClassAndModuleChildren
|
4
|
+
module Constants
|
5
|
+
ACCESS_TOKEN = ENV['GITHUB_TOKEN'].freeze
|
6
|
+
NAMESPACE = 'puppetlabs'.freeze
|
7
|
+
PDKSYNC_DIR = 'modules_pdksync'.freeze
|
8
|
+
PUSH_FILE_DESTINATION = 'origin'.freeze
|
9
|
+
CREATE_PR_AGAINST = 'master'.freeze
|
10
|
+
MANAGED_MODULES = 'managed_modules.yml'.freeze
|
11
|
+
end
|
12
|
+
end
|
data/managed_modules.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
- puppetlabs-accounts
|
3
|
+
- puppetlabs-apache
|
4
|
+
- puppetlabs-apt
|
5
|
+
- puppetlabs-firewall
|
6
|
+
- puppetlabs-haproxy
|
7
|
+
- puppetlabs-ibm_installation_manager
|
8
|
+
- puppetlabs-java
|
9
|
+
- puppetlabs-mysql
|
10
|
+
- puppetlabs-ntp
|
11
|
+
- puppetlabs-postgresql
|
12
|
+
# - puppetlabs-satellite_pe_tools
|
13
|
+
- puppetlabs-tagmail
|
14
|
+
- puppetlabs-tomcat
|
15
|
+
- puppetlabs-translate
|
16
|
+
# - puppetlabs-vcsrepo
|
17
|
+
- puppetlabs-websphere_application_server
|
18
|
+
- puppetlabs-bootstrap
|
19
|
+
- puppetlabs-concat
|
20
|
+
- puppetlabs-exec
|
21
|
+
- puppetlabs-facter_task
|
22
|
+
- puppetlabs-hocon
|
23
|
+
- puppetlabs-inifile
|
24
|
+
# - puppetlabs-java_ks
|
25
|
+
- puppetlabs-motd
|
26
|
+
- puppetlabs-package
|
27
|
+
- puppetlabs-puppet_conf
|
28
|
+
- puppetlabs-resource
|
29
|
+
- puppetlabs-service
|
30
|
+
- puppetlabs-stdlib
|
data/pdksync.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'pdksync'
|
6
|
+
spec.version = '0.1.0'
|
7
|
+
spec.authors = ['Puppet']
|
8
|
+
spec.email = ['']
|
9
|
+
spec.summary = 'Puppet Module PDK Synchronizer'
|
10
|
+
spec.description = 'Utility to synchronize common files across puppet modules using PDK Update.'
|
11
|
+
spec.homepage = 'http://github.com/puppetlabs/pdksync'
|
12
|
+
spec.license = 'Apache-2.0'
|
13
|
+
spec.required_ruby_version = '>= 2.0.0'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec'
|
23
|
+
spec.add_development_dependency 'rubocop', '~> 0.50.0'
|
24
|
+
spec.add_development_dependency 'octokit'
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'git', '~>1.3'
|
28
|
+
spec.add_runtime_dependency 'pdk', '>= 1.4.1'
|
29
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../../lib/pdksync'
|
2
|
+
require 'git'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'octokit'
|
5
|
+
|
6
|
+
describe PdkSync do
|
7
|
+
before(:all) do
|
8
|
+
@timestamp = Time.now.to_i
|
9
|
+
@namespace = 'puppetlabs'
|
10
|
+
@pdksync_dir = './modules_pdksync'
|
11
|
+
@module_name = 'puppetlabs-testing'
|
12
|
+
@output_path = "#{@pdksync_dir}/#{@module_name}"
|
13
|
+
@access_token = ENV['GITHUB_TOKEN']
|
14
|
+
@repo_name = "#{@namespace}/#{@module_name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'env' do
|
18
|
+
it 'has a filespace' do
|
19
|
+
FileUtils.rm_rf(@pdksync_dir)
|
20
|
+
PdkSync.create_filespace
|
21
|
+
expect(Dir.exist?(@pdksync_dir)).to be(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has cloned the repo' do
|
25
|
+
PdkSync.clone_directory(@namespace, @module_name, @output_path)
|
26
|
+
expect(Dir.exist?(@output_path)).to be(true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'run' do
|
31
|
+
before(:all) do
|
32
|
+
@git_repo = Git.open(@output_path)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'has created a branch' do
|
36
|
+
PdkSync.checkout_branch(@git_repo, @timestamp)
|
37
|
+
expect(@git_repo.current_branch).to include(@timestamp.to_s)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has created a report' do
|
41
|
+
FileUtils.rm_rf('update_report.txt')
|
42
|
+
PdkSync.pdk_update(@output_path)
|
43
|
+
expect(File.exist?('update_report.txt')).to be(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'has staged files' do
|
47
|
+
PdkSync.add_staged_files(@git_repo)
|
48
|
+
result = Open3.capture3('git status')
|
49
|
+
expect(result).to include(%r{Changes to be committed})
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has committed files' do
|
53
|
+
pre_commit = @git_repo.log.last
|
54
|
+
PdkSync.commit_staged_files(@git_repo, @timestamp)
|
55
|
+
post_commit = @git_repo.log.last
|
56
|
+
expect(pre_commit).not_to eq(post_commit)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# # Test fails if ran from travis due to lack of proper credentials
|
60
|
+
# it 'The committed files should be pushed and the PR created', unless: @access_token == '' do
|
61
|
+
# @client = PdkSync.setup_client
|
62
|
+
# PdkSync.push_staged_files(@git_repo, @timestamp, @repo_name)
|
63
|
+
# pr = PdkSync.create_pr(@client, @repo_name, @timestamp, @timstamp)
|
64
|
+
# expect(pr.title).to eq("pdksync - pdksync_#{@timestamp}")
|
65
|
+
# #Branch is now cleaned
|
66
|
+
# PdkSync.delete_branch(@client, @repo_name, "pdksync_#{@timestamp}".to_s)
|
67
|
+
# end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pdksync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Puppet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-23 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.50.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.50.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: octokit
|
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: pry
|
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: git
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.3'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pdk
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.4.1
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.4.1
|
125
|
+
description: Utility to synchronize common files across puppet modules using PDK Update.
|
126
|
+
email:
|
127
|
+
- ''
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rubocop.yml"
|
134
|
+
- ".rubocop_todo.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- lib/pdksync.rb
|
142
|
+
- lib/pdksync/constants.rb
|
143
|
+
- managed_modules.yml
|
144
|
+
- pdksync.gemspec
|
145
|
+
- spec/lib/pdksync_spec.rb
|
146
|
+
homepage: http://github.com/puppetlabs/pdksync
|
147
|
+
licenses:
|
148
|
+
- Apache-2.0
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 2.0.0
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.6.11
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: Puppet Module PDK Synchronizer
|
170
|
+
test_files:
|
171
|
+
- spec/lib/pdksync_spec.rb
|