nicc777 / py-animus

A python based plugable and extensible manifest processing system
GNU General Public License v3.0
0 stars 0 forks source link

Logic enhancement in `ManifestManager` to not add execution count when `skipApplyAll` is set to `True` #44

Closed nicc777 closed 1 year ago

nicc777 commented 1 year ago

Brief Description of the Enhancement

Execution count was incremented when the apply/delete method was not actually executed but skipped due to the skipApplyAll option in a manifest. It should not be incremented.

Describe the benefit of this proposed enhancement

Better flow control

Code examples, pseudo code or any other technical description of the proposal

Original:


class ManifestManager:

    def apply_manifest(self, name: str, skip_dependency_processing: bool=False):
        manifest_instance = self.get_manifest_instance_by_name(name=name)
        self._record_manifest_instance_call(name=manifest_instance.metadata['name'])
        self.logger.debug('ManifestManager.apply_manifest(): manifest_instance named "{}" loaded. Previous exec count: {}'.format(manifest_instance.metadata['name'], self.executions_per_manifest_instance[manifest_instance.metadata['name']]))

        if 'skipApplyAll' in manifest_instance.metadata:
            if manifest_instance.metadata['skipApplyAll'] is True:
                self.logger.warning('ManifestManager:apply_manifest(): Manifest named "{}" skipped because of skipApplyAll setting'.format(manifest_instance.metadata['name']))
                return

Proposed change:

class ManifestManager:

    def apply_manifest(self, name: str, skip_dependency_processing: bool=False):
        manifest_instance = self.get_manifest_instance_by_name(name=name)
        self.logger.debug('ManifestManager.apply_manifest(): manifest_instance named "{}" loaded. Previous exec count: {}'.format(manifest_instance.metadata['name'], self.executions_per_manifest_instance[manifest_instance.metadata['name']]))

        if 'skipApplyAll' in manifest_instance.metadata:
            if manifest_instance.metadata['skipApplyAll'] is True:
                self.logger.warning('ManifestManager:apply_manifest(): Manifest named "{}" skipped because of skipApplyAll setting'.format(manifest_instance.metadata['name']))
                return

        self._record_manifest_instance_call(name=manifest_instance.metadata['name'])