module

Krikri::PluginHelpers::MysqlPrivileges

MysqlPrivileges - pure logic for parsing/comparing MySQL privilege grants. No I/O - mysql_user.cr does the actual GRANT/REVOKE calls.

Class methods

current_grants(show_grants_lines : Enumerable(String)) : Hash(String, Set(String))

Reduces a full SHOW GRANTS result to the same {target => privileges} shape parse_spec produces, for direct comparison.

Source
desired_grants(spec : String) : Hash(String, Set(String))
Source
parse_show_grants_line(line : String) : Grant | Nil

Parses one line of real SHOW GRANTS FOR user@host output, e.g. GRANT SELECT, INSERT ON \db`.* TO `user`@`host`, optionally suffixed WITH GRANT OPTION(mapped to a "GRANT" pseudo-privilege, matching real Ansible's own priv: convention for the grant option). Returns nil for the baselineGRANT USAGE ON . TO ... IDENTIFIED BY ...` identity row every MySQL/MariaDB account has regardless of what's actually been granted to it - not a real privilege grant, and would otherwise always show up as a spurious diff against any desired priv: spec.

Source
parse_spec(spec : String) : Array(Grant)

Parses a priv: param string in real Ansible's own format: "db.table:PRIV1,PRIV2/db2.table2:PRIV3" (multiple grants separated by "/", privileges within one grant separated by ",").

Source

Nested types