Skip to content

Commit

Permalink
Add option to skip credential type discovery
Browse files Browse the repository at this point in the history
* Option to avoid database operations in django init path. Useful for
  running collectstatic, or other management commands, without a database.
  • Loading branch information
chrismeyersfsu committed Nov 15, 2024
1 parent 3dbcfb1 commit 04c698d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion awx/main/apps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
from awx.main.utils.common import bypass_in_test
Expand Down Expand Up @@ -61,5 +63,11 @@ def load_credential_types_feature(self):
def ready(self):
super().ready()

self.load_credential_types_feature()
"""
Credential loading triggers database operations. There are cases we want to call
awx-manage collectstatic without a database. All management commands invoke the ready() code
path. Using settings.AWX_SKIP_CREDENTIAL_TYPES_DISCOVER _could_ invoke a database operation.
"""
if not os.environ.get('AWX_SKIP_CREDENTIAL_TYPES_DISCOVER', None):
self.load_credential_types_feature()
self.load_named_url_feature()

0 comments on commit 04c698d

Please sign in to comment.