-
Notifications
You must be signed in to change notification settings - Fork 30
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
Introduce a pulpcore::admin define #43
Merged
Merged
Changes from all commits
Commits
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 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,38 @@ | ||
# @summary Run a django-admin command | ||
# | ||
# @param command | ||
# The command to run | ||
# | ||
# @param refreshonly | ||
# The command should only be run as a refresh mechanism for when a dependent | ||
# object is changed. | ||
# | ||
# @param unless | ||
# A test command that checks the state of the target system and restricts | ||
# when the exec can run. | ||
# | ||
# @param path | ||
# The path to look for commands. | ||
# | ||
# @param pulp_settings | ||
# The pulp settings file to use | ||
# | ||
# @see exec | ||
define pulpcore::admin( | ||
String $command = $title, | ||
Boolean $refreshonly = false, | ||
Optional[String] $unless = undef, | ||
Array[Stdlib::Absolutepath] $path = ['/usr/bin'], | ||
Stdlib::Absolutepath $pulp_settings = $pulpcore::settings_file, | ||
) { | ||
File <| title == $pulp_settings |> | ||
-> exec { "django-admin ${title}": | ||
path => $path, | ||
environment => [ | ||
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings', | ||
"PULP_SETTINGS=${pulp_settings}", | ||
], | ||
refreshonly => $refreshonly, | ||
unless => $unless, | ||
} | ||
} |
This file contains 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 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 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,59 @@ | ||
require 'spec_helper' | ||
|
||
describe 'pulpcore::admin' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:title) { 'help' } | ||
|
||
context 'with a fixed pulp_settings' do | ||
let(:params) { { pulp_settings: '/etc/pulpcore/settings.py' } } | ||
|
||
context 'default parameters' do | ||
it do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_exec('django-admin help') | ||
.with_environment(['DJANGO_SETTINGS_MODULE=pulpcore.app.settings', 'PULP_SETTINGS=/etc/pulpcore/settings.py']) | ||
.with_refreshonly(false) | ||
.with_unless(nil) | ||
end | ||
end | ||
|
||
context 'default parameters' do | ||
let(:params) do | ||
super().merge( | ||
command: 'migrate --noinput', | ||
refreshonly: true, | ||
unless: '/usr/bin/false', | ||
) | ||
end | ||
|
||
it do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_exec('django-admin help') | ||
.with_environment(['DJANGO_SETTINGS_MODULE=pulpcore.app.settings', 'PULP_SETTINGS=/etc/pulpcore/settings.py']) | ||
.with_refreshonly(true) | ||
.with_unless('/usr/bin/false') | ||
end | ||
end | ||
end | ||
|
||
context 'with inheritance' do | ||
let(:pre_condition) { 'include pulpcore' } | ||
|
||
context 'default parameters' do | ||
it do | ||
is_expected.to compile.with_all_deps | ||
is_expected.to contain_pulpcore__admin('help').with_pulp_settings('/etc/pulp/settings.py') | ||
is_expected.to contain_file('/etc/pulp/settings.py') | ||
is_expected.to contain_exec('django-admin help') | ||
.with_environment(['DJANGO_SETTINGS_MODULE=pulpcore.app.settings', 'PULP_SETTINGS=/etc/pulp/settings.py']) | ||
.with_refreshonly(false) | ||
.with_unless(nil) | ||
.that_requires('File[/etc/pulp/settings.py]') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So once @evgeni has modified the RPM design so that django 3's
django-admin
does not conflict with django 2, we can update theexec
statement in a single place and have it be correct for the whole module.I really like this approach. LGTM.