Skip to content

(MODULES-8193) - Wrapper methods created for inbuilt 4.x functions #1151

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 2 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 125 additions & 34 deletions REFERENCE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Reference
<!-- DO NOT EDIT: This document was generated by Puppet Strings -->

## Classes
## Table of Contents

**Classes**

### Public Classes
_Public Classes_

* [`mysql::bindings`](#mysqlbindings): Parent class for MySQL bindings.
* [`mysql::client`](#mysqlclient): Installs and configures the MySQL client.
Expand All @@ -12,7 +14,7 @@
* [`mysql::server::monitor`](#mysqlservermonitor): This is a helper class to add a monitoring user to the database
* [`mysql::server::mysqltuner`](#mysqlservermysqltuner): Manage the MySQLTuner package.

### Private Classes
_Private Classes_

* `mysql::backup::mysqlbackup`: Manage the mysqlbackup client.
* `mysql::backup::mysqldump`: "Provider" for mysqldump
Expand All @@ -35,31 +37,35 @@
* `mysql::server::root_password`: Private class for managing the root password
* `mysql::server::service`: Private class for managing the MySQL service

## Defined types
**Defined types**

* [`mysql::db`](#mysqldb): Create and configure a MySQL database.

## Resource types
**Resource types**

### Public Resource types
_Public Resource types_

* [`mysql_plugin`](#mysql_plugin): Manage MySQL plugins.

### Private Resource types
_Private Resource types_

* `mysql_database`: Manage a MySQL database.
* `mysql_datadir`: Manage MySQL datadirs with mysql_install_db OR mysqld (5.7.6 and above).
* `mysql_grant`: Manage a MySQL user's rights.
* `mysql_user`: Manage a MySQL user. This includes management of users password as well as privileges.

## Functions
**Functions**

* [`mysql_deepmerge`](#mysql_deepmerge): Recursively merges two or more hashes together and returns the resulting hash.
* [`mysql_dirname`](#mysql_dirname): Returns the dirname of a path
* [`mysql::password`](#mysqlpassword): Hash a string as mysql's "PASSWORD()" function would do it
* [`mysql::strip_hash`](#mysqlstrip_hash): When given a hash this function strips out all blank entries.
* [`mysql_password`](#mysql_password): A wrapper for the 4.x function 'mysql::password' to bridge the gap between
it and the 3.x function 'mysql_password'.
* [`mysql_password`](#mysql_password): Hash a string as mysql's "PASSWORD()" function would do it
* [`mysql_strip_hash`](#mysql_strip_hash): A wrapper for the 4.x function 'mysql::strip_hash' to bridge the gap between
it and the 3.x function 'mysql_strip_hash'.
* [`mysql_strip_hash`](#mysql_strip_hash): TEMPORARY FUNCTION: EXPIRES 2014-03-10 When given a hash this function strips out all blank entries.

## Tasks
**Tasks**

* [`export`](#export): Allows you to backup your database to local file.
* [`sql`](#sql): Allows you to execute arbitary SQL
Expand Down Expand Up @@ -616,6 +622,22 @@ This parameter no longer does anything. It exists only for backwards compatibili

Default value: `undef`

##### `create_root_login_file`

Data type: `Any`



Default value: $mysql::params::create_root_login_file

##### `login_file`

Data type: `Any`



Default value: $mysql::params::login_file

### mysql::server::backup

Create and manage a MySQL backup.
Expand Down Expand Up @@ -811,7 +833,7 @@ Default value: '1M'

Data type: `Any`

Specifies an array of optional arguments which should be passed through to the backup tool. (Currently only supported by the xtrabackup provider.)
Specifies an array of optional arguments which should be passed through to the backup tool. (Supported by the xtrabackup and mysqldump providers.)

Default value: []

Expand Down Expand Up @@ -879,13 +901,13 @@ Source path for the mysqltuner package.

Default value: `undef`

##### `environment`
##### `tuner_location`

Data type: `Any`

Environment variables active during download, e.g. to download via proxies: environment => 'https_proxy=http://proxy.example.com:80'
Destination for the mysqltuner package.

Default value: `undef`
Default value: '/usr/local/bin/mysqltuner'

## Defined types

Expand Down Expand Up @@ -922,6 +944,14 @@ Data type: `Any`

The password for $user for the database you're creating.

##### `tls_options`

Data type: `Any`

The tls_options for $user for the database you're creating.

Default value: `undef`

##### `dbname`

Data type: `Any`
Expand Down Expand Up @@ -962,6 +992,14 @@ The privileges to be granted for user@host on the database.

Default value: 'ALL'

##### `grant_options`

Data type: `Any`

The grant_options for the grant for user@host on the database.

Default value: `undef`

##### `sql`

Data type: `Optional[Variant[Array, Hash, String]]`
Expand Down Expand Up @@ -1002,6 +1040,14 @@ Command to read the sqlfile for importing the database. Useful for compressed sq

Default value: 'cat'

##### `mysql_exec_path`

Data type: `Any`



Default value: $mysql::params::exec_path

## Resource types

### mysql_plugin
Expand Down Expand Up @@ -1048,39 +1094,62 @@ The name of the MySQL plugin to manage.

## Functions

### mysql_deepmerge
### mysql::password

Type: Ruby 3.x API
Type: Ruby 4.x API

- When there is a duplicate key that is a hash, they are recursively merged.
- When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
- When there are conficting uses of dashes and underscores in two keys (which mysql would otherwise equate),
the rightmost style will win.
Hash a string as mysql's "PASSWORD()" function would do it

#### `mysql_deepmerge()`
#### `mysql::password(String $password)`

- When there is a duplicate key that is a hash, they are recursively merged.
- When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
- When there are conficting uses of dashes and underscores in two keys (which mysql would otherwise equate),
the rightmost style will win.
The mysql::password function.

Returns: `Hash`
Returns: `String` hash
The mysql password hash from the clear text password.

### mysql_dirname
##### `password`

Type: Ruby 3.x API
Data type: `String`

Plain text password.

### mysql::strip_hash

Type: Ruby 4.x API

When given a hash this function strips out all blank entries.

#### `mysql::strip_hash(Hash $hash)`

The mysql::strip_hash function.

Returns: `Hash` hash
The given hash with all blank entries removed

##### `hash`

Data type: `Hash`

Hash to be stripped

Returns the dirname of a path
### mysql_password

Type: Ruby 4.x API

#### `mysql_dirname(String $path)`
A wrapper for the 4.x function 'mysql::password' to bridge the gap between
it and the 3.x function 'mysql_password'.

Returns: `String` Directory name of path.
#### `mysql_password(String $password)`

##### `path`
The mysql_password function.

Returns: `String` The mysql password hash from the 4.x function mysql::password.

##### `password`

Data type: `String`

Path to find the dirname for.
Plain text password.

### mysql_password

Expand All @@ -1090,6 +1159,8 @@ Hash a string as mysql's "PASSWORD()" function would do it

#### `mysql_password(String $password)`

The mysql_password function.

Returns: `String` the mysql password hash from the clear text password.

##### `password`
Expand All @@ -1100,6 +1171,26 @@ Plain text password.

### mysql_strip_hash

Type: Ruby 4.x API

A wrapper for the 4.x function 'mysql::strip_hash' to bridge the gap between
it and the 3.x function 'mysql_strip_hash'.

#### `mysql_strip_hash(Hash $hash)`

The mysql_strip_hash function.

Returns: `Hash` hash
The given hash with all blank entries removed

##### `hash`

Data type: `Hash`

Hash to be stripped

### mysql_strip_hash

Type: Ruby 3.x API

TEMPORARY FUNCTION: EXPIRES 2014-03-10
Expand Down
3 changes: 2 additions & 1 deletion lib/puppet/functions/mysql/password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# @param password
# Plain text password.
#
# @return the mysql password hash from the clear text password.
# @return hash
# The mysql password hash from the clear text password.
#
dispatch :password do
required_param 'String', :password
Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/functions/mysql/strip_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# @param hash
# Hash to be stripped
#
# @return hash
# The given hash with all blank entries removed
#
dispatch :strip_hash do
required_param 'Hash', :hash
return_type 'Hash'
Expand Down
21 changes: 21 additions & 0 deletions lib/puppet/functions/mysql_password.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @summary
# A wrapper for the 4.x function 'mysql::password' to bridge the gap between
# it and the 3.x function 'mysql_password'.
#
Puppet::Functions.create_function(:mysql_password) do
# @param password
# Plain text password.
#
# @return
# The mysql password hash from the 4.x function mysql::password.
#
dispatch :mysql_password do
required_param 'String', :password
return_type 'String'
end

def mysql_password(password)
call_function('deprecation', 'mysql_password', "This method has been deprecated, please use the namespaced version 'mysql::password' instead.")
call_function('mysql::password', password)
end
end
21 changes: 21 additions & 0 deletions lib/puppet/functions/mysql_strip_hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @summary
# A wrapper for the 4.x function 'mysql::strip_hash' to bridge the gap between
# it and the 3.x function 'mysql_strip_hash'.
#
Puppet::Functions.create_function(:mysql_strip_hash) do
# @param hash
# Hash to be stripped
#
# @return hash
# The given hash with all blank entries removed
#
dispatch :mysql_strip_hash do
required_param 'Hash', :hash
return_type 'Hash'
end

def mysql_strip_hash(hash)
call_function('deprecation', 'mysql_strip_hash', "This method has been deprecated, please use the namespaced version 'mysql::strip_hash' instead.")
call_function('mysql::strip_hash', hash)
end
end
28 changes: 28 additions & 0 deletions spec/functions/mysql_password_wrapper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'spec_helper'

describe 'mysql_password' do
it 'exists' do
is_expected.not_to eq(nil)
end

it 'raises a ArgumentError if there is less than 1 arguments' do
is_expected.to run.with_params.and_raise_error(ArgumentError)
end

it 'raises a ArgumentError if there is more than 1 arguments' do
is_expected.to run.with_params('foo', 'bar').and_raise_error(ArgumentError)
end

# Please note that the below test's fail if run via rspec rather than rake
it 'converts password into a hash' do
is_expected.to run.with_params('password').and_return('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')
end

it 'converts an empty password into a empty string' do
is_expected.to run.with_params('').and_return('')
end

it 'does not convert a password that is already a hash' do
is_expected.to run.with_params('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19').and_return('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')
end
end
Loading