feat: finally implement app new command

This commit is contained in:
2021-07-31 15:50:04 +02:00
parent 932803453e
commit 42968fb8e1
4 changed files with 68 additions and 26 deletions

View File

@ -1,5 +1,25 @@
package client
import (
"context"
"github.com/docker/docker/api/types/swarm"
)
func StoreSecret(secretName, secretValue, server string) error {
cl, err := NewClientWithContext(server)
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
}
return nil
}