Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 29 additions & 18 deletions cmd/infrakit/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,39 @@ func Command(plugins func() discovery.Plugins) *cobra.Command {
cmd := &cobra.Command{
Use: "template <url>",
Short: "Render an infrakit template at given url. If url is '-', read from stdin",
RunE: func(cmd *cobra.Command, args []string) error {
}

if len(args) != 1 {
cmd.Usage()
os.Exit(1)
}
outputFile := cmd.PersistentFlags().StringP("output", "o", "", "Output filename")
cmd.Flags().AddFlagSet(templateFlags)

url := args[0]
if url == "-" {
buff, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
url = fmt.Sprintf("str://%s", string(buff))
}
cmd.RunE = func(cmd *cobra.Command, args []string) error {

view, err := processTemplate(url)
if len(args) != 1 {
cmd.Usage()
os.Exit(1)
}

url := args[0]
if url == "-" {
buff, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
url = fmt.Sprintf("str://%s", string(buff))
}

fmt.Print(view)
return nil
},
view, err := processTemplate(url)
if err != nil {
return err
}

if *outputFile != "" {
return ioutil.WriteFile(*outputFile, []byte(view), 0644)
}

fmt.Print(view)
return nil
}
cmd.Flags().AddFlagSet(templateFlags)

format := &cobra.Command{
Use: "format json|yaml",
Expand Down Expand Up @@ -86,6 +93,10 @@ func Command(plugins func() discovery.Plugins) *cobra.Command {
return err
}

if *outputFile != "" {
return ioutil.WriteFile(*outputFile, buff, 0644)
}

fmt.Print(string(buff))
return nil

Expand Down
5 changes: 4 additions & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# package
github.com/docker/infrakit

github.com/Masterminds/sprig 2.8.0
github.com/Masterminds/sprig 2.10.0
github.com/Masterminds/semver v1.3.0
github.com/Microsoft/go-winio 0.3.6
github.com/Sirupsen/logrus v0.11.0-5-gabc6f20
github.com/aokoli/goutils 1.0.0
Expand All @@ -33,6 +34,7 @@ github.com/golang/protobuf/jsonpb 4bd1920723d7b7c925de087a
github.com/golang/protobuf/proto 4bd1920723d7b7c925de087aa32e2187708897f7
github.com/gorilla/mux 757bef9
github.com/gorilla/rpc 22c016f
github.com/graymeta/stow 0f16e17
github.com/grpc-ecosystem/go-grpc-prometheus v1.1
github.com/grpc-ecosystem/grpc-gateway/runtime 84398b94e188ee336f307779b57b3aa91af7063c
github.com/grpc-ecosystem/grpc-gateway/utilities 84398b94e188ee336f307779b57b3aa91af7063c
Expand Down Expand Up @@ -73,6 +75,7 @@ github.com/stretchr/testify v1.1.4-4-g976c720
github.com/twmb/algoimpl 716f8e7
github.com/vaughan0/go-ini a98ad7e
golang.org/x/crypto/pbkdf2 b07d8c9
golang.org/x/crypto/scrypt aa2481c
golang.org/x/net 0dd7c8d
golang.org/x/sys b699b70
golang.org/x/text a263ba8
Expand Down
25 changes: 25 additions & 0 deletions vendor/github.com/Masterminds/semver/.travis.yml

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

62 changes: 62 additions & 0 deletions vendor/github.com/Masterminds/semver/CHANGELOG.md

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

20 changes: 20 additions & 0 deletions vendor/github.com/Masterminds/semver/LICENSE.txt

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

36 changes: 36 additions & 0 deletions vendor/github.com/Masterminds/semver/Makefile

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

Loading