|
27 | 27 | from paas_wl.workloads.networking.entrance.addrs import EnvExposedURL |
28 | 28 | from paasng.accessories.publish.entrance.domains import get_preallocated_domain, get_preallocated_domains_by_env |
29 | 29 | from paasng.accessories.publish.entrance.subpaths import get_preallocated_path, get_preallocated_paths_by_env |
| 30 | +from paasng.accessories.publish.market.models import MarketConfig |
| 31 | +from paasng.accessories.publish.market.utils import MarketAvailableAddressHelper |
30 | 32 | from paasng.platform.applications.models import Application, ModuleEnvironment |
31 | 33 | from paasng.platform.engine.configurations.env_var.entities import EnvVariableList, EnvVariableObj |
32 | 34 | from paasng.platform.engine.configurations.provider import env_vars_providers |
@@ -114,6 +116,25 @@ def _default_preallocated_urls(env: ModuleEnvironment) -> EnvVariableList: |
114 | 116 | ) |
115 | 117 |
|
116 | 118 |
|
| 119 | +@env_vars_providers.register_env |
| 120 | +def _market_entrance_url(env: ModuleEnvironment) -> EnvVariableList: |
| 121 | + """注入应用市场访问地址.""" |
| 122 | + application = env.module.application |
| 123 | + market_config, _created = MarketConfig.objects.get_or_create_by_app(application) |
| 124 | + entrance = MarketAvailableAddressHelper(market_config).access_entrance |
| 125 | + url = entrance.address if entrance and entrance.address else "" |
| 126 | + |
| 127 | + return EnvVariableList( |
| 128 | + [ |
| 129 | + EnvVariableObj.with_sys_prefix( |
| 130 | + key="MARKET_ENTRANCE_URL", |
| 131 | + value=url, |
| 132 | + description=_("应用市场访问地址"), |
| 133 | + ) |
| 134 | + ] |
| 135 | + ) |
| 136 | + |
| 137 | + |
117 | 138 | class PreAddresses(NamedTuple): |
118 | 139 | """Preallocated addresses, include both environments""" |
119 | 140 |
|
|
0 commit comments