engine: resources: pkg: Simplify state check
Refactor this code.
This commit is contained in:
@@ -554,9 +554,8 @@ func (obj *PkgRes) GroupCmp(r engine.GroupableRes) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("resource is not the same kind")
|
return fmt.Errorf("resource is not the same kind")
|
||||||
}
|
}
|
||||||
objStateIsVersion := (obj.State != PkgStateInstalled && obj.State != PkgStateUninstalled && obj.State != PkgStateNewest) // must be a ver. string
|
// TODO: what should we do about the empty string?
|
||||||
resStateIsVersion := (res.State != PkgStateInstalled && res.State != PkgStateUninstalled && res.State != PkgStateNewest) // must be a ver. string
|
if stateIsVersion(obj.State) || stateIsVersion(res.State) {
|
||||||
if objStateIsVersion || resStateIsVersion {
|
|
||||||
// can't merge specific version checks atm
|
// can't merge specific version checks atm
|
||||||
return fmt.Errorf("resource uses a version string")
|
return fmt.Errorf("resource uses a version string")
|
||||||
}
|
}
|
||||||
@@ -605,3 +604,10 @@ func ReturnSvcInFileList(fileList []string) []string {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stateIsVersion is a simple test to see if the state string is an existing
|
||||||
|
// well-known flag.
|
||||||
|
// TODO: what should we do about the empty string?
|
||||||
|
func stateIsVersion(state string) bool {
|
||||||
|
return (state != PkgStateInstalled && state != PkgStateUninstalled && state != PkgStateNewest) // must be a ver. string
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user