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"
|
2023-01-31 15:09:09 +00:00
|
|
|
"github.com/docker/docker/client"
|
2021-07-31 13:50:04 +00:00
|
|
|
)
|
|
|
|
|
2023-01-31 15:09:09 +00:00
|
|
|
func StoreSecret(cl *client.Client, secretName, secretValue, server string) error {
|
2021-07-31 13:50:04 +00:00
|
|
|
ann := swarm.Annotations{Name: secretName}
|
|
|
|
spec := swarm.SecretSpec{Annotations: ann, Data: []byte(secretValue)}
|
|
|
|
|
2023-01-31 15:09:09 +00:00
|
|
|
if _, err := cl.SecretCreate(context.Background(), spec); err != nil {
|
2021-07-31 13:50:04 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-30 20:55:00 +00:00
|
|
|
return nil
|
|
|
|
}
|