Share read-only planning and analysis closure
This commit is contained in:
@@ -63,11 +63,7 @@ func planAnalyzeWork(
|
||||
}
|
||||
targets := effective.Keys()
|
||||
targetSet := stringSet(targets)
|
||||
closure, err := analyzeTargetDependencyClosure(configured, targets)
|
||||
if err != nil {
|
||||
return analyzeWorkPlan{}, err
|
||||
}
|
||||
order, err := orderConfiguredAnalyzeArtifacts(configured)
|
||||
order, err := AnalyzeTargetClosure(configured, targets)
|
||||
if err != nil {
|
||||
return analyzeWorkPlan{}, err
|
||||
}
|
||||
@@ -100,11 +96,8 @@ func planAnalyzeWork(
|
||||
invalidated[state.Key] = struct{}{}
|
||||
}
|
||||
}
|
||||
scheduled := make(map[string]bool, len(closure))
|
||||
scheduled := make(map[string]bool, len(order))
|
||||
for _, key := range order {
|
||||
if _, included := closure[key]; !included {
|
||||
continue
|
||||
}
|
||||
state, ok := reconciled[key]
|
||||
if !ok {
|
||||
return analyzeWorkPlan{}, fmt.Errorf("analysis reconciliation is missing configured artifact %q", key)
|
||||
@@ -150,10 +143,11 @@ func planAnalyzeWork(
|
||||
return plan, nil
|
||||
}
|
||||
|
||||
func analyzeTargetDependencyClosure(
|
||||
// AnalyzeTargetClosure returns targets and their prerequisites in work order.
|
||||
func AnalyzeTargetClosure(
|
||||
configured map[string]config.ScriptoriumArtifactConfig,
|
||||
targets []string,
|
||||
) (map[string]struct{}, error) {
|
||||
) ([]string, error) {
|
||||
closure := make(map[string]struct{}, len(targets))
|
||||
var visit func(string) error
|
||||
visit = func(key string) error {
|
||||
@@ -177,7 +171,17 @@ func analyzeTargetDependencyClosure(
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return closure, nil
|
||||
order, err := orderConfiguredAnalyzeArtifacts(configured)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]string, 0, len(closure))
|
||||
for _, key := range order {
|
||||
if _, included := closure[key]; included {
|
||||
result = append(result, key)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func reconciledAnalyzeRecords(
|
||||
|
||||
Reference in New Issue
Block a user