Browse Source

enough: refactor manage enough_api

keep-around/aef162c68d2894154e05932f159c9a17e456887f
singuliere 2 years ago
parent
commit
9d0e6cd8ad
No known key found for this signature in database GPG Key ID: 900857755EF189C2
  1. 16
      enough/api/management/commands/enough_api.py
  2. 2
      molecule/api/roles/api/tasks/api.yml

16
enough/api/management/commands/enough_api.py

@ -13,14 +13,13 @@ class Command(BaseCommand):
parser.add_argument('username')
parser.add_argument('password')
def handle(self, *args, **kwargs):
def setup_gitlab_auth(self, *args, **kwargs):
provider = 'gitlab'
name = 'GitLab'
existing = SocialApp.objects.filter(provider=provider)
if existing:
self.stdout.write('Already exists')
return
return False
gitlab = GitLab(f'https://lab.{kwargs["domain"]}')
gitlab.login('root', kwargs['password'])
@ -35,4 +34,13 @@ class Command(BaseCommand):
sites = [i for i in Site.objects.all()]
a.sites.add(*sites)
self.stdout.write('Created')
return True
def handle(self, *args, **kwargs):
changed = False
changed |= self.setup_gitlab_auth(*args, **kwargs)
if changed:
self.stdout.write('Changed')
else:
self.stdout.write('Up to date')

2
molecule/api/roles/api/tasks/api.yml

@ -88,7 +88,7 @@
shell: |
enough --domain {{ domain }} manage enough_api {{ domain }} root '{{ gitlab_password }}'
register: result
changed_when: '"Created" in result.stdout'
changed_when: '"Changed" in result.stdout'
- name: enough create service
shell: |

Loading…
Cancel
Save