-
Notifications
You must be signed in to change notification settings - Fork 794
CAT-1147 erb to epp conversion #1589
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 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 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,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# @summary this function populates and returns the string of arguments which later gets injected in template. | ||
# arguments that return string holds is conditional and decided by the the input given to function. | ||
|
||
Puppet::Functions.create_function(:'mysql::innobackupex_args') do | ||
# @param args | ||
# String backupuser | ||
# Boolean backupcompress | ||
# String backuppassword_unsensitive | ||
# Array backupdatabases | ||
# Array optional_args | ||
# | ||
# @return String | ||
# Generated on the basis of provided values. | ||
# | ||
dispatch :innobackupex_args do | ||
required_param 'Optional[String]', :backupuser | ||
required_param 'Boolean', :backupcompress | ||
required_param 'Optional[Variant[String, Sensitive[String]]]', :backuppassword_unsensitive | ||
required_param 'Array[String[1]]', :backupdatabases | ||
required_param 'Array[String[1]]', :optional_args | ||
return_type 'Variant[String]' | ||
end | ||
|
||
def innobackupex_args(backupuser, backupcompress, backuppassword_unsensitive, backupdatabases, optional_args) | ||
innobackupex_args = '' | ||
innobackupex_args = "--user=\"#{backupuser}\" --password=\"#{backuppassword_unsensitive}\"" if backupuser && backuppassword_unsensitive | ||
|
||
innobackupex_args = "#{innobackupex_args} --compress" if backupcompress | ||
|
||
innobackupex_args = "#{innobackupex_args} --databases=\"#{backupdatabases.join(' ')}\"" if backupdatabases.is_a?(Array) && !backupdatabases.empty? | ||
|
||
if optional_args.is_a?(Array) | ||
optional_args.each do |arg| | ||
innobackupex_args = "#{innobackupex_args} #{arg}" | ||
end | ||
end | ||
innobackupex_args | ||
end | ||
end |
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,58 @@ | ||
# frozen_string_literal: true | ||
dinesh-gujar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
require 'spec_helper' | ||
|
||
describe 'mysql::innobackupex_args' do | ||
it 'exists' do | ||
expect(subject).not_to be_nil | ||
end | ||
|
||
it 'accepts empty strings as puppet undef' do | ||
expect(subject).to run.with_params('', true, '', [], []) | ||
end | ||
|
||
context 'should work with username and password' do | ||
it 'returns args with username and password' do | ||
expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') | ||
end | ||
|
||
it 'returns args with database lists' do | ||
expect(subject).to run.with_params('root', false, '12345', ['db1', 'db2'], []).and_return('--user="root" --password="12345" --databases="db1 db2"') | ||
end | ||
|
||
it 'returns args with backup compress only' do | ||
expected_results = '--user="root" --password="12345" --compress' | ||
expect(subject).to run.with_params('root', true, '12345', [], []).and_return(expected_results) | ||
end | ||
|
||
it 'returns args with backup compress, database list and optional_args' do | ||
expected_results = '--user="root" --password="12345" --compress --databases="db1 db2" tst_arg_1 tst_arg_2' | ||
expect(subject).to run.with_params('root', true, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) | ||
end | ||
end | ||
|
||
context 'should work without database args' do | ||
it 'returns args without database list' do | ||
expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') | ||
end | ||
end | ||
|
||
it 'returns args without backup compress' do | ||
expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') | ||
end | ||
|
||
it 'returns args with backup compress and database list' do | ||
expected_results = '--user="root" --password="12345" --compress --databases="db1 db2"' | ||
expect(subject).to run.with_params('root', true, '12345', ['db1', 'db2'], []).and_return(expected_results) | ||
end | ||
|
||
it 'returns args without backup compress database list and optional_args' do | ||
expected_results = '--user="root" --password="12345" --databases="db1 db2" tst_arg_1 tst_arg_2' | ||
expect(subject).to run.with_params('root', false, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) | ||
end | ||
|
||
it 'returns args without backup compress database list and with optional_args' do | ||
expected_results = '--user="root" --password="12345" tst_arg_1 tst_arg_2' | ||
expect(subject).to run.with_params('root', false, '12345', [], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) | ||
end | ||
end |
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,25 @@ | ||
### MANAGED BY PUPPET ### | ||
|
||
<% sort($options.map |$key, $value| { [$key, $value] }).map |$v| { -%> | ||
<% if type($v[1]) =~ Type[Hash] { -%> | ||
[<%= $v[0] %>] | ||
<%sort($v[1].map |$key, $value| { [$key, $value] }).map |$vi| { -%> | ||
<%- if ($vi[0] == 'ssl-disable') or ($vi[0] =~ /^ssl/ and $v[1]['ssl-disable'] == true) or ($vi[0] =~ /^ssl-/ and $v[1]['ssl'] == false) { -%> | ||
<%- next -%> | ||
<%- } elsif $vi[1] == true or $vi[1] == '' { -%> | ||
<%= $vi[0] -%> | ||
<%- } elsif type($vi[1]) =~ Type[Array] { -%> | ||
<%- $vi[1].each |$vii| { -%> | ||
<%-$base = $vi[0]-%> | ||
<%= $base %> = <%= $vii %> | ||
<%- } -%> | ||
<%- } elsif !($vi[1] ==nil or $vi[1]=='' or $vi[1]==undef) { -%> | ||
<%-$base = $vi[0]-%> | ||
<%= $base %> = <%= $vi[1] -%> | ||
<% } %> | ||
<% } %> | ||
<% } %> | ||
<% } %> | ||
<% if $includedir and $includedir != '' { -%> | ||
!includedir <%= $includedir %> | ||
<% } -%> |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
<%['mysql', 'client', 'mysqldump', 'mysqladmin', 'mysqlcheck'].each |$section| { %> | ||
[<%= $section -%>] | ||
user=root | ||
host=localhost | ||
<% if $root_password_set { -%> | ||
password='<%= $root_password %>' | ||
<% } -%> | ||
socket=<%= $options['client']['socket'] %> | ||
<% } %> |
This file was deleted.
Oops, something went wrong.
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.