diff --git a/apps/accounts/automations/change_secret/manager.py b/apps/accounts/automations/change_secret/manager.py index 41b0a4844..eb2d9d185 100644 --- a/apps/accounts/automations/change_secret/manager.py +++ b/apps/accounts/automations/change_secret/manager.py @@ -153,6 +153,11 @@ class ChangeSecretManager(AccountBasePlaybookManager): logger.error("Change secret error: ", e) def run(self, *args, **kwargs): + if self.secret_strategy == SecretStrategy.custom \ + and not self.execution.snapshot['secret']: + print('Custom secret is empty') + return + super().run(*args, **kwargs) recorders = self.name_recorder_mapper.values() recorders = list(recorders) diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index 454708265..97033eda9 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -39,11 +39,22 @@ class AccountSerializerCreateValidateMixin: attrs = super().validate(attrs) return self.set_secret(attrs) + @staticmethod + def push_account(instance, push_now): + if not push_now: + return + push_accounts_to_assets.delay([instance.id], [instance.asset_id]) + def create(self, validated_data): push_now = validated_data.pop('push_now', None) - instance = super().create(validated_data) - if push_now: - push_accounts_to_assets.delay([instance.id], [instance.asset_id]) + instance = super().create(validated_data, push_now) + self.push_account(instance, push_now) + return instance + + def update(self, instance, validated_data): + push_now = validated_data.pop('push_now', None) + instance = super().update(instance, validated_data) + self.push_account(instance, push_now) return instance