fix: check outputs

This commit is contained in:
Jason Song 2023-04-20 16:05:05 +08:00
parent 85453aa315
commit cb14d38e50
No known key found for this signature in database
GPG key ID: 8402EEEE4511A8B5

View file

@ -173,6 +173,10 @@ func (r *Reporter) SetOutputs(outputs map[string]string) {
defer r.stateMu.Unlock()
for k, v := range outputs {
if len(k) > 255 {
r.Logf("ignore output because the key is too long: %q", k)
continue
}
if _, ok := r.outputs.Load(k); ok {
continue
}
@ -282,6 +286,17 @@ func (r *Reporter) ReportState() error {
r.cancel()
}
var noSent []string
r.outputs.Range(func(k, v interface{}) bool {
if _, ok := v.(string); ok {
noSent = append(noSent, k.(string))
}
return true
})
if len(noSent) >= 0 {
return fmt.Errorf("there are still outputs that have not been sent: %v", noSent)
}
return nil
}