Skip to content

Commit

Permalink
Tidy up deployment envs
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljcollinsuk committed Jan 15, 2024
1 parent 6524d72 commit 69570b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
11 changes: 6 additions & 5 deletions controlpanel/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ def delete_customer_by_email(self, email, group_id):
def status(self):
return "Deployed"

def deployment_envs(self, github_token):
return cluster.App(self, github_token).get_deployment_envs()

def delete(self, *args, **kwargs):
github_api_token = None
if "github_api_token" in kwargs:
Expand Down Expand Up @@ -319,8 +316,12 @@ class DeleteCustomerError(Exception):

@receiver(post_save, sender=App)
def trigger_app_create_related_messages(sender, instance, created, **kwargs):
if created:
tasks.AppCreateRole(instance, instance.current_user).create_task()
if not created:
return
tasks.AppCreateRole(instance, instance.current_user).create_task()

# TODO this could be removed as part of a review of task queue usage
if instance.deployment_envs:
tasks.AppCreateAuth(instance, instance.current_user, extra_data=dict(
deployment_envs=instance.deployment_envs,
disable_authentication=instance.disable_authentication,
Expand Down
1 change: 0 additions & 1 deletion controlpanel/api/tasks/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def _get_args_list(self):
self.extra_data.get('deployment_envs'),
self.extra_data.get('disable_authentication'),
self.extra_data.get('connections'),
# self.extra_data.get('has_ip_ranges') # NOT USED, REMOVE IT?
]

@property
Expand Down
4 changes: 0 additions & 4 deletions tests/api/models/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ def test_create(sqs, helpers):
helpers.validate_task_with_sqs_messages(
iam_messages, App.__name__, app.id, queue_name=settings.IAM_QUEUE_NAME
)
auth_messages = helpers.retrieve_messages(sqs, queue_name=settings.AUTH_QUEUE_NAME)
helpers.validate_task_with_sqs_messages(
auth_messages, App.__name__, app.id, queue_name=settings.AUTH_QUEUE_NAME
)


@pytest.mark.django_db
Expand Down
4 changes: 2 additions & 2 deletions tests/api/views/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def test_create(client, users, sqs, helpers):
assert response.data["repo_url"] == "https://example.com/bar"

app = App.objects.get(repo_url="https://example.com/bar")
messages = helpers.retrieve_messages(sqs)
helpers.validate_task_with_sqs_messages(messages, App.__name__, app.id)
messages = helpers.retrieve_messages(sqs, queue_name=settings.IAM_QUEUE_NAME)
helpers.validate_task_with_sqs_messages(messages, App.__name__, app.id, queue_name=settings.IAM_QUEUE_NAME)


def test_update(client, app):
Expand Down

0 comments on commit 69570b2

Please sign in to comment.