diff --git a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentFlavor.cs b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentFlavor.cs index f8e52c448a97f9..f98ff5a3226248 100644 --- a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentFlavor.cs +++ b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentFlavor.cs @@ -1,21 +1,29 @@ using System; -using System.Linq; namespace WixSetup.Datadog_Agent { internal static class AgentFlavorFactory { - public static Type[] GetAllAgentFlavors() + private const string FipsFlavor = "fips"; + private const string BaseFlavor = "base"; + + public static string[] GetAllAgentFlavors() { - return typeof(AgentFlavorFactory).Assembly.GetTypes() - .Where(t => typeof(IAgentFlavor).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) - .ToArray(); + return new[] + { + BaseFlavor, + FipsFlavor + }; } public static IAgentFlavor New(AgentVersion agentVersion) { var flavor = Environment.GetEnvironmentVariable("AGENT_FLAVOR"); + return New(flavor, agentVersion); + } + public static IAgentFlavor New(string flavor, AgentVersion agentVersion) + { return flavor switch { "fips" => new FIPSAgent(agentVersion), diff --git a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs index d936f128473160..2b10538d2e3b53 100644 --- a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs +++ b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentInstaller.cs @@ -211,7 +211,7 @@ public Project Configure() // to prevent them from being installed side-by-side. foreach (var flavorType in AgentFlavorFactory.GetAllAgentFlavors()) { - var flavor = (IAgentFlavor)Activator.CreateInstance(flavorType, _agentVersion); + IAgentFlavor flavor = AgentFlavorFactory.New(flavorType, _agentVersion); if (flavor.UpgradeCode == _agentFlavor.UpgradeCode) { continue;