Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Fix ServiceConfiguration.OneFuzzVersion #2316

Merged
merged 3 commits into from
Aug 30, 2022
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
4 changes: 2 additions & 2 deletions src/ApiService/ApiService/Functions/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public Info(IEndpointAuthorization auth, IOnefuzzContext context) {
var asm = Assembly.GetExecutingAssembly();
var gitVersion = ReadResource(asm, "ApiService.onefuzzlib.git.version");
var buildId = ReadResource(asm, "ApiService.onefuzzlib.build.id");
var versionString = asm.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
var versionString = context.ServiceConfiguration.OneFuzzVersion;

return new InfoResponse(
ResourceGroup: resourceGroup,
Subscription: subscription,
Region: region,
Versions: new Dictionary<string, InfoVersion> { { "onefuzz", new(gitVersion, buildId, versionString ?? "") } },
Versions: new Dictionary<string, InfoVersion> { { "onefuzz", new(gitVersion, buildId, versionString) } },
InstanceId: await _context.Containers.GetInstanceId(),
InsightsAppid: config.ApplicationInsightsAppId,
InsightsInstrumentationKey: config.ApplicationInsightsInstrumentationKey);
Expand Down
20 changes: 18 additions & 2 deletions src/ApiService/ApiService/ServiceConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Microsoft.OneFuzz.Service;
using System.Reflection;

namespace Microsoft.OneFuzz.Service;

public enum LogDestination {
Console,
Expand Down Expand Up @@ -49,6 +51,11 @@ public interface IServiceConfig {

public class ServiceConfiguration : IServiceConfig {

// Version is baked into the assembly by the build process:
private static readonly string? _oneFuzzVersion =
Assembly.GetExecutingAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;

public ServiceConfiguration() {
#if DEBUG
LogDestinations = new LogDestination[] { LogDestination.AppInsights, LogDestination.Console };
Expand Down Expand Up @@ -86,7 +93,16 @@ public ServiceConfiguration() {
public string? OneFuzzOwner { get => Environment.GetEnvironmentVariable("ONEFUZZ_OWNER"); }
public string? OneFuzzResourceGroup { get => Environment.GetEnvironmentVariable("ONEFUZZ_RESOURCE_GROUP"); }
public string? OneFuzzTelemetry { get => Environment.GetEnvironmentVariable("ONEFUZZ_TELEMETRY"); }
public string OneFuzzVersion { get => Environment.GetEnvironmentVariable("ONEFUZZ_VERSION") ?? "0.0.0"; }

public string OneFuzzVersion {
get {
// version can be overridden by config:
return Environment.GetEnvironmentVariable("ONEFUZZ_VERSION")
?? _oneFuzzVersion
?? throw new InvalidOperationException("Unable to read OneFuzz version from assembly");
}
}

public string? OneFuzzAllowOutdatedAgent => Environment.GetEnvironmentVariable("ONEFUZZ_ALLOW_OUTDATED_AGENT");

public string OneFuzzNodeDisposalStrategy { get => Environment.GetEnvironmentVariable("ONEFUZZ_NODE_DISPOSAL_STRATEGY") ?? "scale_in"; }
Expand Down
4 changes: 2 additions & 2 deletions src/ApiService/ApiService/onefuzzlib/ReproOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public interface IReproOperations : IStatefulOrm<Repro, VmState> {
public class ReproOperations : StatefulOrm<Repro, VmState, ReproOperations>, IReproOperations {
private static readonly Dictionary<Os, string> DEFAULT_OS = new()
{
{Os.Linux, "Canonical:UbuntuServer:18.04-LTS:latest"},
{Os.Windows, "MicrosoftWindowsDesktop:Windows-10:20h2-pro:latest"}
{ Os.Linux, "Canonical:UbuntuServer:18.04-LTS:latest" },
{ Os.Windows, "MicrosoftWindowsDesktop:Windows-10:20h2-pro:latest" }
};

const string DEFAULT_SKU = "Standard_DS1_v2";
Expand Down