Skip to content

Commit 3ecdd6e

Browse files
ForestEckhardtForest Eckhardt
authored andcommitted
Makes changes needed for 1.0 release
1 parent c6ed78a commit 3ecdd6e

15 files changed

Lines changed: 7 additions & 588 deletions

build.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"regexp"
99
"time"
1010

11-
"github.com/Masterminds/semver"
1211
"github.com/paketo-buildpacks/packit/v2"
1312
"github.com/paketo-buildpacks/packit/v2/cargo"
1413
"github.com/paketo-buildpacks/packit/v2/chronos"
@@ -86,40 +85,15 @@ func Build(
8685

8786
logger.Process("Resolving ASP.NET Core Runtime version")
8887

89-
// Convert dotnet-runtime and dotnet-aspnetcore BuildpackPlanEntries into
90-
// dotnet-core-aspnet-runtime entries and then print a warning
91-
var warn bool
92-
for i := range context.Plan.Entries {
93-
if context.Plan.Entries[i].Name == "dotnet-runtime" || context.Plan.Entries[i].Name == "dotnet-aspnetcore" {
94-
warn = true
95-
context.Plan.Entries[i].Name = "dotnet-core-aspnet-runtime"
96-
}
97-
}
98-
99-
if warn {
100-
nextMajorVersion := semver.MustParse(context.BuildpackInfo.Version).IncMajor()
101-
logger.Subprocess("WARNING: Requiring dotnet-runtime or dotnet-aspnetcore in your build plan will be deprecated soon in .NET Core Buildpack v%s.", nextMajorVersion.String())
102-
logger.Subprocess("Please require dotnet-core-aspnet-runtime in your build plan going forward.")
103-
logger.Break()
104-
}
105-
10688
priorities := []interface{}{
10789
"BP_DOTNET_FRAMEWORK_VERSION",
108-
"buildpack.yml",
10990
"runtimeconfig.json",
11091
regexp.MustCompile(`.*\.(cs)|(fs)|(vb)proj`),
11192
}
93+
11294
entry, sortedEntries := entries.Resolve("dotnet-core-aspnet-runtime", context.Plan.Entries, priorities)
11395
logger.Candidates(sortedEntries)
11496

115-
source, _ := entry.Metadata["version-source"].(string)
116-
if source == "buildpack.yml" {
117-
nextMajorVersion := semver.MustParse(context.BuildpackInfo.Version).IncMajor()
118-
logger.Subprocess("WARNING: Setting the .NET Framework version through buildpack.yml will be deprecated soon in .NET Core ASP.NET Core Runtime Buildpack v%s.", nextMajorVersion.String())
119-
logger.Subprocess("Please specify the version through the $BP_DOTNET_FRAMEWORK_VERSION environment variable instead. See docs for more information.")
120-
logger.Break()
121-
}
122-
12397
dependency, err := versionResolver.Resolve(filepath.Join(context.CNBPath, "buildpack.toml"), entry, context.Stack)
12498
if err != nil {
12599
return packit.BuildResult{}, err

build_test.go

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -370,116 +370,6 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
370370
})
371371
})
372372

