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

Commit 640723b

Browse files
author
David Chung
authored
Migrate stand-alone binaries to built-ins (#693)
Signed-off-by: David Chung <[email protected]>
1 parent 571bf2d commit 640723b

File tree

21 files changed

+419
-365
lines changed

21 files changed

+419
-365
lines changed

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,13 @@ endef
9797

9898

9999
$(call define_binary_target,infrakit,github.com/docker/infrakit/cmd/infrakit)
100-
$(call define_binary_target,infrakit-event-time,github.com/docker/infrakit/examples/event/time)
101-
$(call define_binary_target,infrakit-flavor-combo,github.com/docker/infrakit/examples/flavor/combo)
102100
$(call define_binary_target,infrakit-flavor-kubernetes,github.com/docker/infrakit/examples/flavor/kubernetes)
103101
$(call define_binary_target,infrakit-flavor-swarm,github.com/docker/infrakit/examples/flavor/swarm)
104-
$(call define_binary_target,infrakit-flavor-vanilla,github.com/docker/infrakit/examples/flavor/vanilla)
105102
$(call define_binary_target,infrakit-flavor-zookeeper,github.com/docker/infrakit/examples/flavor/zookeeper)
106103
$(call define_binary_target,infrakit-group-default,github.com/docker/infrakit/cmd/group)
107104
$(call define_binary_target,infrakit-instance-aws,github.com/docker/infrakit/cmd/instance/aws)
108105
$(call define_binary_target,infrakit-instance-digitalocean,github.com/docker/infrakit/cmd/instance/digitalocean)
109106
$(call define_binary_target,infrakit-instance-docker,github.com/docker/infrakit/examples/instance/docker)
110-
$(call define_binary_target,infrakit-instance-file,github.com/docker/infrakit/examples/instance/file)
111107
$(call define_binary_target,infrakit-instance-gcp,github.com/docker/infrakit/cmd/instance/google)
112108
$(call define_binary_target,infrakit-instance-hyperkit,github.com/docker/infrakit/cmd/instance/hyperkit)
113109
$(call define_binary_target,infrakit-instance-image,github.com/docker/infrakit/cmd/instance/image)
@@ -128,17 +124,13 @@ $(call define_binary_target,infrakit-resource,github.com/docker/infrakit/cmd/res
128124

129125
binaries: clean build-binaries
130126
build-binaries: build/infrakit \
131-
build/infrakit-event-time \
132-
build/infrakit-flavor-combo \
133127
build/infrakit-flavor-kubernetes \
134128
build/infrakit-flavor-swarm \
135-
build/infrakit-flavor-vanilla \
136129
build/infrakit-flavor-zookeeper \
137130
build/infrakit-group-default \
138131
build/infrakit-instance-aws \
139132
build/infrakit-instance-digitalocean \
140133
build/infrakit-instance-docker \
141-
build/infrakit-instance-file \
142134
build/infrakit-instance-gcp \
143135
build/infrakit-instance-hyperkit \
144136
build/infrakit-instance-image \

cmd/infrakit/main.go

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

4242
// Supported "kinds"
4343
_ "github.com/docker/infrakit/pkg/run/v0/aws"
44+
_ "github.com/docker/infrakit/pkg/run/v0/combo"
4445
_ "github.com/docker/infrakit/pkg/run/v0/enrollment"
4546
_ "github.com/docker/infrakit/pkg/run/v0/file"
4647
_ "github.com/docker/infrakit/pkg/run/v0/group"

examples/instance/file/README.md renamed to docs/instance/file/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ The plugin can be started without any arguments and will default to using unix s
1414
`~/.infrakit/plugins` for communications with the CLI and other plugins:
1515

1616
```shell
17-
$ build/infrakit-instance-file --dir=./test
18-
INFO[0000] Listening at: ~/.infrakit/plugins/instance-file
17+
$ INFRAKIT_INSTANCE_FILE_DIR=./test build/infrakit plugin start file
18+
INFO[0000] Listening at: ~/.infrakit/plugins/file
1919
```
2020

21-
This starts the plugin using `./test` as directory and `instance-file` as name.
21+
The environment variable `INFRAKIT_INSTANCE_FILE_DIR` sets the directory
22+
used by this plugin instance. This starts the plugin starts up the
23+
plugin listening at socket file `file`.
2224

23-
You can give the another plugin instance a different name via the `listen` flag:
25+
You can give the another plugin instance a different name:
2426
```shell
25-
$ build/infrakit-instance-file --name=another-file --dir=./test
26-
INFO[0000] Listening at: ~/.infrakit/plugins/another-file
27+
$ INFRAKIT_INSTANCE_FILE_DIR=./test2 build/infrakit plugn start file:another
28+
INFO[0000] Listening at: ~/.infrakit/plugins/another
2729
```
2830

2931
Be sure to verify that the plugin is [discoverable](/cmd/infrakit/README.md#list-plugins).
3032

3133
Note that there should be two file instance plugins running now with different names
32-
(`instance-file`, and `another-file`).
34+
(`file`, and `another`).
3335

3436
See the [CLI Doc](/cmd/infrakit/README.md) for details on accessing the instance plugin via CLI.

docs/plugins/flavor/combo/README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
InfraKit Flavor Plugin - Combo
2+
==============================
3+
4+
A [reference](/README.md#reference-implementations) implementation of a Flavor Plugin that supports composition
5+
of other Flavors.
6+
7+
The Combo plugin allows you to use Flavors as mixins, combining their Instance properties:
8+
* `Tags`: combined, with any colliding values determined by the last Plugin to set them
9+
* `Init`: concatenated in the order of the configuration, separated by a newline
10+
* `Attachments`: combined in the order of the configuration
11+
12+
## Schema
13+
14+
Here's a skeleton of this Plugin's schema:
15+
```json
16+
{
17+
"Flavors": []
18+
}
19+
```
20+
21+
A single field, `Flavors`, is supported, which is an array of the Flavors to compose. Each element in the array is the
22+
same structure as how Flavors are used elsewhere:
23+
24+
```json
25+
{
26+
"Plugin": "",
27+
"Properties": {
28+
}
29+
}
30+
```
31+
32+
33+
## Example
34+
35+
To demonstrate how the Combo Flavor plugin works, we will compose two uses of the Vanilla plugin together.
36+
37+
First, start up the plugins we will use:
38+
39+
```shell
40+
$ build/infrakit plugin start group:group combo vanilla simulator
41+
```
42+
This will start up all the plugins running in a single process.
43+
44+
Now in another terminal session:
45+
46+
Your `infrakit` command shows:
47+
48+
```shell
49+
$ infrakit
50+
51+
52+
infrakit command line interface
53+
54+
Usage:
55+
infrakit [command]
56+
57+
Available Commands:
58+
combo Access object combo which implements Flavor/0.1.0
59+
group Access object group which implements Group/0.1.0,Metadata/0.1.0
60+
manager Access the manager
61+
playbook Manage playbooks
62+
plugin Manage plugins
63+
remote Manage remotes
64+
simulator/compute Access object simulator/compute which implements Instance/0.6.0
65+
simulator/disk Access object simulator/disk which implements Instance/0.6.0
66+
simulator/lb1 Access object simulator/lb1 which implements L4/0.6.0
67+
simulator/lb2 Access object simulator/lb2 which implements L4/0.6.0
68+
simulator/lb3 Access object simulator/lb3 which implements L4/0.6.0
69+
simulator/net Access object simulator/net which implements Instance/0.6.0
70+
template Render an infrakit template at given url. If url is '-', read from stdin
71+
up Up everything
72+
util Utilities
73+
vanilla Access object vanilla which implements Flavor/0.1.0
74+
version Print build version information
75+
x Experimental features
76+
```
77+
78+
Check that there are no instances provisioned -- that we are in a clean state:
79+
80+
```shell
81+
$ build/infrakit simulator/compute describe
82+
ID LOGICAL TAGS
83+
$ build/infrakit group ls
84+
ID
85+
```
86+
87+
Using the [example](example.yml) configuration, commit a group:
88+
```shell
89+
$ build/infrakit group commit -y docs/plugins/flavor/combo/example.yml
90+
Committed combo: Managing 2 instances
91+
```
92+
93+
Checking on the group:
94+
95+
```shell
96+
$ build/infrakit group ls combo
97+
ID
98+
combo
99+
$ build/infrakit group describe combo
100+
ID LOGICAL TAGS
101+
1505887656884092558 - infrakit.config_sha=k4kacxuwykbyba6ydi36w6tjwj2c3plw,infrakit.group=combo,v1=tag one,v2=tag two
102+
1505887656884528218 - infrakit.config_sha=k4kacxuwykbyba6ydi36w6tjwj2c3plw,infrakit.group=combo,v1=tag one,v2=tag two
103+
```
104+
105+
Note that now two instances are created and each instance has the tags from
106+
the two chained flavors: `v1: tag one` and `v2: tag two`.
107+
108+
Get the full details of each instance:
109+
110+
```shell
111+
$ build/infrakit simulator/compute describe -pry
112+
- ID: "1505887656884092558"
113+
LogicalID: null
114+
Properties:
115+
Attachments: []
116+
Init: |-
117+
vanilla one
118+
vanilla two
119+
LogicalID: null
120+
Properties:
121+
Note: custom field
122+
Tags:
123+
infrakit.config_sha: k4kacxuwykbyba6ydi36w6tjwj2c3plw
124+
infrakit.group: combo
125+
v1: tag one
126+
v2: tag two
127+
Tags:
128+
infrakit.config_sha: k4kacxuwykbyba6ydi36w6tjwj2c3plw
129+
infrakit.group: combo
130+
v1: tag one
131+
v2: tag two
132+
- ID: "1505887656884528218"
133+
LogicalID: null
134+
Properties:
135+
Attachments: []
136+
Init: |-
137+
vanilla one
138+
vanilla two
139+
LogicalID: null
140+
Properties:
141+
Note: custom field
142+
Tags:
143+
infrakit.config_sha: k4kacxuwykbyba6ydi36w6tjwj2c3plw
144+
infrakit.group: combo
145+
v1: tag one
146+
v2: tag two
147+
Tags:
148+
infrakit.config_sha: k4kacxuwykbyba6ydi36w6tjwj2c3plw
149+
infrakit.group: combo
150+
v1: tag one
151+
v2: tag two
152+
```
153+
154+
Note that the `Init` are also chained together in sequence:
155+
156+
```
157+
- ID: "1505887656884528218"
158+
LogicalID: null
159+
Properties:
160+
Attachments: []
161+
Init: |-
162+
vanilla one # From the first vanilla
163+
vanilla two # From the second vanilla
164+
LogicalID: null
165+
Properties:
166+
Note: custom field
167+
Tags:
168+
infrakit.config_sha: k4kacxuwykbyba6ydi36w6tjwj2c3plw
169+
infrakit.group: combo
170+
v1: tag one
171+
v2: tag two
172+
Tags:
173+
infrakit.config_sha: k4kacxuwykbyba6ydi36w6tjwj2c3plw
174+
infrakit.group: combo
175+
v1: tag one
176+
v2: tag two
177+
```

docs/plugins/flavor/combo/example.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ID: combo
2+
Properties:
3+
Allocation:
4+
Size: 2
5+
Flavor:
6+
# Here we use combo to chain together two vanilla flavors
7+
Plugin: combo
8+
Properties:
9+
Flavors:
10+
- Plugin: vanilla
11+
Properties:
12+
Init:
13+
- vanilla one
14+
Tags:
15+
v1: tag one
16+
- Plugin: vanilla
17+
Properties:
18+
Init:
19+
- vanilla two
20+
Tags:
21+
v2: tag two
22+
Instance:
23+
Plugin: simulator/compute
24+
Properties:
25+
Note: custom field

0 commit comments

Comments
 (0)