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

Commit 67c52c9

Browse files
authored
Move sources to a top-level pkg/ directory (#299)
Signed-off-by: Bill Farner <[email protected]>
1 parent 0cb698d commit 67c52c9

File tree

115 files changed

+211
-239
lines changed

Some content is hidden

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

115 files changed

+211
-239
lines changed

README.md

+22-32
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ environments while using shared components and consistent interfaces.
2525
_InfraKit_ leverages _Plugins_ to manage arbitrary systems in diverse environments, which can be composed to meet
2626
different needs. Technically, a Plugin is an HTTP server with a well-defined API, listening on a unix socket.
2727

28-
[Utilities](spi/http) are provided as libraries to simplify Plugin development in Go.
28+
[Utilities](pkg/rpc) are provided as libraries to simplify Plugin development in Go.
2929

3030
### Plugin types
3131
#### Group
@@ -43,7 +43,7 @@ Since _InfraKit_ emphasizes on declarative infrastructure, there are no operatio
4343
state to another. Instead, you _declare_ your desired state of the infrastructure. _InfraKit_ is responsible
4444
for converging towards, and maintaining, that desired state.
4545

46-
Therefore, a [group plugin](spi/group/spi.go) manages Groups of Instances and exposes the operations that are of
46+
Therefore, a [group plugin](pkg/spi/group/spi.go) manages Groups of Instances and exposes the operations that are of
4747
interest to a user:
4848

4949
+ commit a group configuration, to start managing a group
@@ -60,7 +60,7 @@ infrastructure management system. This would allow you to use _InfraKit_ toolin
6060
different infrastructure using the same interface.
6161

6262
#### Instance
63-
Instances are members of a group. An [instance plugin](spi/instance/spi.go) manages some physical resource instances.
63+
Instances are members of a group. An [instance plugin](pkg/spi/instance/spi.go) manages some physical resource instances.
6464
It knows only about individual instances and nothing about Groups. Instance is technically defined by the plugin, and
6565
need not be a physical machine at all.
6666

@@ -73,7 +73,7 @@ persistent, stable state. These properties are captured via the _flavors_ of the
7373

7474
#### Flavor
7575
Flavors help distinguish members of one group from another by describing how these members should be treated.
76-
A [flavor plugin](spi/flavor/spi.go) can be thought of as defining what runs on an Instance.
76+
A [flavor plugin](pkg/spi/flavor/spi.go) can be thought of as defining what runs on an Instance.
7777
It is responsible for dictating commands to run services, and check the health of those services.
7878

7979
Flavors allow a group of instances to have different characteristics. In a group of cattle,
@@ -93,12 +93,12 @@ to start a discussion before contributing to these plugins with non-trivial code
9393

9494
| plugin | type | description |
9595
|:---------------------------------------------------|:---------|:----------------------------------------|
96-
| [swarm](example/flavor/swarm) | flavor | runs Docker in Swarm mode |
97-
| [vanilla](example/flavor/vanilla) | flavor | manual specification of instance fields |
98-
| [zookeeper](example/flavor/zookeeper) | flavor | run an Apache ZooKeeper ensemble |
99-
| [infrakit/file](example/instance/file) | instance | useful for development and testing |
100-
| [infrakit/terraform](example/instance/terraform) | instance | creates instances using Terraform |
101-
| [infrakit/vagrant](example/instance/vagrant) | instance | creates Vagrant VMs |
96+
| [swarm](pkg/example/flavor/swarm) | flavor | runs Docker in Swarm mode |
97+
| [vanilla](pkg/example/flavor/vanilla) | flavor | manual specification of instance fields |
98+
| [zookeeper](pkg/example/flavor/zookeeper) | flavor | run an Apache ZooKeeper ensemble |
99+
| [infrakit/file](pkg/example/instance/file) | instance | useful for development and testing |
100+
| [infrakit/terraform](pkg/example/instance/terraform) | instance | creates instances using Terraform |
101+
| [infrakit/vagrant](pkg/example/instance/vagrant) | instance | creates Vagrant VMs |
102102

103103

104104
#### Supported implementations
@@ -154,32 +154,22 @@ $ make binaries
154154
```
155155
Executables will be placed in the `./build` directory.
156156
This will produce binaries for tools and several reference Plugin implementations:
157-
+ [`infrakit`](./cmd/cli/README.md): a command line interface to interact with plugins
158-
+ [`infrakit-group-default`](./cmd/group/README.md): the default [Group plugin](./spi/group)
159-
+ [`infrakit-instance-file`](./example/instance/file): an Instance plugin using dummy files to represent instances
160-
+ [`infrakit-instance-terraform`](./example/instance/terraform):
157+
+ [`infrakit`](cmd/cli/README.md): a command line interface to interact with plugins
158+
+ [`infrakit-group-default`](cmd/group/README.md): the default [Group plugin](./spi/group)
159+
+ [`infrakit-instance-file`](pkg/example/instance/file): an Instance plugin using dummy files to represent instances
160+
+ [`infrakit-instance-terraform`](pkg/example/instance/terraform):
161161
an Instance plugin integrating [Terraform](https://www.terraform.io)
162-
+ [`infrakit-instance-vagrant`](./example/instance/vagrant):
162+
+ [`infrakit-instance-vagrant`](pkg/example/instance/vagrant):
163163
an Instance plugin using [Vagrant](https://www.vagrantup.com/)
164-
+ [`infrakit-flavor-vanilla`](./example/flavor/vanilla):
164+
+ [`infrakit-flavor-vanilla`](pkg/example/flavor/vanilla):
165165
a Flavor plugin for plain vanilla set up with user data and labels
166-
+ [`infrakit-flavor-zookeeper`](./example/flavor/zookeeper):
166+
+ [`infrakit-flavor-zookeeper`](pkg/example/flavor/zookeeper):
167167
a Flavor plugin for [Apache ZooKeeper](https://zookeeper.apache.org/) ensemble members
168-
+ [`infrakit-flavor-swarm`](./example/flavor/swarm):
168+
+ [`infrakit-flavor-swarm`](pkg/example/flavor/swarm):
169169
a Flavor plugin for Docker in [Swarm mode](https://docs.docker.com/engine/swarm/).
170170

171171
All provided binaries have a `help` sub-command to get usage and a `version` sub-command to identify the build revision.
172172

173-
## Examples
174-
There are a few examples of _InfraKit_ plugins:
175-
176-
+ Terraform Instance Plugin
177-
- [README](./example/instance/terraform/README.md)
178-
- [Code] (./example/instance/terraform/plugin.go) and [configs](./example/instance/terraform/aws-two-tier)
179-
+ Zookeeper / Vagrant
180-
- [README](./example/flavor/zookeeper/README.md)
181-
- [Code] (./plugin/flavor/zookeeper)
182-
183173

184174
# Design
185175

@@ -200,10 +190,10 @@ A common pattern for a JSON object looks like this:
200190

201191
There is only one `Properties` field in this JSON and its value is a JSON object. The opaque
202192
JSON value for `Properties` is decoded via the Go `Spec` struct defined within the package of the plugin --
203-
for example -- [`vanilla.Spec`](/plugin/flavor/vanilla/flavor.go).
193+
for example -- [`vanilla.Spec`](pkg/plugin/flavor/vanilla/flavor.go).
204194

205195
The JSON above is a _value_, but the type of the value belongs outside the structure. For example, the
206-
default Group [Spec](/plugin/group/types/types.go) is composed of an Instance plugin, a Flavor plugin, and an
196+
default Group [Spec](pkg/plugin/group/types/types.go) is composed of an Instance plugin, a Flavor plugin, and an
207197
Allocation:
208198

209199
```json
@@ -305,7 +295,7 @@ The CLI shows which plugins are [discoverable](cmd/cli/README.md#list-plugins).
305295

306296
## Docs
307297

308-
Design docs can be found [here](./docs).
298+
Additional documentation can be found [here](docs).
309299

310300
## Reporting security issues
311301

@@ -327,7 +317,7 @@ _InfraKit_ is currently focused on supporting setup and management of base infra
327317
orchestrator. The image below illustrates an architecture we are working towards supporting - a Docker cluster in Swarm
328318
mode.
329319

330-
![arch image](images/arch.png)
320+
![arch image](docs/images/arch.png)
331321

332322
This configuration co-locates _InfraKit_ with Swarm manager nodes and offers high availability of _InfraKit_ itself and
333323
Swarm managers (using attached storage). _InfraKit_ is shown managing two groups - managers and workers that will be

cmd/cli/flavor.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"strings"
99

1010
log "github.com/Sirupsen/logrus"
11-
"github.com/docker/infrakit/discovery"
12-
"github.com/docker/infrakit/plugin/group/types"
13-
flavor_plugin "github.com/docker/infrakit/rpc/flavor"
14-
"github.com/docker/infrakit/spi/flavor"
15-
"github.com/docker/infrakit/spi/instance"
11+
"github.com/docker/infrakit/pkg/discovery"
12+
"github.com/docker/infrakit/pkg/plugin/group/types"
13+
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
14+
"github.com/docker/infrakit/pkg/spi/flavor"
15+
"github.com/docker/infrakit/pkg/spi/instance"
1616
"github.com/spf13/cobra"
1717
)
1818

cmd/cli/group.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"strings"
1010

1111
log "github.com/Sirupsen/logrus"
12-
"github.com/docker/infrakit/discovery"
13-
group_plugin "github.com/docker/infrakit/rpc/group"
14-
"github.com/docker/infrakit/spi/group"
12+
"github.com/docker/infrakit/pkg/discovery"
13+
group_plugin "github.com/docker/infrakit/pkg/rpc/group"
14+
"github.com/docker/infrakit/pkg/spi/group"
1515
"github.com/spf13/cobra"
1616
)
1717

