puppet2conf 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 +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/puppet2conf.rb +92 -0
- data/lib/puppet2conf/version.rb +3 -0
- data/puppet2conf.gemspec +26 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c5f6cd86dea2b3c04deb56bf11b4620be8405dc
|
4
|
+
data.tar.gz: 65dd18418792584785d43eeb3bc2a3f2d8454c90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd08beaf1a6d96c1592d8b8daab833fded599fa210f226e51bdf79e2924c53c1e7d7607e366956a7ebbc069921fc549060f0ed4c8eae13a6bd6f82b21c3910c2
|
7
|
+
data.tar.gz: e276438b4a9acf5ad410d0a00bb973066ce61acfde36d97bb2334db1dea4dc6d1a14784c78c8442431b1207a5633f61c55422977af7629264d8a5c68216b5fc6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at vtyshkevich@iponweb.net. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Vladimir Tyshkevich
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Puppet2conf
|
2
|
+
|
3
|
+
Generate all related to your puppet module documentation in your confluence
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'puppet2conf'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
First, generate a configuration file located at `~/.puppet2conf.yml`:
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
username: confluence-bot
|
23
|
+
password: MySecurePassword
|
24
|
+
url: https://confluence.mycompany.com
|
25
|
+
space: OpsSpace
|
26
|
+
ancestor: PuppetModules
|
27
|
+
```
|
28
|
+
|
29
|
+
then create a Rake task that looks like this:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
desc 'Generate documentation'
|
33
|
+
task :gendoc do
|
34
|
+
require 'puppet2conf'
|
35
|
+
doc_pusher = Puppet2conf::DocPusher.new
|
36
|
+
doc_pusher.gendocs('module_name')
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
If you have lots of modules with the same Rakefile, you could parse out the module name from metadata:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
desc 'Generate documentation'
|
44
|
+
task :gendoc do
|
45
|
+
require 'puppet2conf'
|
46
|
+
require 'json'
|
47
|
+
module_name = JSON.parse(File.read 'metadata.json')['name'].split('-')[1]
|
48
|
+
doc_pusher = Puppet2conf::DocPusher.new
|
49
|
+
doc_pusher.gendocs(module_name)
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/v0v04ka/puppet2conf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
64
|
+
|
65
|
+
## Code of Conduct
|
66
|
+
|
67
|
+
Everyone interacting in the Puppet2conf project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/v0v04ka/puppet2conf/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "puppet2conf"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/puppet2conf.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'puppet2conf/version'
|
2
|
+
require 'strings2conf'
|
3
|
+
require 'md2conf'
|
4
|
+
require 'conf/api/client'
|
5
|
+
require 'puppet-strings'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
module Puppet2conf
|
9
|
+
class DocPusher
|
10
|
+
# Pass the following variables as parameters:
|
11
|
+
# - username
|
12
|
+
# - password
|
13
|
+
# - url
|
14
|
+
# - space
|
15
|
+
# - ancestor
|
16
|
+
#
|
17
|
+
# or provide them in configuration file in YAML format.
|
18
|
+
# Configuration file location can be overridden by `config_file` parameter.
|
19
|
+
def initialize(config_file: '~/.puppet2conf.yaml', username: nil, password: nil, url: nil, space: nil, ancestor: nil)
|
20
|
+
params = {}
|
21
|
+
params['username'] = username if username
|
22
|
+
params['password'] = password if password
|
23
|
+
params['url'] = url if url
|
24
|
+
params['space'] = space if space
|
25
|
+
params['ancestor'] = ancestor if ancestor
|
26
|
+
|
27
|
+
if File.file? File.expand_path(config_file)
|
28
|
+
@config = YAML.load_file(File.expand_path(config_file))
|
29
|
+
end
|
30
|
+
|
31
|
+
@config.merge! params
|
32
|
+
@client = Conf::Api::Client.new(@config['username'], @config['password'], @config['url'])
|
33
|
+
end
|
34
|
+
|
35
|
+
def push_page(page_title, html, ancestor)
|
36
|
+
page = @client.get(spaceKey: @config['space'], title: page_title)[0]
|
37
|
+
if ancestor
|
38
|
+
parent_page = @client.get(spaceKey: @config['space'], title: ancestor)[0]
|
39
|
+
if parent_page
|
40
|
+
ancestors = [{ type: 'page', id: parent_page['id'] }]
|
41
|
+
else
|
42
|
+
warn "Couldn't find parent page #{ancestor}"
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
if page.nil?
|
47
|
+
puts "Page '#{page_title}' doesn't exist, creating it"
|
48
|
+
@client.create(
|
49
|
+
type: 'page',
|
50
|
+
title: page_title,
|
51
|
+
space: { key: @config['space'] },
|
52
|
+
ancestors: ancestors,
|
53
|
+
body: { storage: { value: html, representation: 'storage' } }
|
54
|
+
)
|
55
|
+
else
|
56
|
+
page = @client.get_by_id(page['id'])
|
57
|
+
puts "Page '#{page_title}' exists. Updating it"
|
58
|
+
version = page['version']['number'] || 1
|
59
|
+
@client.update(
|
60
|
+
page['id'],
|
61
|
+
type: 'page',
|
62
|
+
id: page['id'],
|
63
|
+
title: page_title,
|
64
|
+
space: { key: @config['space'] },
|
65
|
+
ancestors: ancestors,
|
66
|
+
version: { number: version + 1 },
|
67
|
+
body: { storage: { value: html, representation: 'storage' } }
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def gendocs(title_page, strings: true)
|
73
|
+
module_html = Md2conf.parse_markdown File.read('README.md')
|
74
|
+
push_page(title_page, module_html, @config['ancestor'])
|
75
|
+
Dir.glob('*.md').each do |md_file|
|
76
|
+
next if md_file.eql? 'README.md'
|
77
|
+
html = if md_file.eql? 'CHANGELOG.md'
|
78
|
+
Md2conf.parse_markdown(File.read(md_file), max_toc_level: 2)
|
79
|
+
else
|
80
|
+
Md2conf.parse_markdown File.read(md_file)
|
81
|
+
end
|
82
|
+
page_title = "#{title_page} #{File.basename(md_file).sub('.md', '').split('_').map(&:capitalize).join(' ')}"
|
83
|
+
push_page(page_title, html, title_page)
|
84
|
+
end
|
85
|
+
if strings
|
86
|
+
PuppetStrings.generate(PuppetStrings::DEFAULT_SEARCH_PATTERNS, json: 'puppet_strings.json')
|
87
|
+
reference_html = Strings2conf.convert(File.read('puppet_strings.json'))
|
88
|
+
push_page("#{title_page} Reference", reference_html, title_page)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/puppet2conf.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'puppet2conf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'puppet2conf'
|
8
|
+
spec.version = Puppet2conf::VERSION
|
9
|
+
spec.authors = ['Vladimir Tyshkevich', 'Eugene Piven']
|
10
|
+
spec.email = ['vtyshkevich@iponweb.net', 'epiven@iponweb.net']
|
11
|
+
spec.summary = 'Gets XHTML Confluence storage and push it to Confluence'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
|
+
spec.bindir = 'exe'
|
15
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.add_runtime_dependency 'md2conf'
|
19
|
+
spec.add_runtime_dependency 'strings2conf'
|
20
|
+
spec.add_runtime_dependency 'puppet-strings'
|
21
|
+
spec.add_runtime_dependency 'conf-api-client'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet2conf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vladimir Tyshkevich
|
8
|
+
- Eugene Piven
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-08-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: md2conf
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: strings2conf
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: puppet-strings
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: conf-api-client
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rake
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
description:
|
113
|
+
email:
|
114
|
+
- vtyshkevich@iponweb.net
|
115
|
+
- epiven@iponweb.net
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CODE_OF_CONDUCT.md
|
124
|
+
- CONTRIBUTING.md
|
125
|
+
- Gemfile
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/console
|
130
|
+
- bin/setup
|
131
|
+
- lib/puppet2conf.rb
|
132
|
+
- lib/puppet2conf/version.rb
|
133
|
+
- puppet2conf.gemspec
|
134
|
+
homepage:
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.6.11
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Gets XHTML Confluence storage and push it to Confluence
|
158
|
+
test_files: []
|