fix: support multiple SSH keys
This commit is contained in:
parent
f1386b5cf7
commit
c35e78fe3f
|
@ -6,11 +6,13 @@
|
|||
import "coopcloud.tech/libcapsul"
|
||||
```
|
||||
|
||||
Package libcapsul provides Capsul operations functionality\.
|
||||
|
||||
## Index
|
||||
|
||||
- [type CapsulClient](<#type-capsulclient>)
|
||||
- [func New(instanceURL, APIToken string) CapsulClient](<#func-new>)
|
||||
- [func (c CapsulClient) Create(capsulName, capsulType, capsulImage, capsulSSHKey string) (CapsulCreateResponse, error)](<#func-capsulclient-create>)
|
||||
- [func (c CapsulClient) Create(capsulName, capsulType, capsulImage string, capsulSSHKeys []string) (CapsulCreateResponse, error)](<#func-capsulclient-create>)
|
||||
- [type CapsulCreateResponse](<#type-capsulcreateresponse>)
|
||||
|
||||
|
||||
|
@ -36,7 +38,7 @@ New creates a new Capsul client\.
|
|||
### func \(CapsulClient\) Create
|
||||
|
||||
```go
|
||||
func (c CapsulClient) Create(capsulName, capsulType, capsulImage, capsulSSHKey string) (CapsulCreateResponse, error)
|
||||
func (c CapsulClient) Create(capsulName, capsulType, capsulImage string, capsulSSHKeys []string) (CapsulCreateResponse, error)
|
||||
```
|
||||
|
||||
Create creates a new capsul\.
|
||||
|
|
16
libcapsul.go
16
libcapsul.go
|
@ -32,7 +32,7 @@ func New(instanceURL, APIToken string) CapsulClient {
|
|||
}
|
||||
|
||||
// Create creates a new capsul.
|
||||
func (c CapsulClient) Create(capsulName, capsulType, capsulImage, capsulSSHKey string) (CapsulCreateResponse, error) {
|
||||
func (c CapsulClient) Create(capsulName, capsulType, capsulImage string, capsulSSHKeys []string) (CapsulCreateResponse, error) {
|
||||
// yep, the response time is quite slow, something to fix on the Capsul side
|
||||
client := &http.Client{Timeout: 20 * time.Second}
|
||||
|
||||
|
@ -40,10 +40,16 @@ func (c CapsulClient) Create(capsulName, capsulType, capsulImage, capsulSSHKey s
|
|||
logrus.Debugf("using '%s' as capsul create url", capsulCreateURL)
|
||||
|
||||
values := map[string]string{
|
||||
"name": capsulName,
|
||||
"size": capsulType,
|
||||
"os": capsulImage,
|
||||
"ssh_key_0": capsulSSHKey,
|
||||
"name": capsulName,
|
||||
"size": capsulType,
|
||||
"os": capsulImage,
|
||||
}
|
||||
|
||||
idx := 0
|
||||
for _, sshKey := range capsulSSHKeys {
|
||||
key := fmt.Sprintf("ssh_key_%v", idx)
|
||||
values[key] = sshKey
|
||||
idx++
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(values)
|
||||
|
|
Loading…
Reference in New Issue