cmd/cli/instance.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"strings"
1010

1111
log "github.com/Sirupsen/logrus"
12-
"github.com/docker/infrakit/discovery"
13-
instance_plugin "github.com/docker/infrakit/rpc/instance"
14-
"github.com/docker/infrakit/spi/instance"
12+
"github.com/docker/infrakit/pkg/discovery"
13+
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
14+
"github.com/docker/infrakit/pkg/spi/instance"
1515
"github.com/spf13/cobra"
1616
)
1717

cmd/cli/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"os"
66

77
log "github.com/Sirupsen/logrus"
8-
"github.com/docker/infrakit/cli"
9-
"github.com/docker/infrakit/discovery"
8+
"github.com/docker/infrakit/pkg/cli"
9+
"github.com/docker/infrakit/pkg/discovery"
1010
"github.com/spf13/cobra"
1111
)
1212

cmd/cli/plugin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/docker/infrakit/discovery"
5+
"github.com/docker/infrakit/pkg/discovery"
66
"github.com/spf13/cobra"
77
)
88

cmd/group/main.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import (
55
"time"
66

77
log "github.com/Sirupsen/logrus"
8-
"github.com/docker/infrakit/cli"
9-
"github.com/docker/infrakit/discovery"
10-
"github.com/docker/infrakit/plugin/group"
11-
flavor_client "github.com/docker/infrakit/rpc/flavor"
12-
group_server "github.com/docker/infrakit/rpc/group"
13-
instance_client "github.com/docker/infrakit/rpc/instance"
14-
"github.com/docker/infrakit/spi/flavor"
15-
"github.com/docker/infrakit/spi/instance"
8+
"github.com/docker/infrakit/pkg/cli"
9+
"github.com/docker/infrakit/pkg/discovery"
10+
"github.com/docker/infrakit/pkg/plugin/group"
11+
flavor_client "github.com/docker/infrakit/pkg/rpc/flavor"
12+
group_server "github.com/docker/infrakit/pkg/rpc/group"
13+
instance_client "github.com/docker/infrakit/pkg/rpc/instance"
14+
"github.com/docker/infrakit/pkg/spi/flavor"
15+
"github.com/docker/infrakit/pkg/spi/instance"
1616
"github.com/spf13/cobra"
1717
)
1818

