mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
Fix handling of attest extra arguments
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
This commit is contained in:
parent
4e91fe6507
commit
b06bddfee6
@ -148,9 +148,8 @@ func (a *Attest) UnmarshalText(text []byte) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return errors.Errorf("invalid value %s", field)
|
return errors.Errorf("invalid value %s", field)
|
||||||
}
|
}
|
||||||
key = strings.TrimSpace(strings.ToLower(key))
|
|
||||||
|
|
||||||
switch key {
|
switch strings.TrimSpace(strings.ToLower(key)) {
|
||||||
case "type":
|
case "type":
|
||||||
a.Type = value
|
a.Type = value
|
||||||
case "disabled":
|
case "disabled":
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package buildflags
|
package buildflags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"maps"
|
"maps"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -259,9 +260,18 @@ func (w *csvBuilder) Write(key, value string) {
|
|||||||
if w.sb.Len() > 0 {
|
if w.sb.Len() > 0 {
|
||||||
w.sb.WriteByte(',')
|
w.sb.WriteByte(',')
|
||||||
}
|
}
|
||||||
w.sb.WriteString(key)
|
|
||||||
w.sb.WriteByte('=')
|
pair := key + "=" + value
|
||||||
w.sb.WriteString(value)
|
if strings.ContainsRune(pair, ',') || strings.ContainsRune(pair, '"') {
|
||||||
|
var attr strings.Builder
|
||||||
|
writer := csv.NewWriter(&attr)
|
||||||
|
writer.Write([]string{pair})
|
||||||
|
writer.Flush()
|
||||||
|
// Strips the extra newline added by the csv writer
|
||||||
|
pair = strings.TrimSpace(attr.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
w.sb.WriteString(pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *csvBuilder) WriteAttributes(attrs map[string]string) {
|
func (w *csvBuilder) WriteAttributes(attrs map[string]string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user