Skip to content

Commit

Permalink
add linode-tags for adding Tags to created Linodes
Browse files Browse the repository at this point in the history
  • Loading branch information
displague committed Jan 10, 2019
1 parent 9c16025 commit 1e2d26c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ docker-machine create -d linode --linode-token=<linode-token> --linode-root-pass
| `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*.
| `linode-stackscript-data` | `LINODE_STACKSCRIPT_DATA` | None | A JSON string specifying data that is passed (via UDF) to the selected StackScript.
| `linode-create-private-ip` | `LINODE_CREATE_PRIVATE_IP` | None | A flag specifying to create private IP for the Linode instance.
| `linode-tags` | `LINODE_TAGS` | None | A comma separated list of tags to apply to the the Linode resource
| `linode-ua-prefix` | `LINODE_UA_PREFIX` | None | Prefix the User-Agent in Linode API calls with some 'product/version'

## Notes
Expand Down
12 changes: 12 additions & 0 deletions pkg/drivers/linode/linode.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Driver struct {
StackScriptUser string
StackScriptLabel string
StackScriptData map[string]string

Tags string
}

var (
Expand Down Expand Up @@ -226,6 +228,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: "linode-ua-prefix",
Usage: fmt.Sprintf("Prefix the User-Agent in Linode API calls with some 'product/version'"),
},
mcnflag.StringFlag{
EnvVar: "LINODE_TAGS",
Name: "linode-tags",
Usage: fmt.Sprintf("A comma separated list of tags to apply to the the Linode resource"),
},
}
}

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

d.SetSwarmConfigFromFlags(flags)

Expand Down Expand Up @@ -394,6 +402,10 @@ func (d *Driver) Create() error {
PrivateIP: d.CreatePrivateIP,
}

if d.Tags != "" {
createOpts.Tags = strings.Split(d.Tags, ",")
}

if d.StackScriptID != 0 {
createOpts.StackScriptID = d.StackScriptID
createOpts.StackScriptData = d.StackScriptData
Expand Down

0 comments on commit 1e2d26c

Please sign in to comment.