Skip to content

Commit eada720

Browse files
committed
support base64-encoded user data
1 parent 6f80d1e commit eada720

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ check "hashistack-allocated-cpu" {
6767

6868
- `snapshot_id` `(string: <required>)` - The Droplet image ID.
6969

70-
- `user_data` `(string: "")` - A string of the desired User Data for the Droplet or a path to a file containing the User Data
70+
- `user_data` `(string: "")` - A (raw or base64-encoded) string of the desired User Data for the Droplet,
71+
or a path to a file containing the User Data
7172

7273
- `ssh_keys` `(string: "")` - A comma-separated list of SSH fingerprints to enable
7374

plugin/digitalocean.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"context"
5+
"encoding/base64"
56
"errors"
67
"fmt"
78
"io"
@@ -117,8 +118,14 @@ func (t *TargetPlugin) scaleOut(
117118
// file was found at this location, so use its content
118119
createRequest.UserData = string(content)
119120
} else {
120-
// assume the string contains the user data
121-
createRequest.UserData = template.userData
121+
// assume the string contains the user data, which
122+
// maybe be base64-encoded
123+
decodedData, err := base64.StdEncoding.DecodeString(template.userData)
124+
if err == nil {
125+
createRequest.UserData = string(decodedData)
126+
} else {
127+
createRequest.UserData = template.userData
128+
}
122129
}
123130
}
124131

0 commit comments

Comments
 (0)