Skip to content

Commit

Permalink
Minor code cleanup in FunctionsSyncManager (#9991)
Browse files Browse the repository at this point in the history
Minor code cleanup in FunctionsSyncManager
  • Loading branch information
kshyju authored and RohitRanjanMS committed Apr 12, 2024
1 parent 8c95991 commit 5c59f22
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/WebJobs.Script.WebHost/Management/FunctionsSyncManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ internal static bool IsSyncTriggersEnvironment(IScriptWebHostEnvironment webHost
return true;
}

internal async Task<string> CheckHashAsync(BlobClient hashBlobClient, string content)
private async Task<string> CheckHashAsync(BlobClient hashBlobClient, string content)
{
try
{
Expand Down Expand Up @@ -306,7 +306,7 @@ internal async Task<BlobClient> GetHashBlobAsync()
return _hashBlobClient;
}

public async Task<SyncTriggersPayload> GetSyncTriggersPayload()
private async Task<SyncTriggersPayload> GetSyncTriggersPayload()
{
var hostOptions = _applicationHostOptions.CurrentValue.ToHostOptions();
var functionsMetadata = _functionMetadataManager.GetFunctionMetadata().Where(m => !m.IsProxy());
Expand Down Expand Up @@ -344,7 +344,6 @@ public async Task<SyncTriggersPayload> GetSyncTriggersPayload()
}

// Add all listable functions details to the payload
JObject functions = new JObject();
var listableFunctions = _functionMetadataManager.GetFunctionMetadata().Where(m => !m.IsCodeless());
var functionDetails = await WebFunctionsManager.GetFunctionMetadataResponse(listableFunctions, hostOptions, _hostNameProvider);
result.Add("functions", new JArray(functionDetails.Select(p => JObject.FromObject(p))));
Expand Down Expand Up @@ -468,7 +467,7 @@ internal static async Task<JObject> GetHostJsonExtensionsAsync(IOptionsMonitor<S
return null;
}

internal async Task<IEnumerable<JObject>> GetFunctionTriggers(IEnumerable<FunctionMetadata> functionsMetadata, ScriptJobHostOptions hostOptions)
private async Task<IEnumerable<JObject>> GetFunctionTriggers(IEnumerable<FunctionMetadata> functionsMetadata, ScriptJobHostOptions hostOptions)
{
var triggers = (await functionsMetadata
.Where(f => !f.IsProxy())
Expand Down Expand Up @@ -739,17 +738,13 @@ internal HttpRequestMessage BuildSetTriggersRequest()
// of triggers. It'll verify app ownership using a SWT token valid for 5 minutes. It should be plenty.
private async Task<(bool Success, string ErrorMessage)> SetTriggersAsync(string content)
{
string sanitizedContentString = content;
if (ArmCacheEnabled)
// sanitize the content before logging
var sanitizedContent = JToken.Parse(content);
if (sanitizedContent.Type == JTokenType.Object)
{
// sanitize the content before logging
var sanitizedContent = JToken.Parse(content);
if (sanitizedContent.Type == JTokenType.Object)
{
((JObject)sanitizedContent).Remove("secrets");
sanitizedContentString = sanitizedContent.ToString();
}
((JObject)sanitizedContent).Remove("secrets");
}
var sanitizedContentString = Sanitizer.Sanitize(sanitizedContent.ToString());

using (var request = BuildSetTriggersRequest())
{
Expand Down

0 comments on commit 5c59f22

Please sign in to comment.