Skip to content

Commit 1e2d26c

Browse files
committed
add linode-tags for adding Tags to created Linodes
1 parent 9c16025 commit 1e2d26c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ docker-machine create -d linode --linode-token=<linode-token> --linode-root-pass
6464
| `linode-stackscript` | `LINODE_STACKSCRIPT` | None | Specifies the Linode StackScript to use to create the instance, either by numeric ID, or using the form *username*/*label*.
6565
| `linode-stackscript-data` | `LINODE_STACKSCRIPT_DATA` | None | A JSON string specifying data that is passed (via UDF) to the selected StackScript.
6666
| `linode-create-private-ip` | `LINODE_CREATE_PRIVATE_IP` | None | A flag specifying to create private IP for the Linode instance.
67+
| `linode-tags` | `LINODE_TAGS` | None | A comma separated list of tags to apply to the the Linode resource
6768
| `linode-ua-prefix` | `LINODE_UA_PREFIX` | None | Prefix the User-Agent in Linode API calls with some 'product/version'
6869

6970
## Notes

pkg/drivers/linode/linode.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type Driver struct {
4949
StackScriptUser string
5050
StackScriptLabel string
5151
StackScriptData map[string]string
52+
53+
Tags string
5254
}
5355

5456
var (
@@ -226,6 +228,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
226228
Name: "linode-ua-prefix",
227229
Usage: fmt.Sprintf("Prefix the User-Agent in Linode API calls with some 'product/version'"),
228230
},
231+
mcnflag.StringFlag{
232+
EnvVar: "LINODE_TAGS",
233+
Name: "linode-tags",
234+
Usage: fmt.Sprintf("A comma separated list of tags to apply to the the Linode resource"),
235+
},
229236
}
230237
}
231238

@@ -267,6 +274,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
267274
d.DockerPort = flags.Int("linode-docker-port")
268275
d.CreatePrivateIP = flags.Bool("linode-create-private-ip")
269276
d.UserAgentPrefix = flags.String("linode-ua-prefix")
277+
d.Tags = flags.String("linode-tags")
270278

271279
d.SetSwarmConfigFromFlags(flags)
272280

@@ -394,6 +402,10 @@ func (d *Driver) Create() error {
394402
PrivateIP: d.CreatePrivateIP,
395403
}
396404

405+
if d.Tags != "" {
406+
createOpts.Tags = strings.Split(d.Tags, ",")
407+
}
408+
397409
if d.StackScriptID != 0 {
398410
createOpts.StackScriptID = d.StackScriptID
399411
createOpts.StackScriptData = d.StackScriptData

0 commit comments

Comments
 (0)