mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-17 12:28:07 +00:00
Make the dotnet endpoint and functions configurable in the cli (#2190)
This commit is contained in:
@ -1714,6 +1714,8 @@ class Onefuzz:
|
||||
client_secret: Optional[str] = None,
|
||||
authority: Optional[str] = None,
|
||||
tenant_domain: Optional[str] = None,
|
||||
_dotnet_endpoint: Optional[str] = None,
|
||||
_dotnet_functions: Optional[List[str]] = None,
|
||||
) -> None:
|
||||
|
||||
if endpoint:
|
||||
@ -1726,6 +1728,10 @@ class Onefuzz:
|
||||
self._backend.client_secret = client_secret
|
||||
if tenant_domain is not None:
|
||||
self._backend.config.tenant_domain = tenant_domain
|
||||
if _dotnet_endpoint is not None:
|
||||
self._backend.config.dotnet_endpoint = _dotnet_endpoint
|
||||
if _dotnet_functions is not None:
|
||||
self._backend.config.dotnet_functions = _dotnet_functions
|
||||
|
||||
if self._backend.is_feature_enabled(PreviewFeature.job_templates.name):
|
||||
self.job_templates._load_cache()
|
||||
@ -1769,6 +1775,8 @@ class Onefuzz:
|
||||
client_id: Optional[str] = None,
|
||||
enable_feature: Optional[PreviewFeature] = None,
|
||||
tenant_domain: Optional[str] = None,
|
||||
_dotnet_endpoint: Optional[str] = None,
|
||||
_dotnet_functions: Optional[List[str]] = None,
|
||||
reset: Optional[bool] = None,
|
||||
) -> BackendConfig:
|
||||
"""Configure onefuzz CLI"""
|
||||
@ -1799,6 +1807,10 @@ class Onefuzz:
|
||||
self._backend.enable_feature(enable_feature.name)
|
||||
if tenant_domain is not None:
|
||||
self._backend.config.tenant_domain = tenant_domain
|
||||
if _dotnet_endpoint is not None:
|
||||
self._backend.config.dotnet_endpoint = _dotnet_endpoint
|
||||
if _dotnet_functions is not None:
|
||||
self._backend.config.dotnet_functions = _dotnet_functions
|
||||
self._backend.app = None
|
||||
self._backend.save_config()
|
||||
|
||||
|
@ -92,6 +92,8 @@ class BackendConfig(BaseModel):
|
||||
endpoint: Optional[str]
|
||||
features: Set[str] = Field(default_factory=set)
|
||||
tenant_domain: Optional[str]
|
||||
dotnet_endpoint: Optional[str]
|
||||
dotnet_functions: Optional[List[str]]
|
||||
|
||||
|
||||
class Backend:
|
||||
@ -280,9 +282,15 @@ class Backend:
|
||||
params: Optional[Any] = None,
|
||||
_retry_on_auth_failure: bool = True,
|
||||
) -> Any:
|
||||
if not self.config.endpoint:
|
||||
if self.config.dotnet_functions and path in self.config.dotnet_functions:
|
||||
endpoint = self.config.dotnet_endpoint
|
||||
else:
|
||||
endpoint = self.config.endpoint
|
||||
|
||||
if not endpoint:
|
||||
raise Exception("endpoint not configured")
|
||||
url = self.config.endpoint + "/api/" + path
|
||||
|
||||
url = endpoint + "/api/" + path
|
||||
headers = self.headers()
|
||||
json_data = serialize(json_data)
|
||||
|
||||
|
Reference in New Issue
Block a user