Skip to content

Commit f74eb42

Browse files
authored
Add dummy planners for a bunch of languages (#98)
## Summary Add dummy planners for a bunch of languages; for now they are placeholders that don't do anything, but it sets up the whole structure so we can easily start editing them (or the community can contribute by finding the right file). In the process refactored the common types and utility functions used by all planners into a `plansdk`. ## How was it tested? `go test -v ./...`
1 parent 6dc077d commit f74eb42

39 files changed

+843
-156
lines changed

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ package devbox
66
import (
77
"github.com/pkg/errors"
88
"go.jetpack.io/devbox/cuecfg"
9-
"go.jetpack.io/devbox/planner"
9+
"go.jetpack.io/devbox/planner/plansdk"
1010
)
1111

1212
// Config defines a devbox environment as JSON.
1313
type Config struct {
14-
planner.SharedPlan
14+
plansdk.SharedPlan
1515

1616
// Packages is the slice of Nix packages that devbox makes available in
1717
// its environment.

devbox.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"go.jetpack.io/devbox/nix"
1414
"go.jetpack.io/devbox/pkgslice"
1515
"go.jetpack.io/devbox/planner"
16+
"go.jetpack.io/devbox/planner/plansdk"
1617
"golang.org/x/exp/slices"
1718
)
1819

@@ -99,13 +100,13 @@ func (d *Devbox) Build(opts ...docker.BuildOptions) error {
99100

100101
// Plan creates a plan of the actions that devbox will take to generate its
101102
// environment.
102-
func (d *Devbox) Plan() *planner.Plan {
103-
basePlan := &planner.Plan{
103+
func (d *Devbox) Plan() *plansdk.Plan {
104+
basePlan := &plansdk.Plan{
104105
DevPackages: d.cfg.Packages,
105106
RuntimePackages: d.cfg.Packages,
106107
SharedPlan: d.cfg.SharedPlan,
107108
}
108-
return planner.MergePlans(basePlan, planner.GetPlan(d.srcDir))
109+
return plansdk.MergePlans(basePlan, planner.GetPlan(d.srcDir))
109110
}
110111

111112
// Generate creates the directory of Nix files and the Dockerfile that define

devbox_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/bmatcuk/doublestar/v4"
1010
"github.com/stretchr/testify/assert"
11-
"go.jetpack.io/devbox/planner"
11+
"go.jetpack.io/devbox/planner/plansdk"
1212
)
1313

1414
func TestDevboxPlan(t *testing.T) {
@@ -45,7 +45,7 @@ func testIndividualPlan(t *testing.T, testPath string) {
4545
data, err := os.ReadFile(goldenFile)
4646
assert.NoError(err, "plan.json should be readable")
4747

48-
expected := &planner.Plan{}
48+
expected := &plansdk.Plan{}
4949
err = json.Unmarshal(data, &expected)
5050
assert.NoError(err, "plan.json should parse correctly")
5151
expected.Errors = nil

generate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
"github.com/pkg/errors"
1616
"go.jetpack.io/devbox/debug"
17-
"go.jetpack.io/devbox/planner"
17+
"go.jetpack.io/devbox/planner/plansdk"
1818
)
1919

2020
//go:embed tmpl/* tmpl/.*
@@ -23,7 +23,7 @@ var tmplFS embed.FS
2323
var shellFiles = []string{".gitignore", "shell.nix"}
2424
var buildFiles = []string{".gitignore", "development.nix", "runtime.nix", "Dockerfile", "Dockerfile.dockerignore"}
2525

26-
func generate(rootPath string, plan *planner.Plan, files []string) error {
26+
func generate(rootPath string, plan *plansdk.Plan, files []string) error {
2727
outPath := filepath.Join(rootPath, ".devbox/gen")
2828

2929
for _, file := range files {
@@ -36,7 +36,7 @@ func generate(rootPath string, plan *planner.Plan, files []string) error {
3636
return nil
3737
}
3838

39-
func writeFromTemplate(path string, plan *planner.Plan, tmplName string) error {
39+
func writeFromTemplate(path string, plan *plansdk.Plan, tmplName string) error {
4040
embeddedPath := fmt.Sprintf("tmpl/%s.tmpl", tmplName)
4141

4242
// Should we clear the directory so we start "fresh"?

planner/empty/empty_planner.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
// Dummy empty planner. Mainly to serve as a template for how to start a new
5+
// planner.
6+
7+
package empty
8+
9+
import "go.jetpack.io/devbox/planner/plansdk"
10+
11+
type Planner struct{}
12+
13+
// Implements interface Planner (compile-time check)
14+
var _ plansdk.Planner = (*Planner)(nil)
15+
16+
func (p *Planner) Name() string {
17+
return "empty.Planner"
18+
}
19+
20+
func (p *Planner) IsRelevant(srcDir string) bool {
21+
return false
22+
}
23+
24+
func (p *Planner) GetPlan(srcDir string) *plansdk.Plan {
25+
return &plansdk.Plan{}
26+
}

planner/empty_planner.go

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

planner/languages/c/c_planner.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
package c
5+
6+
import (
7+
"go.jetpack.io/devbox/planner/plansdk"
8+
)
9+
10+
type Planner struct{}
11+
12+
// Implements interface Planner (compile-time check)
13+
var _ plansdk.Planner = (*Planner)(nil)
14+
15+
func (p *Planner) Name() string {
16+
return "c.Planner"
17+
}
18+
19+
func (p *Planner) IsRelevant(srcDir string) bool {
20+
return false
21+
}
22+
23+
func (p *Planner) GetPlan(srcDir string) *plansdk.Plan {
24+
return &plansdk.Plan{}
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
package clojure
5+
6+
import "go.jetpack.io/devbox/planner/plansdk"
7+
8+
type Planner struct{}
9+
10+
// Implements interface Planner (compile-time check)
11+
var _ plansdk.Planner = (*Planner)(nil)
12+
13+
func (p *Planner) Name() string {
14+
return "clojure.Planner"
15+
}
16+
17+
func (p *Planner) IsRelevant(srcDir string) bool {
18+
return false
19+
}
20+
21+
func (p *Planner) GetPlan(srcDir string) *plansdk.Plan {
22+
return &plansdk.Plan{}
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
package cplusplus
5+
6+
import (
7+
"go.jetpack.io/devbox/planner/plansdk"
8+
)
9+
10+
type Planner struct{}
11+
12+
// Implements interface Planner (compile-time check)
13+
var _ plansdk.Planner = (*Planner)(nil)
14+
15+
func (p *Planner) Name() string {
16+
return "cplusplus.Planner"
17+
}
18+
19+
func (p *Planner) IsRelevant(srcDir string) bool {
20+
return false
21+
}
22+
23+
func (p *Planner) GetPlan(srcDir string) *plansdk.Plan {
24+
return &plansdk.Plan{}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
package crystal
5+
6+
import (
7+
"go.jetpack.io/devbox/planner/plansdk"
8+
)
9+
10+
type Planner struct{}
11+
12+
// Implements interface Planner (compile-time check)
13+
var _ plansdk.Planner = (*Planner)(nil)
14+
15+
func (p *Planner) Name() string {
16+
return "crystal.Planner"
17+
}
18+
19+
func (p *Planner) IsRelevant(srcDir string) bool {
20+
return false
21+
}
22+
23+
func (p *Planner) GetPlan(srcDir string) *plansdk.Plan {
24+
return &plansdk.Plan{}
25+
}

0 commit comments

Comments
 (0)