Skip to content

Commit

Permalink
Fix sync triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmelsayed committed May 24, 2021
1 parent d92a89d commit c40536e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
9 changes: 1 addition & 8 deletions Kudu.Core/Functions/SyncTriggerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@ public async Task<string> SyncTriggers(string functionTriggersPayload)

var scaleTriggers = scaleTriggersContent.Item1;
string appName = _environment.K8SEAppName;
string buildNumber = Guid.NewGuid().ToString();
var buildMetadata = new BuildMetadata()
{
AppName = appName,
BuildVersion = buildNumber,
AppSubPath = string.Empty
};

await Task.Run(() => K8SEDeploymentHelper.UpdateFunctionAppTriggers(appName, scaleTriggers, buildMetadata));
await Task.Run(() => K8SEDeploymentHelper.UpdateFunctionAppTriggers(appName, scaleTriggers, null));
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Core/Helpers/SimpleWebTokenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class SimpleWebTokenHelper
Justification = "MemoeryStream, CryptoStream, and BinaryWriter handle multiple disposal correctly. The alternative is pretty ugly code for clearing each variable, checking for null, and manual dispose.")]
public static string Encrypt(string value, byte[] key = null)
{
if (key == null)
if (key == null)placeholder-azure-functions-node12-cm4bl
{
TryGetEncryptionKey(SettingsKeys.AuthEncryptionKey, out key);
}
Expand Down
31 changes: 14 additions & 17 deletions Kudu.Core/K8SE/K8SEDeploymentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static string GetAppKind(HttpContext context)
throw new InvalidOperationException("Couldn't recognize AppKind");
}

return appKind;
return appKind;
}

public static string GetAppNamespace(HttpContext context)
Expand Down Expand Up @@ -214,33 +214,30 @@ public static void UpdateContextWithAppSettings(HttpContext context)

private static string GetFunctionAppPatchJson(IEnumerable<ScaleTrigger> functionTriggers, BuildMetadata buildMetadata)
{
if (functionTriggers == null || !functionTriggers.Any())
if ((functionTriggers == null || !functionTriggers.Any()) && buildMetadata == null)
{
return null;
}

if (buildMetadata == null )
var patchAppJson = new PatchAppJson { PatchSpec = new PatchSpec { } };
if (functionTriggers?.Any() == true)
{
return null;
patchAppJson.PatchSpec.TriggerOptions = new TriggerOptions
{
Triggers = functionTriggers
};
}

var patchAppJson = new PatchAppJson
if (buildMetadata != null)
{
PatchSpec = new PatchSpec
patchAppJson.PatchSpec.Code = new CodeSpec
{
TriggerOptions = new TriggerOptions
{
Triggers = functionTriggers
},
Code = new CodeSpec
PackageRef = new PackageReference
{
PackageRef = new PackageReference
{
BuildMetadata = GetBuildMetadataStr(buildMetadata),
}
BuildMetadata = GetBuildMetadataStr(buildMetadata),
}
}
};
};
}

var str= System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(JsonConvert.SerializeObject(patchAppJson)));
Console.WriteLine("Test Str: " + str);
Expand Down
14 changes: 7 additions & 7 deletions Kudu.Services.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironm


/// <summary>
/// This method gets called by the runtime. It is used to add services
/// This method gets called by the runtime. It is used to add services
/// to the container. It uses the Extension pattern.
/// </summary>
/// <todo>
Expand All @@ -81,7 +81,7 @@ public void ConfigureServices(IServiceCollection services)
{
Console.WriteLine(@"Configure Services : " + DateTime.Now.ToString("hh.mm.ss.ffffff"));
FileSystemHelpers.DeleteDirectorySafe("/home/site/locks/deployment");
// configure basic authentication
// configure basic authentication

services.Configure<FormOptions>(options =>
{
Expand All @@ -92,7 +92,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddRouteAnalyzer();

// Kudu.Services contains all the Controllers
// Kudu.Services contains all the Controllers
var kuduServicesAssembly = Assembly.Load("Kudu.Services");

services.AddMvcCore()
Expand Down Expand Up @@ -234,11 +234,11 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped<ILogger>(KuduWebUtil.GetDeploymentLogger);

services.AddScoped<IDeploymentManager, DeploymentManager>();

services.AddScoped<IFetchDeploymentManager, FetchDeploymentManager>();

services.AddScoped<IScanManager, ScanManager>();

services.AddScoped<ISSHKeyManager, SSHKeyManager>();

services.AddScoped<IRepositoryFactory>(
Expand Down Expand Up @@ -521,7 +521,7 @@ public void Configure(IApplicationBuilder app,
new { controller = "Revision", action = "RedployDeployemnt" },
new { verb = new HttpMethodRouteConstraint("GET") });
// IsDeploying status
// IsDeploying status
routes.MapRoute("is-deployment-underway", "api/isdeploying",
new {controller = "Deployment", action = "IsDeploying"},
new {verb = new HttpMethodRouteConstraint("GET")});
Expand Down Expand Up @@ -679,7 +679,7 @@ private static void ProxyRequestIfRelativeUrlMatches(
private static Func<HttpContext, bool> ContainsRelativeUrl(string relativeUrl, HttpContext httpContext)
{
return x => httpContext.Request.Path.Value.StartsWith(relativeUrl, StringComparison.OrdinalIgnoreCase);
}
}/

// <summary>
// Returns a lambda function that checks if an incoming request object's url path
Expand Down

0 comments on commit c40536e

Please sign in to comment.