Skip to content

Commit

Permalink
Merge pull request #59 from infobloxopen/fixexpand
Browse files Browse the repository at this point in the history
Fix problem with expand option
  • Loading branch information
drewwells authored Jun 8, 2020
2 parents 51fc595 + 2d892ca commit de17086
Show file tree
Hide file tree
Showing 67 changed files with 20,032 additions and 72 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
- docker

go:
- "1.13.x"
- "1.14.x"

env:
global:
Expand All @@ -20,5 +20,4 @@ before_script:
- /tmp/helm init --client-only

script:
- go mod init
- make test-with-integration
27 changes: 0 additions & 27 deletions Gopkg.lock

This file was deleted.

36 changes: 0 additions & 36 deletions Gopkg.toml

This file was deleted.

23 changes: 16 additions & 7 deletions atlas/commands/bootstrap/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bootstrap
import (
"bufio"
"fmt"
"github.com/infobloxopen/atlas-cli/atlas/templates"
"github.com/jinzhu/inflection"
"io"
"log"
Expand Down Expand Up @@ -61,31 +62,31 @@ func expandResource(appName, expandName string, withDatabase bool) error {
}

err = runTemplate(r, appName, withDatabase,
"../atlas/templates/pkg/pb/template.proto.gotmpl",
"templates/pkg/pb/template.proto.gotmpl",
"pkg/pb/"+appName+".proto")

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

err = runTemplate(r, appName, withDatabase,
"../atlas/templates/pkg/svc/servers.gotmpl",
"templates/pkg/svc/servers.gotmpl",
"pkg/svc/servers.go")

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

err = runTemplate(r, appName, withDatabase,
"../atlas/templates/cmd/server/endpoints.gotmpl",
"templates/cmd/server/endpoints.gotmpl",
"cmd/server/endpoints.go")

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

err = runTemplate(r, appName, withDatabase,
"../atlas/templates/cmd/server/servers.gotmpl",
"templates/cmd/server/servers.gotmpl",
"cmd/server/servers.go")

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

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

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

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

if err != nil {
Expand Down Expand Up @@ -171,15 +172,23 @@ func strPlural(s string) string {
func runTemplate(r []templateResource, appName string, expandName bool, src string, dst string) error {
// Create a new template and parse the file into it
name := path.Base(src)
t, err := template.New(name).ParseFiles(src)
t := template.New(name)
bytes, err := templates.Asset(src)
if err != nil {
log.Fatalf("parsing template: %s\n", err)
}
t, err = t.Parse(string(bytes))
if err != nil {
return err
}

// Create Template
f, err := os.Create(dst)
if err != nil {
log.Fatalf("create file %s failed: %s\n", dst, err)
}
defer f.Close()

q := finalTemplate{appName, expandName, r}
err = t.Execute(f, q)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/infobloxopen/atlas-cli

go 1.14

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/iancoleman/strcase/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions vendor/github.com/iancoleman/strcase/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions vendor/github.com/iancoleman/strcase/camel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions vendor/github.com/iancoleman/strcase/numbers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit de17086

Please sign in to comment.