From 85273a7b3c020d377541b4d3b2c2d39e86efafd9 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Thu, 4 Apr 2019 17:16:45 -0700 Subject: [PATCH] remove warning for kafka extension --- .../FunctionJsonConverter.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs b/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs index b41359a..865afc6 100644 --- a/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs +++ b/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs @@ -21,6 +21,12 @@ namespace MakeFunctionJson "host.json" }; + private static readonly IEnumerable _triggersWithoutStorage = new[] + { + "httptrigger", + "kafkatrigger" + }; + internal FunctionJsonConverter(ILogger logger, string assemblyPath, string outputPath, IEnumerable excludedFunctionNames = null) { if (logger == null) @@ -194,16 +200,17 @@ namespace MakeFunctionJson { // FirstOrDefault returns a KeyValuePair which is a struct so it can't be null. var azureWebJobsStorage = values.FirstOrDefault(pair => pair.Key.Equals("AzureWebJobsStorage", StringComparison.OrdinalIgnoreCase)).Value; - var isHttpTrigger = functionJson + var allWithoutStorageTriggers = functionJson .Bindings .Where(b => b["type"] != null) .Select(b => b["type"].ToString()) - .Where(b => b.IndexOf("Trigger") != -1) - .Any(t => t == "httpTrigger"); + .Where(b => b.IndexOf("Trigger", StringComparison.OrdinalIgnoreCase) != -1) + .All(t => _triggersWithoutStorage.Any(tws => tws.Equals(t, StringComparison.OrdinalIgnoreCase))); - if (string.IsNullOrWhiteSpace(azureWebJobsStorage) && !isHttpTrigger) + if (string.IsNullOrWhiteSpace(azureWebJobsStorage) && !allWithoutStorageTriggers) { - _logger.LogWarning($"Function [{functionName}]: Missing value for AzureWebJobsStorage in {settingsFileName}. This is required for all triggers other than HTTP."); + _logger.LogWarning($"Function [{functionName}]: Missing value for AzureWebJobsStorage in {settingsFileName}. " + + $"This is required for all triggers other than {string.Join(", ", _triggersWithoutStorage)}."); } foreach (var binding in functionJson.Bindings)