Skip to content

Commit c63d4c9

Browse files
bart-vmwareTimHess
andauthored
Turn off version checks, translate Spring-style wildcards (#100)
* Update staging settings, fix broken test * when deploying, use env.SLOT_NAME instead of vars.STAGING_SLOT_NAME --------- Co-authored-by: Tim Hess <[email protected]>
1 parent a5131d2 commit c63d4c9

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

.github/workflows/build-and-stage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
with:
101101
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
102102
package: '.'
103-
slot-name: ${{ vars.STAGING_SLOT_NAME }}
103+
slot-name: ${{ env.SLOT_NAME }}
104104

105105
- name: If PR, comment with the preview link
106106
if: ${{ github.event_name == 'pull_request' }}

src/InitializrService/Controllers/ProjectController.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ public async Task<ActionResult> GetProjectArchive([FromQuery] ProjectSpec spec)
7373
Dependencies = spec.Dependencies ?? defaults?.Dependencies?.Default,
7474
};
7575

76-
if (new ReleaseRange("3.0.0").Accepts(normalizedSpec.SteeltoeVersion)
77-
&& !new ReleaseRange("netcoreapp3.1").Accepts(normalizedSpec.DotNetFramework))
78-
{
79-
return NotFound(
80-
$".NET framework version {normalizedSpec.DotNetFramework} not found for Steeltoe version {normalizedSpec.SteeltoeVersion}");
81-
}
82-
8376
if (normalizedSpec.Dependencies != null)
8477
{
8578
var deps = normalizedSpec.Dependencies.Split(',');
@@ -95,19 +88,25 @@ public async Task<ActionResult> GetProjectArchive([FromQuery] ProjectSpec spec)
9588
continue;
9689
}
9790

91+
// This is effectively unreachable. InitializrWeb filters out incompatible dependencies.
92+
/*
9893
var steeltoeRange = new ReleaseRange(dep.SteeltoeVersionRange);
9994
if (!steeltoeRange.Accepts(normalizedSpec.SteeltoeVersion))
10095
{
10196
return NotFound(
10297
$"No dependency '{deps[i]}' found for Steeltoe version {normalizedSpec.SteeltoeVersion}.");
10398
}
99+
*/
104100

101+
// This is effectively unreachable. InitializrWeb filters out incompatible dependencies.
102+
/*
105103
var frameworkRange = new ReleaseRange(dep.DotNetFrameworkRange);
106104
if (!frameworkRange.Accepts(normalizedSpec.DotNetFramework))
107105
{
108106
return NotFound(
109107
$"No dependency '{deps[i]}' found for .NET framework {normalizedSpec.DotNetFramework}.");
110108
}
109+
*/
111110

112111
deps[i] = dep.Id;
113112
found = true;
@@ -133,6 +132,10 @@ public async Task<ActionResult> GetProjectArchive([FromQuery] ProjectSpec spec)
133132
Logger.LogInformation("Project specification: {ProjectSpec}", normalizedSpec);
134133
try
135134
{
135+
// Translate Spring-style wildcard 'x' to NuGet-style wildcard '*'.
136+
// See https://docs.spring.io/initializr/docs/current-SNAPSHOT/reference/html/#dependencies-compatibility-range.
137+
normalizedSpec.SteeltoeVersion = normalizedSpec.SteeltoeVersion.Replace('x', '*');
138+
136139
var projectPackage = await _projectGenerator.GenerateProjectArchive(normalizedSpec);
137140
return File(
138141
projectPackage,

src/InitializrService/Controllers/RootController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ from dependency in @group.Values
9797
{
9898
dependency.Id,
9999
dependency.Description,
100-
new ReleaseRange(dependency.SteeltoeVersionRange).ToPrettyString(),
101-
new ReleaseRange(dependency.DotNetFrameworkRange).ToPrettyString(),
100+
dependency.SteeltoeVersionRange ?? string.Empty,
101+
dependency.DotNetFrameworkRange ?? string.Empty,
102102
});
103103

104104
help.AddRange(ToTable(table));

test/InitializrService.Test.Unit/Controllers/ProjectControllerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public async Task Null_Archive_Format_Should_Return_500_Internal_Server_Error()
185185
result.Value.Should().Be("Default packaging not configured.");
186186
}
187187

188-
[Fact]
188+
[Fact(Skip = "This is effectively unreachable. InitilizrWeb filters out incompatible dependencies.")]
189189
public async Task Unsupported_Steeltoe_Version_Should_Return_404_NotFound()
190190
{
191191
// Arrange
@@ -230,7 +230,7 @@ public async Task Unsupported_Steeltoe_Version_Should_Return_404_NotFound()
230230
result.Value.ToString().Should().Be("No dependency 'mydep' found for Steeltoe version 0.0.");
231231
}
232232

233-
[Fact]
233+
[Fact(Skip = "This is effectively unreachable. InitilizrWeb filters out incompatible dependencies.")]
234234
public async Task Unsupported_DotNet_Framework_Should_Return_404_NotFound()
235235
{
236236
// Arrange

test/InitializrService.Test.Unit/Controllers/RootControllerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void Get_Should_Return_Help()
119119
help.Should().MatchRegex(@"\|\s+Id\s+\|\s+Description\s+\|\s+Steeltoe Version\s+\|\s+.NET Framework\s+\|");
120120
help.Should().MatchRegex(@"\|\s+dep1\s+\|\s+DependencyOne\s+\|\s+\|");
121121
help.Should().MatchRegex(@"\|\s+dep2\s+\|\s+DependencyTwo\s+\|\s+\|");
122-
help.Should().MatchRegex(@"\|\s+anotherdep\s+\|\s+AnotherDependency\s+\|\s+>=1.0 and <1.9\s+\|\s+>=2.0\s+\|");
122+
help.Should().MatchRegex(@"\|\s+anotherdep\s+\|\s+AnotherDependency\s+\|\s+\[1\.0,1\.9\)\s+\|\s+2.0\s+\|");
123123
}
124124

125125
/* ----------------------------------------------------------------- *

0 commit comments

Comments
 (0)