cmd/manager/main.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"path/filepath"
66

77
log "github.com/Sirupsen/logrus"
8-
"github.com/docker/infrakit/cli"
9-
"github.com/docker/infrakit/discovery"
10-
"github.com/docker/infrakit/leader"
11-
"github.com/docker/infrakit/manager"
12-
group_rpc "github.com/docker/infrakit/rpc/group"
13-
"github.com/docker/infrakit/store"
8+
"github.com/docker/infrakit/pkg/cli"
9+
"github.com/docker/infrakit/pkg/discovery"
10+
"github.com/docker/infrakit/pkg/leader"
11+
"github.com/docker/infrakit/pkg/manager"
12+
group_rpc "github.com/docker/infrakit/pkg/rpc/group"
13+
"github.com/docker/infrakit/pkg/store"
1414
"github.com/spf13/cobra"
1515
)
1616

cmd/manager/os.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"path/filepath"
77
"time"
88

9-
"github.com/docker/infrakit/discovery"
10-
file_leader "github.com/docker/infrakit/leader/file"
11-
file_store "github.com/docker/infrakit/store/file"
9+
"github.com/docker/infrakit/pkg/discovery"
10+
file_leader "github.com/docker/infrakit/pkg/leader/file"
11+
file_store "github.com/docker/infrakit/pkg/store/file"
1212
"github.com/spf13/cobra"
1313
)
1414