373-
context("when the backwards compatible api is being used", func() {
374-
it("returns a result that installs the dotnet aspnet runtime libraries and prints a warning", func() {
375-
result, err := build(packit.BuildContext{
376-
WorkingDir: workingDir,
377-
CNBPath: cnbDir,
378-
Stack: "some-stack",
379-
BuildpackInfo: packit.BuildpackInfo{
380-
Name: "Some Buildpack",
381-
Version: "1.2.3",
382-
SBOMFormats: []string{sbom.CycloneDXFormat, sbom.SPDXFormat},
383-
},
384-
Platform: packit.Platform{Path: "platform"},
385-
Plan: packit.BuildpackPlan{
386-
Entries: []packit.BuildpackPlanEntry{
387-
{
388-
Name: "dotnet-runtime",
389-
Metadata: map[string]interface{}{
390-
"version-source": "BP_DOTNET_FRAMEWORK_VERSION",
391-
"version": "2.5.x",
392-
"launch": true,
393-
},
394-
},
395-
{
396-
Name: "dotnet-aspnetcore",
397-
Metadata: map[string]interface{}{
398-
"launch": true,
399-
},
400-
},
401-
},
402-
},
403-
Layers: packit.Layers{Path: layersDir},
404-
})
405-
Expect(err).NotTo(HaveOccurred())
406-
407-
Expect(result.Layers).To(HaveLen(1))
408-
layer := result.Layers[0]
409-
410-
Expect(layer.Name).To(Equal("dotnet-core-aspnet-runtime"))
411-
Expect(layer.Path).To(Equal(filepath.Join(layersDir, "dotnet-core-aspnet-runtime")))
412-
413-
Expect(entryResolver.ResolveCall.Receives.BuildpackPlanEntrySlice).To(Equal([]packit.BuildpackPlanEntry{
414-
{
415-
Name: "dotnet-core-aspnet-runtime",
416-
Metadata: map[string]interface{}{
417-
"version": "some-version",
418-
"version-source": "runtimeconfig.json",
419-
},
420-
},
421-
{
422-
Name: "dotnet-core-aspnet-runtime",
423-
Metadata: map[string]interface{}{
424-
"version-source": "BP_DOTNET_FRAMEWORK_VERSION",
425-
"version": "2.5.x",
426-
"launch": true,
427-
},
428-
},
429-
{
430-
Name: "dotnet-core-aspnet-runtime",
431-
Metadata: map[string]interface{}{
432-
"launch": true,
433-
},
434-
},
435-
}))
436-
437-
Expect(buffer.String()).To(ContainSubstring("WARNING: Requiring dotnet-runtime or dotnet-aspnetcore in your build plan will be deprecated soon in .NET Core Buildpack v2.0.0."))
438-
Expect(buffer.String()).To(ContainSubstring("Please require dotnet-core-aspnet-runtime in your build plan going forward."))
439-
})
440-
})
441-
442-
context("when version-source of the selected entry is buildpack.yml", func() {
443-
it.Before(func() {
444-
entryResolver.ResolveCall.Returns.BuildpackPlanEntry = packit.BuildpackPlanEntry{
445-
Name: "dotnet-core-aspnet-runtime",
446-
Metadata: map[string]interface{}{
447-
"version-source": "buildpack.yml",
448-
"version": "2.5.x",
449-
"launch": true,
450-
},
451-
}
452-
})
453-
454-
it("chooses the specified version and emits a warning", func() {
455-
_, err := build(packit.BuildContext{
456-
WorkingDir: workingDir,
457-
CNBPath: cnbDir,
458-
Stack: "some-stack",
459-
BuildpackInfo: packit.BuildpackInfo{
460-
Name: "Some Buildpack",
461-
Version: "1.2.3",
462-
},
463-
Plan: packit.BuildpackPlan{
464-
Entries: []packit.BuildpackPlanEntry{
465-
{
466-
Name: "dotnet-core-aspnet-runtime",
467-
Metadata: map[string]interface{}{
468-
"version-source": "buildpack.yml",
469-
"version": "2.5.x",
470-
},
471-
},
472-
},
473-
},
474-
Layers: packit.Layers{Path: layersDir},
475-
})
476-
Expect(err).NotTo(HaveOccurred())
477-
478-
Expect(buffer.String()).To(ContainSubstring("WARNING: Setting the .NET Framework version through buildpack.yml will be deprecated soon in .NET Core ASP.NET Core Runtime Buildpack v2.0.0."))
479-
Expect(buffer.String()).To(ContainSubstring("Please specify the version through the $BP_DOTNET_FRAMEWORK_VERSION environment variable instead. See docs for more information."))
480-
})
481-
})
482-
483373
context("failure cases", func() {
484374
context("when the config parser fails", func() {
485375
it.Before(func() {

buildpack_yml_parser.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

buildpack_yml_parser_test.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

detect.go

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
package dotnetcoreaspnetruntime
22

33
import (
4-
"path/filepath"
5-
64
"github.com/paketo-buildpacks/packit/v2"
75
)
86

9-
//go:generate faux --interface VersionParser --output fakes/version_parser.go
10-
type VersionParser interface {
11-
ParseVersion(path string) (version string, err error)
12-
}
13-
147
type Environment struct {
158
DotnetRollForward string `env:"BP_DOTNET_ROLL_FORWARD"`
169
DotnetFrameworkVersion string `env:"BP_DOTNET_FRAMEWORK_VERSION"`
1710
}
1811

19-
func Detect(environment Environment, versionParser VersionParser) packit.DetectFunc {
12+
func Detect(environment Environment) packit.DetectFunc {
2013
return func(context packit.DetectContext) (packit.DetectResult, error) {
2114
var requirements []packit.BuildPlanRequirement
2215

@@ -30,22 +23,6 @@ func Detect(environment Environment, versionParser VersionParser) packit.DetectF
3023
})
3124
}
3225

33-
// check if the version is set in the buildpack.yml
34-
version, err := versionParser.ParseVersion(filepath.Join(context.WorkingDir, "buildpack.yml"))
35-
if err != nil {
36-
return packit.DetectResult{}, err
37-
}
38-
39-
if version != "" {
40-
requirements = append(requirements, packit.BuildPlanRequirement{
41-
Name: "dotnet-core-aspnet-runtime",
42-
Metadata: map[string]interface{}{
43-
"version-source": "buildpack.yml",
44-
"version": version,
45-
},
46-
})
47-
}
48-
4926
return packit.DetectResult{
5027
Plan: packit.BuildPlan{
5128
Provides: []packit.BuildPlanProvision{

0 commit comments

Comments
 (0)