Skip to content
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

Types redesign #82

Open
MaxFedotov opened this issue Nov 9, 2018 · 1 comment
Open

Types redesign #82

MaxFedotov opened this issue Nov 9, 2018 · 1 comment

Comments

@MaxFedotov
Copy link
Contributor

MaxFedotov commented Nov 9, 2018

Hello @bastelfreak and @mcrauwel!

I am now looking at types design and I think that it wasn't such a good idea to wrap everything in arrays, because right now all configurations files are looking a bit ugly.
Let me show my thoughts using examples.
Right now in order to configure multiples users in hiera we need to write an array of hashes, like:

"proxysql::mysql_users": [
    { "user1": {
        "password": "*92C74DFBDA5D60ABD41EFD7EB0DAE389F4646ABB",
        "default_hostgroup": 1,
        "transaction_persistent": false }
    },
    { "user2": {
        "password": "*86935F2843252CFAAC4CE713C0D5FF80CF444F3B",
        "default_hostgroup": 2 }
    },
    { "user3": {
        "password": "*86935F2843252CFAAC4CE713C0D5FF80CF444F3B",
        "default_hostgroup": 2 }
    },
    { "user4": {
        "password": "*86935F2843252CFAAC4CE713C0D5FF80CF444F3B",
        "default_hostgroup": 2 }
    }
 ]

but actually this arrays brackets just make reading in case of many users harder.
So my proposal is to get rid of arrays and use pure hashes (so it will be more ruby way).
So we will have this configuration parameter like:

"proxysql::mysql_users": {
    "user1": {
        "password": "*92C74DFBDA5D60ABD41EFD7EB0DAE389F4646ABB",
        "default_hostgroup": 1,
        "transaction_persistent": false 
    },
    "user2": {
        "password": "*86935F2843252CFAAC4CE713C0D5FF80CF444F3B",
        "default_hostgroup": 2 
    },
    "user3": {
        "password": "*86935F2843252CFAAC4CE713C0D5FF80CF444F3B",
        "default_hostgroup": 2 
    },
    "user4": {
        "password": "*86935F2843252CFAAC4CE713C0D5FF80CF444F3B",
        "default_hostgroup": 2 
    }
}

And the same thing for other types. As you see, this will be backward incompatible change, but it will make code an configuration more cleaner.

@CyberLine
Copy link
Contributor

CyberLine commented Feb 5, 2019

i use manifest parameter injection in conjunction with yaml:

test::services::proxysql::users:
  - user1:
      password: "*XXX"
      default_hostgroup: 5
class test::services::proxysql(
        Array $users            = [],
){
        class { '::proxysql':
                mysql_users             => $users,
...

works fine for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants