Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/question/build_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (q *BuildSteps) Ask(ctx context.Context) error {
"pip install -r requirements.txt",
)
case models.Yarn, models.Npm:
if answers.Type.Runtime != models.NodeJS {
if answers.Type.Runtime.Type != "nodejs" {
if _, ok := answers.Dependencies["nodejs"]; !ok {
answers.Dependencies["nodejs"] = map[string]string{}
}
Expand Down
17 changes: 13 additions & 4 deletions internal/question/build_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import (
"github.com/platformsh/platformify/internal/question/models"
)

func runtimeByType(t *testing.T, typ string) *models.Runtime {
t.Helper()
r, err := models.Runtimes.RuntimeByType(typ)
if err != nil {
t.Fatalf("runtime %q not found in registry", typ)
}
return r
}

func TestBuildSteps_Ask(t *testing.T) {
type args struct {
answers models.Answers
Expand All @@ -24,7 +33,7 @@ func TestBuildSteps_Ask(t *testing.T) {
q: &BuildSteps{},
args: args{models.Answers{
Stack: models.NextJS,
Type: models.RuntimeType{Runtime: models.NodeJS, Version: "20.0"},
Type: models.RuntimeType{Runtime: runtimeByType(t, "nodejs"), Version: "20.0"},
Dependencies: map[string]map[string]string{},
DependencyManagers: []models.DepManager{models.Yarn},
Environment: map[string]string{},
Expand All @@ -37,7 +46,7 @@ func TestBuildSteps_Ask(t *testing.T) {
q: &BuildSteps{},
args: args{models.Answers{
Stack: models.NextJS,
Type: models.RuntimeType{Runtime: models.NodeJS, Version: "20.0"},
Type: models.RuntimeType{Runtime: runtimeByType(t, "nodejs"), Version: "20.0"},
Dependencies: map[string]map[string]string{},
DependencyManagers: []models.DepManager{models.Npm},
Environment: map[string]string{},
Expand All @@ -50,7 +59,7 @@ func TestBuildSteps_Ask(t *testing.T) {
q: &BuildSteps{},
args: args{models.Answers{
Stack: models.GenericStack,
Type: models.RuntimeType{Runtime: models.Ruby, Version: "3.3"},
Type: models.RuntimeType{Runtime: runtimeByType(t, "ruby"), Version: "3.3"},
Dependencies: map[string]map[string]string{},
DependencyManagers: []models.DepManager{models.Bundler},
Environment: map[string]string{},
Expand All @@ -63,7 +72,7 @@ func TestBuildSteps_Ask(t *testing.T) {
q: &BuildSteps{},
args: args{models.Answers{
Stack: models.Rails,
Type: models.RuntimeType{Runtime: models.Ruby, Version: "3.3"},
Type: models.RuntimeType{Runtime: runtimeByType(t, "ruby"), Version: "3.3"},
Dependencies: map[string]map[string]string{},
DependencyManagers: []models.DepManager{models.Bundler},
Environment: map[string]string{},
Expand Down
2 changes: 1 addition & 1 deletion internal/question/locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (q *Locations) Ask(ctx context.Context) error {
"allow": true,
}
default:
if answers.Type.Runtime == models.PHP {
if answers.Type.Runtime.Type == "php" {
locations := map[string]interface{}{
"passthru": "/index.php",
"root": "",
Expand Down
9 changes: 6 additions & 3 deletions internal/question/models/answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ type Service struct {
}

type RuntimeType struct {
Runtime Runtime
Runtime *Runtime
Version string
}

func (t RuntimeType) String() string {
func (t *RuntimeType) String() string {
if t.Runtime == nil {
return ""
}
if t.Version != "" {
return t.Runtime.String() + ":" + t.Version
}
return t.Runtime.String()
}

func (t RuntimeType) MarshalJSON() ([]byte, error) {
func (t *RuntimeType) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}

Expand Down
288 changes: 0 additions & 288 deletions internal/question/models/generate_versions.go

This file was deleted.

Loading
Loading