From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 3B46522267 for ; Fri, 22 Jun 2018 18:12:02 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b5K9ExGL_4zm for ; Fri, 22 Jun 2018 18:12:02 -0400 (EDT) Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id F035121A8D for ; Fri, 22 Jun 2018 18:12:01 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 2/3] Allow use existing user References: <9e713265548c04cbc3325929ae6ba3fbef533245.1529703268.git.avkhatskevich@tarantool.org> From: Vladislav Shpilevoy Message-ID: <4d20128b-9199-739a-83e4-3eacfa03465a@tarantool.org> Date: Sat, 23 Jun 2018 01:12:00 +0300 MIME-Version: 1.0 In-Reply-To: <9e713265548c04cbc3325929ae6ba3fbef533245.1529703268.git.avkhatskevich@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, AKhatskevich Thanks for the patch! See 1 comment below. On 23/06/2018 00:43, AKhatskevich wrote: > This commit allows to create vshard user outside of vshard. > > This feature is tested in the next commit (destroy). > > Closes #52 > --- > vshard/storage/init.lua | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua > index 57076e1..059e705 100644 > --- a/vshard/storage/init.lua > +++ b/vshard/storage/init.lua > @@ -138,11 +138,19 @@ end > -------------------------------------------------------------------------------- > -- Schema > -------------------------------------------------------------------------------- > +local function create_user(username, password) > + box.schema.user.create(username, { > + password = password, > + if_not_exists = true, > + }) > + -- Replication may has not been granted, if user exists. > + box.schema.user.grant(username, 'replication', nil, nil, > + {if_not_exists = true}) > +end > > local function storage_schema_v1(username, password) > log.info("Initializing schema") > - box.schema.user.create(username, {password = password}) > - box.schema.user.grant(username, 'replication') > + create_user(username, password) 1. Please, just inline this function. It is not needed anywhere else and is extremely simple. > > local bucket = box.schema.space.create('_bucket') > bucket:format({ >