cmd/manager/swarm.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55

66
log "github.com/Sirupsen/logrus"
77
"github.com/docker/go-connections/tlsconfig"
8-
"github.com/docker/infrakit/discovery"
9-
swarm_leader "github.com/docker/infrakit/leader/swarm"
10-
swarm_store "github.com/docker/infrakit/store/swarm"
11-
"github.com/docker/infrakit/util/docker/1.24"
8+
"github.com/docker/infrakit/pkg/discovery"
9+
swarm_leader "github.com/docker/infrakit/pkg/leader/swarm"
10+
swarm_store "github.com/docker/infrakit/pkg/store/swarm"
11+
"github.com/docker/infrakit/pkg/util/docker/1.24"
1212
"github.com/spf13/cobra"
1313
)
1414

File renamed without changes.

docs/tutorial.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ Now we must create the JSON for a group. You will find that the JSON structures
6262

6363
This defines the name of the `Plugin` to use and the `Properties` to configure it with. The plugins are free to define
6464
their own configuration schema. Plugins in this repository follow a convention of using a `Spec` Go struct to define
65-
the `Properties` schema for each plugin. The [`group.Spec`](/plugin/group/types/types.go) in the default Group plugin,
66-
and [`vanilla.Spec`](/plugin/flavor/vanilla/flavor.go) are examples of this pattern.
65+
the `Properties` schema for each plugin. The [`group.Spec`](../pkg/plugin/group/types/types.go) in the default Group plugin,
66+
and [`vanilla.Spec`](../pkg/plugin/flavor/vanilla/flavor.go) are examples of this pattern.
6767

6868
From listing the plugins earlier, we have two plugins running. `instance-file` is the name of the File Instance Plugin,
6969
and `flavor-vanilla` is the name of the Vanilla Flavor Plugin.
File renamed without changes.

cli/serverutil.go renamed to pkg/cli/serverutil.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"path"
55

66
log "github.com/Sirupsen/logrus"
7-
"github.com/docker/infrakit/discovery"
8-
"github.com/docker/infrakit/rpc/server"
7+
"github.com/docker/infrakit/pkg/discovery"
8+
"github.com/docker/infrakit/pkg/rpc/server"
99
)
1010

1111
// RunPlugin runs a plugin server, advertising with the provided name for discovery.
File renamed without changes.

discovery/dir.go renamed to pkg/discovery/dir.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"sync"
99

1010
log "github.com/Sirupsen/logrus"
11-
"github.com/docker/infrakit/plugin"
11+
"github.com/docker/infrakit/pkg/plugin"
1212
)
1313

1414
type dirPluginDiscovery struct {

discovery/dir_test.go renamed to pkg/discovery/dir_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"testing"
88
"time"
99

10-
rpc "github.com/docker/infrakit/rpc/instance"
11-
"github.com/docker/infrakit/rpc/server"
10+
rpc "github.com/docker/infrakit/pkg/rpc/instance"
11+
"github.com/docker/infrakit/pkg/rpc/server"
1212
"github.com/stretchr/testify/require"
1313
)
1414

discovery/discovery.go renamed to pkg/discovery/discovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os/user"
77
"path"
88

9-
"github.com/docker/infrakit/plugin"
9+
"github.com/docker/infrakit/pkg/plugin"
1010
)
1111

1212
// Plugins provides access to plugin discovery.
File renamed without changes.

example/flavor/combo/README.md renamed to pkg/example/flavor/combo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
InfraKit Flavor Plugin - Combo
22
==============================
33

