Skip to content

Commit 80de8ed

Browse files
Andrei SalanovichAndrei Salanovich
authored andcommitted
#352: make PS version 7 as a default for all new and updated scripts
1 parent 4f45d14 commit 80de8ed

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

src/Dorc.ApiModel/PowerShellVersion.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,7 @@ public static string ToVersionString(this PowerShellVersion version)
2323
}
2424
}
2525

26-
public static PowerShellVersion FromVersionString(string versionString)
27-
{
28-
switch (versionString)
29-
{
30-
case "v5.1":
31-
return PowerShellVersion.V5_1;
32-
case "v7":
33-
return PowerShellVersion.V7;
34-
default:
35-
throw new ArgumentException($"Unknown PowerShell version: {versionString}", nameof(versionString));
36-
}
37-
}
38-
39-
public static PowerShellVersion? TryFromVersionString(string versionString)
26+
public static PowerShellVersion? FromVersionString(string versionString)
4027
{
4128
if (string.IsNullOrEmpty(versionString))
4229
return null;

src/Dorc.PersistentData/Sources/ManageProjectsPersistentSource.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ public void CreateComponent(ComponentApiModel apiComponent, int projectId, int?
311311
Name = apiComponent.ComponentName,
312312
Path = apiComponent.ScriptPath,
313313
NonProdOnly = apiComponent.NonProdOnly,
314-
IsPathJSON = IsScriptPathJson(apiComponent.ScriptPath)
314+
IsPathJSON = IsScriptPathJson(apiComponent.ScriptPath),
315+
PowerShellVersionNumber = PowerShellVersion.V7.ToVersionString()
315316
};
316317

317318
component.Script = script;
@@ -370,7 +371,8 @@ public void UpdateComponent(ComponentApiModel apiComponent, int projectId, int?
370371
Name = apiComponent.ComponentName,
371372
Path = apiComponent.ScriptPath,
372373
NonProdOnly = apiComponent.NonProdOnly,
373-
IsPathJSON = IsScriptPathJson(apiComponent.ScriptPath)
374+
IsPathJSON = IsScriptPathJson(apiComponent.ScriptPath),
375+
PowerShellVersionNumber = PowerShellVersion.V7.ToVersionString()
374376
};
375377
component.Script = script;
376378
}

src/Dorc.PersistentData/Sources/ScriptsPersistentSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public bool UpdateScript(ScriptApiModel script, IPrincipal user)
141141
foundScript.Path = script.Path;
142142
foundScript.NonProdOnly = script.NonProdOnly;
143143
foundScript.IsPathJSON = script.IsPathJSON;
144-
foundScript.PowerShellVersionNumber = script.PowerShellVersionNumber;
144+
foundScript.PowerShellVersionNumber = string.IsNullOrEmpty(script.PowerShellVersionNumber) ? PowerShellVersion.V7.ToVersionString() : script.PowerShellVersionNumber;
145145
foreach (var scriptComponent in foundScript.Components)
146146
{
147147
scriptComponent.IsEnabled = script.IsEnabled;

0 commit comments

Comments
 (0)