Ejemplo n.º 1
0
 def present(self):
     ''' Handles state == 'present', creating or updating the secret '''
     secret = self.get_secret()
     if secret:
         self.results['secret_id'] = secret['ID']
         data_changed = False
         attrs = secret.get('Spec', {})
         if attrs.get('Labels', {}).get('ansible_key'):
             if attrs['Labels']['ansible_key'] != self.data_key:
                 data_changed = True
         labels_changed = not compare_generic(self.labels, attrs.get('Labels'), 'allow_more_present', 'dict')
         if data_changed or labels_changed or self.force:
             # if something changed or force, delete and re-create the secret
             self.absent()
             secret_id = self.create_secret()
             self.results['changed'] = True
             self.results['secret_id'] = secret_id
     else:
         self.results['changed'] = True
         self.results['secret_id'] = self.create_secret()
Ejemplo n.º 2
0
def test_compare_generic(entry):
    assert compare_generic(entry['a'], entry['b'], entry['method'],
                           entry['type']) == entry['result']