Skip to content

Commit 394822a

Browse files
author
Quentin Perez
committed
Merge pull request #184 from QuentinPerez/fix_#183
support _userdata SEVER KEY=@path/to/file
2 parents 96559dd + 5027ab3 commit 394822a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
11291129

11301130
### master (unreleased)
11311131

1132-
* No entry
1132+
* Support of `scw _userdata name VAR=@/path/to/file` ([#183](https://github.com/scaleway/scaleway-cli/issues/183))
11331133

11341134
View full [commits list](https://github.com/scaleway/scaleway-cli/compare/v1.5.0...master)
11351135

pkg/cli/x_userdata.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cli
66

77
import (
88
"fmt"
9+
"io/ioutil"
910
"strings"
1011

1112
"github.com/scaleway/scaleway-cli/pkg/api"
@@ -82,8 +83,17 @@ func runUserdata(cmd *Command, args []string) error {
8283
default:
8384
value := parts[1]
8485
if value != "" {
86+
var data []byte
8587
// Set userdata
86-
err := Api.PatchUserdata(serverID, key, []byte(value))
88+
if value[0] == '@' {
89+
data, err = ioutil.ReadFile(value[1:])
90+
if err != nil {
91+
return err
92+
}
93+
} else {
94+
data = []byte(value)
95+
}
96+
err := Api.PatchUserdata(serverID, key, data)
8797
if err != nil {
8898
return err
8999
}

0 commit comments

Comments
 (0)