(opts *InstallOptions, selectedSkills []discovery.Skill, selectedHosts []*registry.AgentHost, scope registry.Scope, gitRoot, homeDir string, canPrompt bool)
| 971 | } |
| 972 | |
| 973 | func buildInstallPlans(opts *InstallOptions, selectedSkills []discovery.Skill, selectedHosts []*registry.AgentHost, scope registry.Scope, gitRoot, homeDir string, canPrompt bool) ([]installPlan, error) { |
| 974 | byDir := make(map[string]*installPlan) |
| 975 | orderedDirs := make([]string, 0, len(selectedHosts)) |
| 976 | |
| 977 | for _, host := range selectedHosts { |
| 978 | targetDir, err := resolveInstallDir(opts, host, scope, gitRoot, homeDir) |
| 979 | if err != nil { |
| 980 | return nil, err |
| 981 | } |
| 982 | |
| 983 | plan, ok := byDir[targetDir] |
| 984 | if !ok { |
| 985 | plan = &installPlan{dir: targetDir} |
| 986 | byDir[targetDir] = plan |
| 987 | orderedDirs = append(orderedDirs, targetDir) |
| 988 | } |
| 989 | plan.hosts = append(plan.hosts, host) |
| 990 | } |
| 991 | |
| 992 | plans := make([]installPlan, 0, len(orderedDirs)) |
| 993 | for _, dir := range orderedDirs { |
| 994 | plan := byDir[dir] |
| 995 | installSkills, err := checkOverwrite(opts, selectedSkills, plan.dir, canPrompt) |
| 996 | if err != nil { |
| 997 | return nil, err |
| 998 | } |
| 999 | if len(installSkills) == 0 { |
| 1000 | fmt.Fprintf(opts.IO.ErrOut, "No skills to install in %s for %s.\n", friendlyDir(plan.dir), formatPlanHosts(plan.hosts)) |
| 1001 | continue |
| 1002 | } |
| 1003 | plan.skills = installSkills |
| 1004 | plans = append(plans, *plan) |
| 1005 | } |
| 1006 | |
| 1007 | return plans, nil |
| 1008 | } |
| 1009 | |
| 1010 | func resolveInstallDir(opts *InstallOptions, host *registry.AgentHost, scope registry.Scope, gitRoot, homeDir string) (string, error) { |
| 1011 | if opts.Dir != "" { |
no test coverage detected