-
Notifications
You must be signed in to change notification settings - Fork 88
Add Puppetserver catalog v4 API support #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
add3459
Add an option_globally_or_per_branch_boolean CLI option helper
seanmil b8b766c
Add Puppetserver v4 catalog API support
seanmil 452059f
Update documentation regarding v4 catalog API support
seanmil 3b03871
Merge branch 'master' into add_catalog_v4
ahayworth 15a8ad6
Merge branch 'master' into add_catalog_v4
ahayworth d3f1e29
Merge branch 'master' into add_catalog_v4
ahayworth 7a40644
Update doc/advanced-puppet-master.md
seanmil 9d99b1c
Update spec/octocatalog-diff/tests/cli/options/puppet_master_token_fi…
seanmil 182272e
Update docs with suggestions from PR
seanmil 94882db
Merge branch 'master' into add_catalog_v4
ahayworth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
# Specify a PE RBAC token used to authenticate to Puppetserver for v4 | ||
# catalog API calls. | ||
# @param parser [OptionParser object] The OptionParser argument | ||
# @param options [Hash] Options hash being constructed; this is modified in this method. | ||
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_token) do | ||
has_weight 310 | ||
|
||
def parse(parser, options) | ||
OctocatalogDiff::Cli::Options.option_globally_or_per_branch( | ||
parser: parser, | ||
options: options, | ||
datatype: '', | ||
cli_name: 'puppet-master-token', | ||
option_name: 'puppet_master_token', | ||
desc: 'PE RBAC token to authenticate to the Puppetserver API v4' | ||
) | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
lib/octocatalog-diff/cli/options/puppet_master_token_file.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
# Specify a path to a file containing a PE RBAC token used to authenticate to the | ||
# Puppetserver for a v4 catalog API call. | ||
# @param parser [OptionParser object] The OptionParser argument | ||
# @param options [Hash] Options hash being constructed; this is modified in this method. | ||
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_token_file) do | ||
has_weight 300 | ||
|
||
def parse(parser, options) | ||
OctocatalogDiff::Cli::Options.option_globally_or_per_branch( | ||
parser: parser, | ||
options: options, | ||
datatype: '', | ||
cli_name: 'puppet-master-token-file', | ||
option_name: 'puppet_master_token_file', | ||
desc: 'File containing PE RBAC token to authenticate to the Puppetserver API v4', | ||
translator: ->(x) { x.start_with?('/', '~') ? x : File.join(options[:basedir], x) }, | ||
post_process: lambda do |opts| | ||
%w(to from).each do |prefix| | ||
fileopt = "#{prefix}_puppet_master_token_file".to_sym | ||
tokenopt = "#{prefix}_puppet_master_token".to_sym | ||
|
||
tokenfile = opts[fileopt] | ||
next if tokenfile.nil? | ||
|
||
raise(Errno::ENOENT, "Token file #{tokenfile} is not readable") unless File.readable?(tokenfile) | ||
ahayworth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
token = File.read(tokenfile).strip | ||
opts[tokenopt] ||= token | ||
end | ||
end | ||
) | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
lib/octocatalog-diff/cli/options/puppet_master_update_catalog.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
# Specify if, when using the Puppetserver v4 catalog API, the Puppetserver should | ||
# update the catalog in PuppetDB. | ||
# @param parser [OptionParser object] The OptionParser argument | ||
# @param options [Hash] Options hash being constructed; this is modified in this method. | ||
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_update_catalog) do | ||
has_weight 320 | ||
|
||
def parse(parser, options) | ||
OctocatalogDiff::Cli::Options.option_globally_or_per_branch( | ||
parser: parser, | ||
options: options, | ||
datatype: false, | ||
cli_name: 'puppet-master-update-catalog', | ||
option_name: 'puppet_master_update_catalog', | ||
desc: 'Update catalog in PuppetDB when using Puppetmaster API version 4' | ||
) | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
lib/octocatalog-diff/cli/options/puppet_master_update_facts.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
# Specify if, when using the Puppetserver v4 catalog API, the Puppetserver should | ||
# update the facts in PuppetDB. | ||
# @param parser [OptionParser object] The OptionParser argument | ||
# @param options [Hash] Options hash being constructed; this is modified in this method. | ||
OctocatalogDiff::Cli::Options::Option.newoption(:puppet_master_update_facts) do | ||
has_weight 320 | ||
|
||
def parse(parser, options) | ||
OctocatalogDiff::Cli::Options.option_globally_or_per_branch( | ||
parser: parser, | ||
options: options, | ||
datatype: false, | ||
cli_name: 'puppet-master-update-facts', | ||
option_name: 'puppet_master_update_facts', | ||
desc: 'Update facts in PuppetDB when using Puppetmaster API version 4' | ||
) | ||
end | ||
end |
41 changes: 41 additions & 0 deletions
41
spec/octocatalog-diff/fixtures/catalogs/tiny-catalog-v4-api.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"catalog": { | ||
"tags": ["settings"], | ||
"name": "my.rspec.node", | ||
"version": "production", | ||
"code_id": null, | ||
"catalog_uuid": "89869359-db50-472f-b435-1d37c22be9eb", | ||
"catalog_format": 1, | ||
"environment": "production", | ||
"resources": [ | ||
{ | ||
"type": "Stage", | ||
"title": "main", | ||
"tags": ["stage"], | ||
"exported": false, | ||
"parameters": { | ||
"name": "main" | ||
} | ||
}, | ||
{ | ||
"type": "Class", | ||
"title": "Settings", | ||
"tags": ["class","settings"], | ||
"exported": false | ||
} | ||
], | ||
"edges": [ | ||
{ | ||
"source": "Stage[main]", | ||
"target": "Class[Settings]" | ||
}, | ||
{ | ||
"source": "Stage[main]", | ||
"target": "Class[main]" | ||
} | ||
], | ||
"classes": [ | ||
"settings" | ||
] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
secretpuppetmastertoken |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.