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

Commit 227dc68

Browse files
authored
Move all example code under pkg/example (#314)
Signed-off-by: Bill Farner <[email protected]>
1 parent 158549a commit 227dc68

File tree

9 files changed

+23
-27
lines changed

9 files changed

+23
-27
lines changed

pkg/plugin/flavor/swarm/flavor.go renamed to pkg/example/flavor/swarm/flavor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package swarm
1+
package main
22

33
import (
44
"bytes"

pkg/plugin/flavor/swarm/flavor_test.go renamed to pkg/example/flavor/swarm/flavor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package swarm
1+
package main
22

33
import (
44
"encoding/json"

pkg/example/flavor/swarm/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
log "github.com/Sirupsen/logrus"
77
"github.com/docker/go-connections/tlsconfig"
88
"github.com/docker/infrakit/pkg/cli"
9-
"github.com/docker/infrakit/pkg/plugin/flavor/swarm"
109
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
1110
"github.com/docker/infrakit/pkg/util/docker/1.24"
1211
"github.com/spf13/cobra"
@@ -40,7 +39,7 @@ func main() {
4039
return err
4140
}
4241

43-
cli.RunPlugin(*name, flavor_plugin.PluginServer(swarm.NewSwarmFlavor(dockerClient)))
42+
cli.RunPlugin(*name, flavor_plugin.PluginServer(NewSwarmFlavor(dockerClient)))
4443
return nil
4544
}
4645

pkg/plugin/flavor/vanilla/flavor.go renamed to pkg/example/flavor/vanilla/flavor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package vanilla
1+
package main
22

33
import (
44
"encoding/json"

pkg/example/flavor/vanilla/main.go

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

66
log "github.com/Sirupsen/logrus"
77
"github.com/docker/infrakit/pkg/cli"
8-
"github.com/docker/infrakit/pkg/plugin/flavor/vanilla"
98
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
109
"github.com/spf13/cobra"
1110
)
@@ -20,7 +19,7 @@ func main() {
2019
name := cmd.Flags().String("name", "flavor-vanilla", "Plugin name to advertise for discovery")
2120
cmd.Run = func(c *cobra.Command, args []string) {
2221
cli.SetLogLevel(*logLevel)
23-
cli.RunPlugin(*name, flavor_plugin.PluginServer(vanilla.NewPlugin()))
22+
cli.RunPlugin(*name, flavor_plugin.PluginServer(NewPlugin()))
2423
}
2524

2625
cmd.AddCommand(cli.VersionCommand())

pkg/plugin/flavor/zookeeper/flavor.go renamed to pkg/example/flavor/zookeeper/flavor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package zookeeper
1+
package main
22

33
import (
44
"bytes"

pkg/example/flavor/zookeeper/main.go

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

66
log "github.com/Sirupsen/logrus"
77
"github.com/docker/infrakit/pkg/cli"
8-
zk "github.com/docker/infrakit/pkg/plugin/flavor/zookeeper"
98
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
109
"github.com/spf13/cobra"
1110
)
@@ -20,7 +19,7 @@ func main() {
2019
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
2120
cmd.Run = func(c *cobra.Command, args []string) {
2221
cli.SetLogLevel(*logLevel)
23-
cli.RunPlugin(*name, flavor_plugin.PluginServer(zk.NewPlugin()))
22+
cli.RunPlugin(*name, flavor_plugin.PluginServer(NewPlugin()))
2423
}
2524

2625
cmd.AddCommand(cli.VersionCommand())

pkg/plugin/instance/vagrant/instance.go renamed to pkg/example/instance/vagrant/instance.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package vagrant
1+
package main
22

33
import (
44
"bytes"
@@ -14,19 +14,6 @@ import (
1414
"github.com/docker/infrakit/pkg/spi/instance"
1515
)
1616

17-
// VagrantFile is the minimum definition of the vagrant file
18-
const VagrantFile = `
19-
Vagrant.configure("2") do |config|
20-
config.vm.box = "{{.Properties.Box}}"
21-
config.vm.hostname = "infrakit.box"
22-
config.vm.network "private_network"{{.NetworkOptions}}
23-
config.vm.provision :shell, path: "boot.sh"
24-
config.vm.provider :virtualbox do |vb|
25-
vb.memory = {{.Properties.Memory}}
26-
vb.cpus = {{.Properties.CPUs}}
27-
end
28-
end`
29-
3017
// NewVagrantPlugin creates an instance plugin for vagrant.
3118
func NewVagrantPlugin(dir string, template *template.Template) instance.Plugin {
3219
return &vagrantPlugin{VagrantfilesDir: dir, VagrantTmpl: template}

pkg/example/instance/vagrant/main.go

Lines changed: 15 additions & 3 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/cli"
9-
"github.com/docker/infrakit/pkg/plugin/instance/vagrant"
109
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
1110
"github.com/spf13/cobra"
1211
)
@@ -30,7 +29,7 @@ func main() {
3029

3130
var templ *template.Template
3231
if *templFile == "" {
33-
templ = template.Must(template.New("").Parse(vagrant.VagrantFile))
32+
templ = template.Must(template.New("").Parse(VagrantFile))
3433
} else {
3534
var err error
3635
templ, err = template.ParseFiles()
@@ -40,7 +39,7 @@ func main() {
4039
}
4140

4241
cli.SetLogLevel(*logLevel)
43-
cli.RunPlugin(*name, instance_plugin.PluginServer(vagrant.NewVagrantPlugin(*dir, templ)))
42+
cli.RunPlugin(*name, instance_plugin.PluginServer(NewVagrantPlugin(*dir, templ)))
4443
return nil
4544
}
4645

@@ -51,3 +50,16 @@ func main() {
5150
os.Exit(1)
5251
}
5352
}
53+
54+
// VagrantFile is the minimum definition of the vagrant file
55+
const VagrantFile = `
56+
Vagrant.configure("2") do |config|
57+
config.vm.box = "{{.Properties.Box}}"
58+
config.vm.hostname = "infrakit.box"
59+
config.vm.network "private_network"{{.NetworkOptions}}
60+
config.vm.provision :shell, path: "boot.sh"
61+
config.vm.provider :virtualbox do |vb|
62+
vb.memory = {{.Properties.Memory}}
63+
vb.cpus = {{.Properties.CPUs}}
64+
end
65+
end`

0 commit comments

Comments
 (0)