InstallOptionalDeps installs the supplied dependency groups. Since the groups are all optional, InstallOptionalDeps continues to install the remaining groups even if a group fails to be installed. It returns a non-nil error if any of the groups fails to be installed.
(groups []*Group, logger flog.Logger)
| 74 | // InstallOptionalDeps continues to install the remaining groups even if a group fails to be installed. |
| 75 | // It returns a non-nil error if any of the groups fails to be installed. |
| 76 | func InstallOptionalDeps(groups []*Group, logger flog.Logger) error { |
| 77 | var errs []error |
| 78 | |
| 79 | for _, group := range groups { |
| 80 | err := group.installOptional(logger) |
| 81 | if err != nil { |
| 82 | errs = append(errs, err) |
| 83 | } |
| 84 | } |
| 85 | if len(errs) > 0 { |
| 86 | return fmt.Errorf("failed to install dependencies: %w", errors.Join(errs...)) |
| 87 | } |
| 88 | |
| 89 | return nil |
| 90 | } |