@ -620,7 +620,7 @@ var _ hclparser.WithEvalContexts = &Group{}
var _ hclparser . WithGetName = & Group { }
var _ hclparser . WithGetName = & Group { }
func ( t * Target ) normalize ( ) {
func ( t * Target ) normalize ( ) {
t . Attest = remove Dupes( t . Attest )
t . Attest = remove Attest Dupes( t . Attest )
t . Tags = removeDupes ( t . Tags )
t . Tags = removeDupes ( t . Tags )
t . Secrets = removeDupes ( t . Secrets )
t . Secrets = removeDupes ( t . Secrets )
t . SSH = removeDupes ( t . SSH )
t . SSH = removeDupes ( t . SSH )
@ -682,6 +682,7 @@ func (t *Target) Merge(t2 *Target) {
}
}
if t2 . Attest != nil { // merge
if t2 . Attest != nil { // merge
t . Attest = append ( t . Attest , t2 . Attest ... )
t . Attest = append ( t . Attest , t2 . Attest ... )
t . Attest = removeAttestDupes ( t . Attest )
}
}
if t2 . Secrets != nil { // merge
if t2 . Secrets != nil { // merge
t . Secrets = append ( t . Secrets , t2 . Secrets ... )
t . Secrets = append ( t . Secrets , t2 . Secrets ... )
@ -1189,6 +1190,26 @@ func removeDupes(s []string) []string {
return s [ : i ]
return s [ : i ]
}
}
func removeAttestDupes ( s [ ] string ) [ ] string {
res := [ ] string { }
m := map [ string ] int { }
for _ , v := range s {
att , err := buildflags . ParseAttest ( v )
if err != nil {
res = append ( res , v )
continue
}
if i , ok := m [ att . Type ] ; ok {
res [ i ] = v
} else {
m [ att . Type ] = len ( res )
res = append ( res , v )
}
}
return res
}
func parseOutputType ( str string ) string {
func parseOutputType ( str string ) string {
csvReader := csv . NewReader ( strings . NewReader ( str ) )
csvReader := csv . NewReader ( strings . NewReader ( str ) )
fields , err := csvReader . Read ( )
fields , err := csvReader . Read ( )