Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sync triggers #212

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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