engine: resources: http: Improved CheckApply for grouped resources
This commit is contained in:
@@ -353,7 +353,8 @@ func (obj *HTTPServerRes) Watch(ctx context.Context) error {
|
|||||||
|
|
||||||
// CheckApply never has anything to do for this resource, so it always succeeds.
|
// CheckApply never has anything to do for this resource, so it always succeeds.
|
||||||
// It does however check that certain runtime requirements (such as the Root dir
|
// It does however check that certain runtime requirements (such as the Root dir
|
||||||
// existing if one was specified) are fulfilled.
|
// existing if one was specified) are fulfilled. If there are any autogrouped
|
||||||
|
// resources, those will be recursively called so that they can send/recv.
|
||||||
func (obj *HTTPServerRes) CheckApply(ctx context.Context, apply bool) (bool, error) {
|
func (obj *HTTPServerRes) CheckApply(ctx context.Context, apply bool) (bool, error) {
|
||||||
if obj.init.Debug {
|
if obj.init.Debug {
|
||||||
obj.init.Logf("CheckApply")
|
obj.init.Logf("CheckApply")
|
||||||
@@ -363,6 +364,7 @@ func (obj *HTTPServerRes) CheckApply(ctx context.Context, apply bool) (bool, err
|
|||||||
// Watch has started up, so we must block here until that's the case...
|
// Watch has started up, so we must block here until that's the case...
|
||||||
|
|
||||||
// Cheap runtime validation!
|
// Cheap runtime validation!
|
||||||
|
// XXX: maybe only do this only once to avoid repeated, unnecessary checks?
|
||||||
if obj.Root != "" {
|
if obj.Root != "" {
|
||||||
fileInfo, err := os.Stat(obj.Root)
|
fileInfo, err := os.Stat(obj.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -373,7 +375,16 @@ func (obj *HTTPServerRes) CheckApply(ctx context.Context, apply bool) (bool, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil // always succeeds, with nothing to do!
|
checkOK := true
|
||||||
|
for _, res := range obj.GetGroup() { // grouped elements
|
||||||
|
if c, err := res.CheckApply(ctx, apply); err != nil {
|
||||||
|
return false, errwrap.Wrapf(err, "autogrouped CheckApply failed")
|
||||||
|
} else if !c {
|
||||||
|
checkOK = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkOK, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cmp compares two resources and returns an error if they are not equivalent.
|
// Cmp compares two resources and returns an error if they are not equivalent.
|
||||||
|
|||||||
Reference in New Issue
Block a user