fix: push account duplicate (#9336)

Co-authored-by: feng <1304903146@qq.com>
pull/9338/head
fit2bot 2023-01-18 17:33:10 +08:00 committed by GitHub
parent c2a8acb73b
commit 4bef48eb6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -21,14 +21,15 @@ class PushAccountManager(PushOrVerifyHostCallbackMixin, AccountBasePlaybookManag
def create_nonlocal_accounts(self, accounts, snapshot_account_usernames, asset):
secret = self.execution.snapshot['secret']
usernames = accounts.filter(secret_type=self.secret_type).values_list(
secret_type = self.secret_type
usernames = accounts.filter(secret_type=secret_type).values_list(
'username', flat=True
)
create_usernames = set(snapshot_account_usernames) - set(usernames)
create_account_objs = [
Account(
name=username, username=username, secret=secret,
secret_type=self.secret_type, asset=asset,
name=f'{username}-{secret_type}', username=username,
secret=secret, secret_type=secret_type, asset=asset,
)
for username in create_usernames
]