Hub initializes the hub. If a remote configuration is provided, it can be used to download the index and items. If no remote parameter is provided, the hub can only be used for local operations.
(c *csconfig.Config, logger *logrus.Logger)
| 112 | // Hub initializes the hub. If a remote configuration is provided, it can be used to download the index and items. |
| 113 | // If no remote parameter is provided, the hub can only be used for local operations. |
| 114 | func Hub(c *csconfig.Config, logger *logrus.Logger) (*cwhub.Hub, error) { |
| 115 | local := c.Hub |
| 116 | |
| 117 | if local == nil { |
| 118 | return nil, errors.New("you must configure cli before interacting with hub") |
| 119 | } |
| 120 | |
| 121 | if logger == nil { |
| 122 | logger = logrus.New() |
| 123 | logger.SetOutput(io.Discard) |
| 124 | } |
| 125 | |
| 126 | hub, err := cwhub.NewHub(local, logger) |
| 127 | if err != nil { |
| 128 | return nil, err |
| 129 | } |
| 130 | |
| 131 | if err := hub.Load(); err != nil { |
| 132 | return nil, err |
| 133 | } |
| 134 | |
| 135 | return hub, nil |
| 136 | } |
no test coverage detected