From 1b7dbbb409c8f7972099cd13a31cae2389f4e48f Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Wed, 31 Jan 2024 09:15:21 -0600 Subject: [PATCH] Add django ansible base (#2048) * Add django ansible base * Bump to python 3.9 No-Issue --- .github/workflows/changelog.yml | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/nightly.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/update-labels.yml | 2 +- .github/workflows/update_ci.yml | 2 +- profiles/dab/README.md | 5 +++++ profiles/dab/profile_requirements.txt | 1 + profiles/dab/pulp_config.env | 5 +++++ requirements/requirements.common.txt | 16 ++++++++++++++- requirements/requirements.insights.txt | 16 ++++++++++++++- requirements/requirements.standalone.txt | 16 ++++++++++++++- setup.py | 25 ++++++++++++------------ template_config.yml | 2 +- 14 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 profiles/dab/README.md create mode 100644 profiles/dab/profile_requirements.txt create mode 100644 profiles/dab/pulp_config.env diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index d02dbcbd3e..17c35ad77a 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Install python dependencies run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d594db936..705c338ac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: fetch-depth: 1 - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" # lint_requirements contains tools needed for flake8, etc. - name: Install requirements run: pip3 install -r lint_requirements.txt @@ -106,7 +106,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Install httpie run: | diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 00b6023a10..b8df6ecab9 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -38,7 +38,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Install httpie run: | @@ -208,7 +208,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c74e4119a..e4140d04fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Untar repository run: | diff --git a/.github/workflows/update-labels.yml b/.github/workflows/update-labels.yml index ade2ca0508..269ecdb7d3 100644 --- a/.github/workflows/update-labels.yml +++ b/.github/workflows/update-labels.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Configure Git with ansible name and email run: | git config --global user.name 'ansible' diff --git a/.github/workflows/update_ci.yml b/.github/workflows/update_ci.yml index 1edf9ba126..450611e1a8 100644 --- a/.github/workflows/update_ci.yml +++ b/.github/workflows/update_ci.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" - name: Install python dependencies run: | diff --git a/profiles/dab/README.md b/profiles/dab/README.md new file mode 100644 index 0000000000..f84453526b --- /dev/null +++ b/profiles/dab/README.md @@ -0,0 +1,5 @@ +# galaxy_ng/dab + +## Usage + +This profile is used for running Galaxy NG with the JWT authentication integrations provided by django-ansible-base \ No newline at end of file diff --git a/profiles/dab/profile_requirements.txt b/profiles/dab/profile_requirements.txt new file mode 100644 index 0000000000..cc6421d168 --- /dev/null +++ b/profiles/dab/profile_requirements.txt @@ -0,0 +1 @@ +galaxy_ng/base \ No newline at end of file diff --git a/profiles/dab/pulp_config.env b/profiles/dab/pulp_config.env new file mode 100644 index 0000000000..3566231d12 --- /dev/null +++ b/profiles/dab/pulp_config.env @@ -0,0 +1,5 @@ +PULP_GALAXY_AUTHENTICATION_CLASSES="['ansible_base.jwt_consumer.hub.auth.HubJWTAuth', 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.BasicAuthentication']" + +PULP_ANSIBLE_BASE_JWT_VALIDATE_CERT=false +PULP_ANSIBLE_BASE_JWT_KEY=https://localhost +PULP_CSRF_TRUSTED_ORIGINS = ['https://localhost'] diff --git a/requirements/requirements.common.txt b/requirements/requirements.common.txt index 5d5ba882ff..7858129616 100644 --- a/requirements/requirements.common.txt +++ b/requirements/requirements.common.txt @@ -71,6 +71,7 @@ click==8.1.3 cryptography==41.0.1 # via # ansible-core + # django-ansible-base # pulpcore # pyjwt # social-auth-core @@ -92,7 +93,9 @@ distro==1.8.0 # galaxy-ng (setup.py) django==4.2.7 # via + # django-ansible-base # django-auth-ldap + # django-crum # django-filter # django-guid # django-import-export @@ -104,8 +107,12 @@ django==4.2.7 # insights-analytics-collector # pulpcore # social-auth-app-django +django-ansible-base[jwt_consumer] @ git+https://github.com/ansible/django-ansible-base@devel + # via galaxy-ng (setup.py) django-auth-ldap==4.0.0 # via galaxy-ng (setup.py) +django-crum==0.7.9 + # via django-ansible-base django-filter==23.2 # via pulpcore django-guid==3.3.0 @@ -120,8 +127,11 @@ django-picklefield==3.1 # via galaxy-ng (setup.py) django-prometheus==2.3.1 # via galaxy-ng (setup.py) +django-split-settings==1.2.0 + # via django-ansible-base djangorestframework==3.14.0 # via + # django-ansible-base # drf-access-policy # drf-nested-routers # drf-spectacular @@ -179,7 +189,9 @@ importlib-metadata==6.0.1 # opentelemetry-api # pulpcore inflection==0.5.1 - # via drf-spectacular + # via + # django-ansible-base + # drf-spectacular insights-analytics-collector==0.3.2 # via galaxy-ng (setup.py) jinja2==3.1.2 @@ -349,6 +361,7 @@ pyjwkest==1.4.2 # via pulp-container pyjwt[crypto]==2.7.0 # via + # django-ansible-base # pulp-container # social-auth-core pyparsing==3.1.1 @@ -380,6 +393,7 @@ redis==4.5.5 # via pulpcore requests==2.31.0 # via + # django-ansible-base # galaxy-importer # insights-analytics-collector # opentelemetry-exporter-otlp-proto-http diff --git a/requirements/requirements.insights.txt b/requirements/requirements.insights.txt index 9ae43a5b5e..bcfe5a82bc 100644 --- a/requirements/requirements.insights.txt +++ b/requirements/requirements.insights.txt @@ -77,6 +77,7 @@ click==8.1.3 cryptography==41.0.1 # via # ansible-core + # django-ansible-base # pulpcore # pyjwt # social-auth-core @@ -98,7 +99,9 @@ distro==1.8.0 # galaxy-ng (setup.py) django==4.2.7 # via + # django-ansible-base # django-auth-ldap + # django-crum # django-filter # django-guid # django-import-export @@ -111,8 +114,12 @@ django==4.2.7 # insights-analytics-collector # pulpcore # social-auth-app-django +django-ansible-base[jwt_consumer] @ git+https://github.com/ansible/django-ansible-base@devel + # via galaxy-ng (setup.py) django-auth-ldap==4.0.0 # via galaxy-ng (setup.py) +django-crum==0.7.9 + # via django-ansible-base django-filter==23.2 # via pulpcore django-guid==3.3.0 @@ -127,10 +134,13 @@ django-picklefield==3.1 # via galaxy-ng (setup.py) django-prometheus==2.3.1 # via galaxy-ng (setup.py) +django-split-settings==1.2.0 + # via django-ansible-base django-storages[boto3]==1.14.2 # via -r requirements/requirements.insights.in djangorestframework==3.14.0 # via + # django-ansible-base # drf-access-policy # drf-nested-routers # drf-spectacular @@ -188,7 +198,9 @@ importlib-metadata==6.0.1 # opentelemetry-api # pulpcore inflection==0.5.1 - # via drf-spectacular + # via + # django-ansible-base + # drf-spectacular insights-analytics-collector==0.3.2 # via galaxy-ng (setup.py) jinja2==3.1.2 @@ -360,6 +372,7 @@ pyjwkest==1.4.2 # via pulp-container pyjwt[crypto]==2.7.0 # via + # django-ansible-base # pulp-container # social-auth-core pyparsing==3.1.1 @@ -391,6 +404,7 @@ redis==4.5.5 # via pulpcore requests==2.31.0 # via + # django-ansible-base # galaxy-importer # insights-analytics-collector # opentelemetry-exporter-otlp-proto-http diff --git a/requirements/requirements.standalone.txt b/requirements/requirements.standalone.txt index 09e8b3b1f9..840de8a806 100644 --- a/requirements/requirements.standalone.txt +++ b/requirements/requirements.standalone.txt @@ -71,6 +71,7 @@ click==8.1.3 cryptography==41.0.1 # via # ansible-core + # django-ansible-base # pulpcore # pyjwt # social-auth-core @@ -92,7 +93,9 @@ distro==1.8.0 # galaxy-ng (setup.py) django==4.2.7 # via + # django-ansible-base # django-auth-ldap + # django-crum # django-filter # django-guid # django-import-export @@ -104,8 +107,12 @@ django==4.2.7 # insights-analytics-collector # pulpcore # social-auth-app-django +django-ansible-base[jwt_consumer] @ git+https://github.com/ansible/django-ansible-base@devel + # via galaxy-ng (setup.py) django-auth-ldap==4.0.0 # via galaxy-ng (setup.py) +django-crum==0.7.9 + # via django-ansible-base django-filter==23.2 # via pulpcore django-guid==3.3.0 @@ -120,8 +127,11 @@ django-picklefield==3.1 # via galaxy-ng (setup.py) django-prometheus==2.3.1 # via galaxy-ng (setup.py) +django-split-settings==1.2.0 + # via django-ansible-base djangorestframework==3.14.0 # via + # django-ansible-base # drf-access-policy # drf-nested-routers # drf-spectacular @@ -179,7 +189,9 @@ importlib-metadata==6.0.1 # opentelemetry-api # pulpcore inflection==0.5.1 - # via drf-spectacular + # via + # django-ansible-base + # drf-spectacular insights-analytics-collector==0.3.2 # via galaxy-ng (setup.py) jinja2==3.1.2 @@ -349,6 +361,7 @@ pyjwkest==1.4.2 # via pulp-container pyjwt[crypto]==2.7.0 # via + # django-ansible-base # pulp-container # social-auth-core pyparsing==3.1.1 @@ -380,6 +393,7 @@ redis==4.5.5 # via pulpcore requests==2.31.0 # via + # django-ansible-base # galaxy-importer # insights-analytics-collector # opentelemetry-exporter-otlp-proto-http diff --git a/setup.py b/setup.py index 39f00bffba..9255f70ccf 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,8 @@ class PrepareStaticCommand(Command): DEV_UI_DOWNLOAD_URL = ( "https://github.com/ansible/ansible-hub-ui/" - "releases/download/dev/automation-hub-ui-dist.tar.gz") + "releases/download/dev/automation-hub-ui-dist.tar.gz" + ) ALTERNATE_UI_DOWNLOAD_URL = os.environ.get("ALTERNATE_UI_DOWNLOAD_URL") @@ -31,9 +32,9 @@ class PrepareStaticCommand(Command): user_options = [ ( - 'force-download-ui', + "force-download-ui", None, - 'Replace any existing static files with the ones downloaded from github.' + "Replace any existing static files with the ones downloaded from github.", ), ] @@ -76,13 +77,13 @@ def _download_tarball(self, url, download_file): class SDistCommand(_SDistCommand): def run(self): - self.run_command('prepare_static') + self.run_command("prepare_static") return super().run() class BuildPyCommand(_BuildPyCommand): def run(self): - self.run_command('prepare_static') + self.run_command("prepare_static") return super().run() @@ -105,8 +106,7 @@ def _format_pulp_requirement(plugin, specifier=None, ref=None, gh_namespace="pul else: repo = plugin.replace("-", "_") return ( - f"{plugin}@git+https://git@github.com/" - f"{gh_namespace}/{repo}.git@{ref}#egg={plugin}" + f"{plugin}@git+https://git@github.com/" f"{gh_namespace}/{repo}.git@{ref}#egg={plugin}" ) @@ -124,6 +124,7 @@ def _format_pulp_requirement(plugin, specifier=None, ref=None, gh_namespace="pul "insights_analytics_collector>=0.3.0", "boto3", "distro", + "django-ansible-base[jwt_consumer] @ git+https://github.com/ansible/django-ansible-base@devel", # noqa 501 # From vendored automated_logging "marshmallow<4.0.0,>=3.6.1", "django-picklefield<4.0.0,>=3.0.1", @@ -133,7 +134,7 @@ def _format_pulp_requirement(plugin, specifier=None, ref=None, gh_namespace="pul # https://softwareengineering.stackexchange.com/questions/223634/what-is-meant-by-now-you-have-two-problems def strip_package_name(spec): - operators = ['=', '>', '<', '~', '!', '^', '@'] + operators = ["=", ">", "<", "~", "!", "^", "@"] for idc, char in enumerate(spec): if char in operators: return spec[:idc] @@ -152,13 +153,11 @@ def strip_package_name(spec): #steps-to-run-dev-environment-with-specific-upstream-branch """ DEV_SOURCE_PATH = os.getenv( - "DEV_SOURCE_PATH", - default="pulpcore:pulp_ansible:pulp_container:galaxy_importer" + "DEV_SOURCE_PATH", default="pulpcore:pulp_ansible:pulp_container:galaxy_importer" ).split(":") DEV_SOURCE_PATH += [path.replace("_", "-") for path in DEV_SOURCE_PATH] requirements = [ - strip_package_name(req) - if req.lower().startswith(tuple(DEV_SOURCE_PATH)) else req + strip_package_name(req) if req.lower().startswith(tuple(DEV_SOURCE_PATH)) else req for req in requirements ] print("Installing with unpinned DEV_SOURCE_PATH requirements", requirements) @@ -171,7 +170,7 @@ def strip_package_name(spec): author="Red Hat, Inc.", author_email="info@ansible.com", url="https://github.com/ansible/galaxy_ng/", - python_requires=">=3.8", + python_requires=">=3.9", setup_requires=["wheel"], install_requires=requirements, include_package_data=True, diff --git a/template_config.yml b/template_config.yml index 48826e2ef6..535479595d 100644 --- a/template_config.yml +++ b/template_config.yml @@ -87,7 +87,7 @@ pulp_settings_s3: null pulpprojectdotorg_key_id: null pydocstyle: true pypi_username: null -python_version: '3.8' +python_version: '3.9' release_email: ansible-infra@redhat.com release_user: ansible run_pulpcore_tests_for_plugins: false