|
| 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 | +``` |
0 commit comments