Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hyagi committed Jan 20, 2025
1 parent d7dc98b commit 171b0a5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if [ "$TEST" = "azure" ]; then
- ./azurite:/etc/pulp\
command: "azurite-blob --blobHost 0.0.0.0"' vars/main.yaml
sed -i -e '$a azure_test: true\
pulp_scenario_settings: {"api_root_rewrite_header": "X-API-Root", "content_origin": null, "domain_enabled": true, "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.DefaultAccessPolicy"]}\
pulp_scenario_settings: {"api_root_rewrite_header": "X-API-Root", "content_origin": "", "domain_enabled": true, "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.DefaultAccessPolicy"]}\
pulp_scenario_env: {}\
' vars/main.yaml
fi
Expand Down
2 changes: 1 addition & 1 deletion CHANGES/5931.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Allow CONTENT_ORIGIN to be None. When None, the base_url for Distributions is a relative path.
Allow CONTENT_ORIGIN to be "" (an empty string). When empty, the base_url for Distributions is a relative path.
4 changes: 2 additions & 2 deletions docs/admin/reference/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ this setting only applies to uploads created after the change.
A string containing the protocol, fqdn, and port where the content app is reachable by users.
This is used by `pulpcore` and various plugins when referring users to the content app.
For example if the API should refer users to content at using http to pulp.example.com on port
24816, (the content default port), you would set: `https://pulp.example.com:24816`. The default is `None`.
When set to `None`, the `base_url` for Distributions is a relative path.
24816, (the content default port), you would set: `https://pulp.example.com:24816`. The default is "".
When set to "" (empty string), the `base_url` for Distributions is a relative path.
This means the API returns relative URLs without the protocol, fqdn, and port.


Expand Down
4 changes: 1 addition & 3 deletions pulpcore/app/serializers/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ class BaseURLField(serializers.CharField):
"""

def to_representation(self, value):
origin = "/"
if settings.CONTENT_ORIGIN:
origin = settings.CONTENT_ORIGIN.strip("/")
origin = settings.CONTENT_ORIGIN.strip("/")
prefix = settings.CONTENT_PATH_PREFIX.strip("/")
base_path = value.base_path.strip("/")
url = urljoin(origin, prefix + "/")
Expand Down
2 changes: 0 additions & 2 deletions pulpcore/app/serializers/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class ContentSettingsSerializer(serializers.Serializer):
content_origin = serializers.CharField(
help_text=_("The CONTENT_ORIGIN setting for this Pulp instance"),
allow_blank=True,
allow_null=True,
required=False,
)
content_path_prefix = serializers.CharField(
help_text=_("The CONTENT_PATH_PREFIX setting for this Pulp instance"),
Expand Down
2 changes: 1 addition & 1 deletion pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@

DRF_ACCESS_POLICY = {"reusable_conditions": ["pulpcore.app.global_access_conditions"]}

CONTENT_ORIGIN = None
CONTENT_ORIGIN = ""
CONTENT_PATH_PREFIX = "/pulp/content/"

API_APP_TTL = 120 # The heartbeat is called from gunicorn notify (defaulting to 45 sec).
Expand Down
3 changes: 2 additions & 1 deletion pulpcore/tests/functional/api/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"content_settings": {
"type": "object",
"properties": {
"content_origin": {"type": ["string", "null"]},
"content_origin": {"type": ["string"]},
"content_path_prefix": {"type": "string"},
},
"required": ["content_origin", "content_path_prefix"],
Expand Down Expand Up @@ -138,6 +138,7 @@ def verify_get_response(status, expected_schema):
assert status["versions"] != []

assert status["content_settings"] is not None
assert status["content_settings"]["content_origin"] is not None
assert status["content_settings"]["content_path_prefix"] is not None

assert status["storage"]["used"] is not None
Expand Down
2 changes: 1 addition & 1 deletion template_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pulp_settings:
tmpfile_protection_time: 10
upload_protection_time: 10
pulp_settings_azure:
content_origin: null
content_origin: ""
api_root_rewrite_header: X-API-Root
domain_enabled: true
rest_framework__default_permission_classes:
Expand Down

0 comments on commit 171b0a5

Please sign in to comment.