Remove unused parts of ProcMeta
Also replace if-else if chain with switch and fix error strings.
This commit is contained in:
parent
f960aceaee
commit
16e61b53a7
@ -170,34 +170,10 @@ type Proc struct {
|
|||||||
WriteStreamIdx int // The index of read stream in function argument list
|
WriteStreamIdx int // The index of read stream in function argument list
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcMetaGenerate is a type for flags from @generate annotation
|
|
||||||
type ProcMetaGenerate int
|
|
||||||
|
|
||||||
// @generate annotation can be none, client, server or both
|
|
||||||
const (
|
|
||||||
ProcMetaGenerateNone ProcMetaGenerate = iota
|
|
||||||
ProcMetaGenerateClient
|
|
||||||
ProcMetaGenerateServer
|
|
||||||
ProcMetaGenerateBoth
|
|
||||||
)
|
|
||||||
|
|
||||||
// ProcMetaPriority is a type for values from @priority annotation
|
|
||||||
type ProcMetaPriority int
|
|
||||||
|
|
||||||
// @priority annotation can be low or high
|
|
||||||
const (
|
|
||||||
ProcMetaPriorityLow ProcMetaPriority = iota
|
|
||||||
ProcMetaPriorityHigh
|
|
||||||
)
|
|
||||||
|
|
||||||
// ProcMeta holds information from annotations attached to a libvirt procedure
|
// ProcMeta holds information from annotations attached to a libvirt procedure
|
||||||
type ProcMeta struct {
|
type ProcMeta struct {
|
||||||
Generate ProcMetaGenerate
|
|
||||||
ReadStream int
|
ReadStream int
|
||||||
WriteStream int
|
WriteStream int
|
||||||
Priority ProcMetaPriority
|
|
||||||
Acls []string
|
|
||||||
Aclfilter string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type structStack []*Structure
|
type structStack []*Structure
|
||||||
@ -671,42 +647,19 @@ func parseMeta(meta string) (*ProcMeta, error) {
|
|||||||
return nil, fmt.Errorf("invalid annotation: %s", meta)
|
return nil, fmt.Errorf("invalid annotation: %s", meta)
|
||||||
}
|
}
|
||||||
spl[1] = strings.Trim(spl[1], " ")
|
spl[1] = strings.Trim(spl[1], " ")
|
||||||
if spl[0] == "generate" {
|
switch spl[0] {
|
||||||
if spl[1] == "none" {
|
case "readstream":
|
||||||
res.Generate = ProcMetaGenerateNone
|
|
||||||
} else if spl[1] == "client" {
|
|
||||||
res.Generate = ProcMetaGenerateClient
|
|
||||||
} else if spl[1] == "server" {
|
|
||||||
res.Generate = ProcMetaGenerateServer
|
|
||||||
} else if spl[1] == "both" {
|
|
||||||
res.Generate = ProcMetaGenerateBoth
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("invalid value for generate: %s", spl[1])
|
|
||||||
}
|
|
||||||
} else if spl[0] == "readstream" {
|
|
||||||
var err error
|
var err error
|
||||||
res.ReadStream, err = strconv.Atoi(spl[1])
|
res.ReadStream, err = strconv.Atoi(spl[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid value for readstread: %s", spl[1])
|
return nil, fmt.Errorf("invalid value for readstream: %s", spl[1])
|
||||||
}
|
}
|
||||||
} else if spl[0] == "writestream" {
|
case "writestream":
|
||||||
var err error
|
var err error
|
||||||
res.WriteStream, err = strconv.Atoi(spl[1])
|
res.WriteStream, err = strconv.Atoi(spl[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid value for readstread: %s", spl[1])
|
return nil, fmt.Errorf("invalid value for writestream: %s", spl[1])
|
||||||
}
|
}
|
||||||
} else if spl[0] == "priority" {
|
|
||||||
if spl[1] == "low" {
|
|
||||||
res.Priority = ProcMetaPriorityLow
|
|
||||||
} else if spl[1] == "high" {
|
|
||||||
res.Priority = ProcMetaPriorityHigh
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("invalid value for priority: %s", spl[1])
|
|
||||||
}
|
|
||||||
} else if spl[0] == "acl" {
|
|
||||||
res.Acls = append(res.Acls, spl[1])
|
|
||||||
} else if spl[0] == "aclfilter" {
|
|
||||||
res.Aclfilter = spl[1]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user