Skip to content

Commit de17086

Browse files
authored
Merge pull request #59 from infobloxopen/fixexpand
Fix problem with expand option
2 parents 51fc595 + 2d892ca commit de17086

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+20032
-72
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
- docker
55

66
go:
7-
- "1.13.x"
7+
- "1.14.x"
88

99
env:
1010
global:
@@ -20,5 +20,4 @@ before_script:
2020
- /tmp/helm init --client-only
2121

2222
script:
23-
- go mod init
2423
- make test-with-integration

Gopkg.lock

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

Gopkg.toml

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

atlas/commands/bootstrap/expand.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bootstrap
33
import (
44
"bufio"
55
"fmt"
6+
"github.com/infobloxopen/atlas-cli/atlas/templates"
67
"github.com/jinzhu/inflection"
78
"io"
89
"log"
@@ -61,31 +62,31 @@ func expandResource(appName, expandName string, withDatabase bool) error {
6162
}
6263

6364
err = runTemplate(r, appName, withDatabase,
64-
"../atlas/templates/pkg/pb/template.proto.gotmpl",
65+
"templates/pkg/pb/template.proto.gotmpl",
6566
"pkg/pb/"+appName+".proto")
6667

6768
if err != nil {
6869
log.Fatalf("failed to create pkg/pb/"+appName+".proto\n%s\n", err)
6970
}
7071

7172
err = runTemplate(r, appName, withDatabase,
72-
"../atlas/templates/pkg/svc/servers.gotmpl",
73+
"templates/pkg/svc/servers.gotmpl",
7374
"pkg/svc/servers.go")
7475

7576
if err != nil {
7677
log.Fatalf("failed to create pkg/pb/servers.go\n%s\n", err)
7778
}
7879

7980
err = runTemplate(r, appName, withDatabase,
80-
"../atlas/templates/cmd/server/endpoints.gotmpl",
81+
"templates/cmd/server/endpoints.gotmpl",
8182
"cmd/server/endpoints.go")
8283

8384
if err != nil {
8485
log.Fatalf("failed to create cmd/server/endpoints.go\n%s\n", err)
8586
}
8687

8788
err = runTemplate(r, appName, withDatabase,
88-
"../atlas/templates/cmd/server/servers.gotmpl",
89+
"templates/cmd/server/servers.gotmpl",
8990
"cmd/server/servers.go")
9091

9192
if err != nil {
@@ -96,15 +97,15 @@ func expandResource(appName, expandName string, withDatabase bool) error {
9697

9798
for _, res := range r {
9899
err = runTemplate([]templateResource{res}, appName, withDatabase,
99-
"../atlas/templates/db/migration/down.sql.gotmpl",
100+
"templates/db/migration/down.sql.gotmpl",
100101
"db/migration/"+res.MigrateVer+"_"+res.NameSnakes+".down.sql")
101102

102103
if err != nil {
103104
log.Fatalf("failed to create db/migration/"+res.MigrateVer+"_"+res.NameSnakes+".down.sql\n%s\n", err)
104105
}
105106

106107
err = runTemplate([]templateResource{res}, appName, withDatabase,
107-
"../atlas/templates/db/migration/up.sql.gotmpl",
108+
"templates/db/migration/up.sql.gotmpl",
108109
"db/migration/"+res.MigrateVer+"_"+res.NameSnakes+".up.sql")
109110

110111
if err != nil {
@@ -171,15 +172,23 @@ func strPlural(s string) string {
171172
func runTemplate(r []templateResource, appName string, expandName bool, src string, dst string) error {
172173
// Create a new template and parse the file into it
173174
name := path.Base(src)
174-
t, err := template.New(name).ParseFiles(src)
175+
t := template.New(name)
176+
bytes, err := templates.Asset(src)
175177
if err != nil {
176178
log.Fatalf("parsing template: %s\n", err)
177179
}
180+
t, err = t.Parse(string(bytes))
181+
if err != nil {
182+
return err
183+
}
184+
178185
// Create Template
179186
f, err := os.Create(dst)
180187
if err != nil {
181188
log.Fatalf("create file %s failed: %s\n", dst, err)
182189
}
190+
defer f.Close()
191+
183192
q := finalTemplate{appName, expandName, r}
184193
err = t.Execute(f, q)
185194
if err != nil {

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/infobloxopen/atlas-cli
2+
3+
go 1.14
4+
5+
require (
6+
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
7+
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7
8+
github.com/jinzhu/inflection v1.0.0
9+
golang.org/x/tools v0.0.0-20200528185414-6be401e3f76e
10+
)

go.sum

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
github.com/go-bindata/go-bindata v1.0.0 h1:DZ34txDXWn1DyWa+vQf7V9ANc2ILTtrEjtlsdJRF26M=
2+
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
3+
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7 h1:ux/56T2xqZO/3cP1I2F86qpeoYPCOzk+KF/UH/Ar+lk=
4+
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
5+
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
6+
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
7+
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
8+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
9+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
10+
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
11+
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
12+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
13+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
14+
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
15+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
16+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
17+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
18+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
19+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
20+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
21+
golang.org/x/tools v0.0.0-20200528185414-6be401e3f76e h1:jTL1CJ2kmavapMVdBKy6oVrhBHByRCMfykS45+lEFQk=
22+
golang.org/x/tools v0.0.0-20200528185414-6be401e3f76e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
23+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
24+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
25+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
26+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

vendor/github.com/iancoleman/strcase/.travis.yml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/iancoleman/strcase/LICENSE

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/iancoleman/strcase/README.md

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/iancoleman/strcase/camel.go

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)