Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit be78504

Browse files
author
David Chung
authored
template clean up (#447)
Signed-off-by: David Chung <[email protected]>
1 parent 606cbb9 commit be78504

File tree

14 files changed

+75
-76
lines changed

14 files changed

+75
-76
lines changed

cmd/cli/event.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
log "github.com/Sirupsen/logrus"
88
"github.com/docker/infrakit/pkg/discovery"
9-
"github.com/docker/infrakit/pkg/discovery/local"
109
metadata_template "github.com/docker/infrakit/pkg/plugin/metadata/template"
1110
"github.com/docker/infrakit/pkg/rpc/client"
1211
event_rpc "github.com/docker/infrakit/pkg/rpc/event"
@@ -193,9 +192,7 @@ func eventCommand(plugins func() discovery.Plugins) *cobra.Command {
193192
RunE: func(c *cobra.Command, args []string) error {
194193

195194
log.Infof("Using %v for rendering view.", templateURL)
196-
engine, err := template.NewTemplate(templateURL, template.Options{
197-
SocketDir: local.Dir(),
198-
})
195+
engine, err := template.NewTemplate(templateURL, template.Options{})
199196
if err != nil {
200197
return err
201198
}

cmd/cli/manager.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
log "github.com/Sirupsen/logrus"
88
"github.com/docker/infrakit/pkg/discovery"
9-
"github.com/docker/infrakit/pkg/discovery/local"
109
"github.com/docker/infrakit/pkg/manager"
1110
"github.com/docker/infrakit/pkg/plugin"
1211
metadata_template "github.com/docker/infrakit/pkg/plugin/metadata/template"
@@ -87,9 +86,7 @@ func managerCommand(plugins func() discovery.Plugins) *cobra.Command {
8786
templateURL := args[0]
8887

8988
log.Infof("Using %v for reading template\n", templateURL)
90-
engine, err := template.NewTemplate(templateURL, template.Options{
91-
SocketDir: local.Dir(),
92-
})
89+
engine, err := template.NewTemplate(templateURL, template.Options{})
9390
if err != nil {
9491
return err
9592
}

cmd/cli/plugin.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
log "github.com/Sirupsen/logrus"
1313
"github.com/docker/infrakit/pkg/discovery"
14-
"github.com/docker/infrakit/pkg/discovery/local"
1514
"github.com/docker/infrakit/pkg/launch"
1615
"github.com/docker/infrakit/pkg/launch/os"
1716
"github.com/docker/infrakit/pkg/plugin"
@@ -59,9 +58,7 @@ func pluginCommand(plugins func() discovery.Plugins) *cobra.Command {
5958

6059
start.RunE = func(c *cobra.Command, args []string) error {
6160

62-
configTemplate, err := template.NewTemplate(*configURL, template.Options{
63-
SocketDir: local.Dir(),
64-
})
61+
configTemplate, err := template.NewTemplate(*configURL, template.Options{})
6562
if err != nil {
6663
return err
6764
}

cmd/cli/resource.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
log "github.com/Sirupsen/logrus"
88
"github.com/docker/infrakit/pkg/discovery"
9-
"github.com/docker/infrakit/pkg/discovery/local"
109
"github.com/docker/infrakit/pkg/plugin"
1110
resource_plugin "github.com/docker/infrakit/pkg/rpc/resource"
1211
"github.com/docker/infrakit/pkg/spi/resource"
@@ -139,9 +138,7 @@ func resourcePluginCommand(plugins func() discovery.Plugins) *cobra.Command {
139138

140139
func readSpecFromTemplateURL(templateURL string) (*resource.Spec, error) {
141140
log.Infof("Reading template from %v", templateURL)
142-
engine, err := template.NewTemplate(templateURL, template.Options{
143-
SocketDir: local.Dir(),
144-
})
141+
engine, err := template.NewTemplate(templateURL, template.Options{})
145142
if err != nil {
146143
return nil, err
147144
}

cmd/cli/template.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
log "github.com/Sirupsen/logrus"
88
"github.com/docker/infrakit/pkg/discovery"
9-
"github.com/docker/infrakit/pkg/discovery/local"
109
metadata_template "github.com/docker/infrakit/pkg/plugin/metadata/template"
1110
"github.com/docker/infrakit/pkg/template"
1211
"github.com/spf13/cobra"
@@ -22,9 +21,7 @@ func templateCommand(plugins func() discovery.Plugins) *cobra.Command {
2221
RunE: func(cmd *cobra.Command, args []string) error {
2322

2423
log.Infof("Using %v for reading template\n", templateURL)
25-
engine, err := template.NewTemplate(templateURL, template.Options{
26-
SocketDir: local.Dir(),
27-
})
24+
engine, err := template.NewTemplate(templateURL, template.Options{})
2825
if err != nil {
2926
return err
3027
}

examples/flavor/swarm/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ func init() {
2424
})
2525
}
2626

27-
var defaultTemplateOptions = template.Options{
28-
SocketDir: local.Dir(),
29-
}
27+
var defaultTemplateOptions = template.Options{}
3028

3129
func main() {
3230

examples/instance/vagrant/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
log "github.com/Sirupsen/logrus"
99
"github.com/docker/infrakit/pkg/cli"
10-
"github.com/docker/infrakit/pkg/discovery/local"
1110
"github.com/docker/infrakit/pkg/plugin/metadata"
1211
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
1312
metadata_plugin "github.com/docker/infrakit/pkg/rpc/metadata"
@@ -33,9 +32,7 @@ func main() {
3332
templFile := cmd.Flags().String("template", "", "Vagrant Template file, in URL form")
3433
cmd.RunE = func(c *cobra.Command, args []string) error {
3534

36-
opts := template.Options{
37-
SocketDir: local.Dir(),
38-
}
35+
opts := template.Options{}
3936

4037
var templ *template.Template
4138
if *templFile == "" {

pkg/discovery/discovery_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package discovery
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestErrNotUnixSocket(t *testing.T) {
10+
err := ErrNotUnixSocket("no socket!")
11+
require.Error(t, err)
12+
require.True(t, IsErrNotUnixSocket(err))
13+
}

pkg/plugin/resource/plugin.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"strings"
88

99
log "github.com/Sirupsen/logrus"
10-
"github.com/docker/infrakit/pkg/discovery/local"
1110
plugin_base "github.com/docker/infrakit/pkg/plugin"
1211
"github.com/docker/infrakit/pkg/spi/instance"
1312
"github.com/docker/infrakit/pkg/spi/resource"
@@ -76,7 +75,7 @@ func (p *plugin) Commit(config resource.Spec, pretend bool) (string, error) {
7675
continue
7776
}
7877

79-
template, err := template.NewTemplate("str://"+resourceConfigs[name].properties, template.Options{SocketDir: local.Dir()})
78+
template, err := template.NewTemplate("str://"+resourceConfigs[name].properties, template.Options{})
8079
if err != nil {
8180
return "", fmt.Errorf("Failed to parse template '%s' for resource '%s': %s", resourceConfigs[name].properties, name, err)
8281
}
@@ -272,7 +271,7 @@ func getProvisioningOrder(resourceConfigs map[string]resourceConfig) ([]string,
272271
}
273272

274273
for name, resourceConfig := range resourceConfigs {
275-
template, err := template.NewTemplate("str://"+resourceConfig.properties, template.Options{SocketDir: local.Dir()})
274+
template, err := template.NewTemplate("str://"+resourceConfig.properties, template.Options{})
276275
if err != nil {
277276
return nil, fmt.Errorf("Failed to parse template for resource '%s': %s", name, err)
278277
}

pkg/plugin/resource/plugin_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"reflect"
88
"testing"
99

10-
"github.com/docker/infrakit/pkg/discovery/local"
1110
plugin_base "github.com/docker/infrakit/pkg/plugin"
1211
"github.com/docker/infrakit/pkg/plugin/group/util"
1312
"github.com/docker/infrakit/pkg/spi/instance"
@@ -377,7 +376,7 @@ func TestGetProvisioningOrder(t *testing.T) {
377376

378377
func TestGetResourceDependencies(t *testing.T) {
379378
newTemplate := func(s string) *template.Template {
380-
t, err := template.NewTemplate("str://"+s, template.Options{SocketDir: local.Dir()})
379+
t, err := template.NewTemplate("str://"+s, template.Options{})
381380
if err != nil {
382381
panic(err)
383382
}

0 commit comments

Comments
 (0)