2021-07-30 20:55:00 +00:00
|
|
|
package client
|
|
|
|
|
2021-07-31 13:50:04 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
|
|
)
|
|
|
|
|
2021-07-30 20:55:00 +00:00
|
|
|
func StoreSecret(secretName, secretValue, server string) error {
|
2021-09-04 22:41:31 +00:00
|
|
|
cl, err := New(server)
|
2021-07-31 13:50:04 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
ann := swarm.Annotations{Name: secretName}
|
|
|
|
spec := swarm.SecretSpec{Annotations: ann, Data: []byte(secretValue)}
|
|
|
|
|
|
|
|
// We don't bother with the secret IDs for now
|
|
|
|
if _, err := cl.SecretCreate(ctx, spec); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-30 20:55:00 +00:00
|
|
|
return nil
|
|
|
|
}
|