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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/cuigh/swirl/misc"
|
"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) {
|
return mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
|
||||||
spec := swarm.SecretSpec{}
|
spec := swarm.SecretSpec{}
|
||||||
spec.Name = info.Name
|
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()
|
spec.Labels = info.Labels.ToMap()
|
||||||
if info.Template.Name != "" {
|
if info.Template.Name != "" {
|
||||||
spec.Templating = &swarm.Driver{
|
spec.Templating = &swarm.Driver{
|
||||||
|
@ -563,6 +563,7 @@ type ConfigCreateInfo struct {
|
|||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
Labels Options `json:"labels"`
|
Labels Options `json:"labels"`
|
||||||
Template Driver `json:"template"`
|
Template Driver `json:"template"`
|
||||||
|
Base64 bool `json:"base64"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigUpdateInfo struct {
|
type ConfigUpdateInfo struct {
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
<textarea name="data" class="textarea" rows="12" placeholder="Secret file content" data-v-rule="native" required></textarea>
|
<textarea name="data" class="textarea" rows="12" placeholder="Secret file content" data-v-rule="native" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
{{ yield switch(id="cb-base64", name="base64", label="Base64 encoded") }}
|
||||||
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">{{ i18n("field.label") }}</label>
|
<label class="label">{{ i18n("field.label") }}</label>
|
||||||
{{ yield options(name="label") }}
|
{{ yield options(name="label") }}
|
||||||
|
Loading…
Reference in New Issue
Block a user