-
Notifications
You must be signed in to change notification settings - Fork 1
/
detect.go
48 lines (43 loc) · 1.2 KB
/
detect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package dotnetcoreaspnetruntime
import (
"github.com/paketo-buildpacks/packit/v2"
)
type Environment struct {
DotnetRollForward string `env:"BP_DOTNET_ROLL_FORWARD"`
DotnetFrameworkVersion string `env:"BP_DOTNET_FRAMEWORK_VERSION"`
}
func Detect(environment Environment) packit.DetectFunc {
return func(context packit.DetectContext) (packit.DetectResult, error) {
var requirements []packit.BuildPlanRequirement
if environment.DotnetFrameworkVersion != "" {
requirements = append(requirements, packit.BuildPlanRequirement{
Name: "dotnet-core-aspnet-runtime",
Metadata: map[string]interface{}{
"version-source": "BP_DOTNET_FRAMEWORK_VERSION",
"version": environment.DotnetFrameworkVersion,
},
})
}
return packit.DetectResult{
Plan: packit.BuildPlan{
Provides: []packit.BuildPlanProvision{
{Name: "dotnet-core-aspnet-runtime"},
},
Requires: requirements,
Or: []packit.BuildPlan{
{
Provides: []packit.BuildPlanProvision{
{Name: "dotnet-runtime"},
},
},
{
Provides: []packit.BuildPlanProvision{
{Name: "dotnet-runtime"},
{Name: "dotnet-aspnetcore"},
},
},
},
},
}, nil
}
}