4-
A [reference](../../../README.md#reference-implementations) implementation of a Flavor Plugin that supports composition
4+
A [reference](/README.md#reference-implementations) implementation of a Flavor Plugin that supports composition
55
of other Flavors.
66

77
The Combo plugin allows you to use Flavors as mixins, combining their Instance properties:

example/flavor/combo/flavor.go renamed to pkg/example/flavor/combo/flavor.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package main
33
import (
44
"encoding/json"
55
"errors"
6-
"github.com/docker/infrakit/plugin/group"
7-
"github.com/docker/infrakit/plugin/group/types"
8-
"github.com/docker/infrakit/spi/flavor"
9-
"github.com/docker/infrakit/spi/instance"
6+
"github.com/docker/infrakit/pkg/plugin/group"
7+
"github.com/docker/infrakit/pkg/plugin/group/types"
8+
"github.com/docker/infrakit/pkg/spi/flavor"
9+
"github.com/docker/infrakit/pkg/spi/instance"
1010
"strings"
1111
)
1212

example/flavor/combo/flavor_test.go renamed to pkg/example/flavor/combo/flavor_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package main
33
import (
44
"encoding/json"
55
"errors"
6-
mock_flavor "github.com/docker/infrakit/mock/spi/flavor"
7-
"github.com/docker/infrakit/plugin/group"
8-
"github.com/docker/infrakit/plugin/group/types"
9-
"github.com/docker/infrakit/spi/flavor"
10-
"github.com/docker/infrakit/spi/instance"
6+
mock_flavor "github.com/docker/infrakit/pkg/mock/spi/flavor"
7+
"github.com/docker/infrakit/pkg/plugin/group"
8+
"github.com/docker/infrakit/pkg/plugin/group/types"
9+
"github.com/docker/infrakit/pkg/spi/flavor"
10+
"github.com/docker/infrakit/pkg/spi/instance"
1111
"github.com/golang/mock/gomock"
1212
"github.com/stretchr/testify/require"
1313
"testing"

example/flavor/combo/main.go renamed to pkg/example/flavor/combo/main.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"os"
55

66
log "github.com/Sirupsen/logrus"
7-
"github.com/docker/infrakit/cli"
8-
"github.com/docker/infrakit/discovery"
9-
flavor_rpc "github.com/docker/infrakit/rpc/flavor"
10-
"github.com/docker/infrakit/spi/flavor"
7+
"github.com/docker/infrakit/pkg/cli"
8+
"github.com/docker/infrakit/pkg/discovery"
9+
flavor_rpc "github.com/docker/infrakit/pkg/rpc/flavor"
10+
"github.com/docker/infrakit/pkg/spi/flavor"
1111
"github.com/spf13/cobra"
1212
)
1313

example/flavor/swarm/README.md renamed to pkg/example/flavor/swarm/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
InfraKit Flavor Plugin - Swarm
22
==============================
33

4-
A [reference](../../../README.md#reference-implementations) implementation of a Flavor Plugin that creates a Docker
4+
A [reference](/README.md#reference-implementations) implementation of a Flavor Plugin that creates a Docker
55
cluster in [Swarm Mode](https://docs.docker.com/engine/swarm/).
66

77

@@ -24,7 +24,7 @@ The supported fields are:
2424

2525
## Example
2626

27-
Begin by building plugin [binaries](../../../README.md#binaries).
27+
Begin by building plugin [binaries](/README.md#binaries).
2828

2929
### Security
3030

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55

66
log "github.com/Sirupsen/logrus"
77
"github.com/docker/go-connections/tlsconfig"
8-
"github.com/docker/infrakit/cli"
9-
"github.com/docker/infrakit/plugin/flavor/swarm"
10-
flavor_plugin "github.com/docker/infrakit/rpc/flavor"
11-
"github.com/docker/infrakit/util/docker/1.24"
8+
"github.com/docker/infrakit/pkg/cli"
9+
"github.com/docker/infrakit/pkg/plugin/flavor/swarm"
10+
flavor_plugin "github.com/docker/infrakit/pkg/rpc/flavor"
11+
"github.com/docker/infrakit/pkg/util/docker/1.24"
1212
"github.com/spf13/cobra"
1313
)
1414

0 commit comments

Comments
 (0)