Skip to content

Commit a1a5092

Browse files
Domas Monkus0x2b3bfa0
andauthored
Separate leo and tpi executables (#662)
* Separate leo and tpi. * Update goreleaser config to build leo and tpi separately. * Add dist to .gitignore. * Use leo name. * Minor Makefile update. * Update machine script. * Update golden files. * Keep terraform-provider-iterative in package root. * Keep using existing tpi release in machine script. * Update golden files. * Address review comments. Co-authored-by: Helio Machado <0x2b3bfa0+git@googlemail.com>
1 parent 5f6b95d commit a1a5092

File tree

14 files changed

+82
-52
lines changed

14 files changed

+82
-52
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ bin
77
/*.tfstate*
88
/crash.log
99

10+
# Build artefacts
11+
/dist
12+
1013
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
1114
# .tfvars files are managed as part of configuration and so should be included in
1215
# version control.

.goreleaser.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
builds:
2-
- env:
2+
-
3+
id: "tpi"
4+
main: ./main.go
5+
env:
36
- CGO_ENABLED=0
47
mod_timestamp: '{{ .CommitTimestamp }}'
58
flags:
69
- -trimpath
710
ldflags:
811
- -s -w
912
- -X terraform-provider-iterative/iterative/utils.Version={{.Version}}
10-
- -X main.version={{.Version}}
11-
- -X main.commit={{.Commit}}
12-
- -X main.date={{.Date}}
1313
goos:
1414
- windows
1515
- linux
@@ -26,14 +26,43 @@ builds:
2626
goarch: arm64
2727
- goos: windows
2828
goarch: arm
29-
binary: '{{ .ProjectName }}_v{{ .Version }}'
29+
binary: 'terraform-provider-iterative'
30+
-
31+
id: "leo"
32+
main: ./cmd/leo
33+
env:
34+
- CGO_ENABLED=0
35+
mod_timestamp: '{{ .CommitTimestamp }}'
36+
flags:
37+
- -trimpath
38+
ldflags:
39+
- -s -w
40+
- -X terraform-provider-iterative/iterative/utils.Version={{.Version}}
41+
goos:
42+
# - freebsd
43+
- windows
44+
- linux
45+
- darwin
46+
goarch:
47+
- amd64
48+
- '386'
49+
- arm
50+
- arm64
51+
ignore:
52+
- goos: darwin
53+
goarch: '386'
54+
- goos: windows
55+
goarch: arm64
56+
- goos: windows
57+
goarch: arm
58+
binary: 'leo'
3059
archives:
3160
- id: default
3261
format: zip
33-
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
62+
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
3463
- id: agent
3564
format: binary
36-
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}'
65+
name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}'
3766
checksum:
3867
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
3968
algorithm: sha256

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ INSTALL_PATH=~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/
99
default: build
1010

1111
build:
12-
go build
12+
go build ./...
1313

14-
install:
15-
GOBIN=${INSTALL_PATH} go install
14+
install_tpi:
15+
GOBIN=${INSTALL_PATH} go install ./...
1616

1717
test:
1818
go test ./... ${TESTARGS} -timeout=30s -parallel=4
File renamed without changes.
File renamed without changes.
File renamed without changes.

cmd/leo/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"os"
5+
)
6+
7+
func main() {
8+
cmd := NewCmd()
9+
err := cmd.Execute()
10+
if err != nil {
11+
os.Exit(1)
12+
}
13+
}
File renamed without changes.

cmd/root.go renamed to cmd/leo/root.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cmd
1+
package main
22

33
import (
44
"fmt"
@@ -11,13 +11,12 @@ import (
1111
"github.com/spf13/pflag"
1212
"github.com/spf13/viper"
1313

14+
"terraform-provider-iterative/cmd/leo/create"
15+
"terraform-provider-iterative/cmd/leo/delete"
16+
"terraform-provider-iterative/cmd/leo/list"
17+
"terraform-provider-iterative/cmd/leo/read"
18+
"terraform-provider-iterative/cmd/leo/stop"
1419
"terraform-provider-iterative/task/common"
15-
16-
"terraform-provider-iterative/cmd/create"
17-
"terraform-provider-iterative/cmd/delete"
18-
"terraform-provider-iterative/cmd/list"
19-
"terraform-provider-iterative/cmd/read"
20-
"terraform-provider-iterative/cmd/stop"
2120
)
2221

2322
type Options struct {
@@ -27,15 +26,8 @@ type Options struct {
2726
common.Cloud
2827
}
2928

30-
func Execute() {
31-
cmd := New()
32-
err := cmd.Execute()
33-
if err != nil {
34-
os.Exit(1)
35-
}
36-
}
37-
38-
func New() *cobra.Command {
29+
// NewCmd initializes the subcommand structure.
30+
func NewCmd() *cobra.Command {
3931
o := Options{
4032
Cloud: common.Cloud{
4133
Timeouts: common.Timeouts{
@@ -48,10 +40,9 @@ func New() *cobra.Command {
4840
}
4941

5042
cmd := &cobra.Command{
51-
Use: "task",
43+
Use: "leo",
5244
Short: "Run code in the cloud",
53-
Long: `Task is a command-line tool that allows
54-
data scientists to run code in the cloud.`,
45+
Long: `leo is a command-line tool that allows data scientists to run code in the cloud.`,
5546
}
5647

5748
cmd.AddCommand(create.New(&o.Cloud))
File renamed without changes.

0 commit comments

Comments
 (0)