mirror of
https://github.com/cuigh/swirl
synced 2025-02-07 05:17:37 +00:00
Allow uploading secrets encoded with base64
This commit is contained in:
parent
da07ba60fc
commit
07d2c4bc3b
@ -2,6 +2,7 @@ package docker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"sort"
|
||||
|
||||
"github.com/cuigh/swirl/misc"
|
||||
@ -39,7 +40,14 @@ func SecretCreate(info *model.ConfigCreateInfo) error {
|
||||
return mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
|
||||
spec := swarm.SecretSpec{}
|
||||
spec.Name = info.Name
|
||||
spec.Data = []byte(info.Data)
|
||||
if info.Base64 {
|
||||
spec.Data, err = base64.StdEncoding.DecodeString(info.Data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
spec.Data = []byte(info.Data)
|
||||
}
|
||||
spec.Labels = info.Labels.ToMap()
|
||||
if info.Template.Name != "" {
|
||||
spec.Templating = &swarm.Driver{
|
||||
|
@ -563,6 +563,7 @@ type ConfigCreateInfo struct {
|
||||
Data string `json:"data"`
|
||||
Labels Options `json:"labels"`
|
||||
Template Driver `json:"template"`
|
||||
Base64 bool `json:"base64"`
|
||||
}
|
||||
|
||||
type ConfigUpdateInfo struct {
|
||||
|
@ -31,6 +31,9 @@
|
||||
<textarea name="data" class="textarea" rows="12" placeholder="Secret file content" data-v-rule="native" required></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
{{ yield switch(id="cb-base64", name="base64", label="Base64 encoded") }}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ i18n("field.label") }}</label>
|
||||
{{ yield options(name="label") }}
|
||||
|
Loading…
Reference in New Issue
Block a user