(o Options, cr *certregistry.CertRegistry)
| 1228 | } |
| 1229 | |
| 1230 | func createDataClients(o Options, cr *certregistry.CertRegistry) ([]routing.DataClient, error) { |
| 1231 | var clients []routing.DataClient |
| 1232 | |
| 1233 | if o.RoutesFile != "" { |
| 1234 | for rf := range strings.SplitSeq(o.RoutesFile, ",") { |
| 1235 | f, err := eskipfile.Open(rf) |
| 1236 | if err != nil { |
| 1237 | return nil, fmt.Errorf("error while opening eskip file: %w", err) |
| 1238 | } |
| 1239 | |
| 1240 | clients = append(clients, f) |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | if o.WatchRoutesFile != "" { |
| 1245 | for rf := range strings.SplitSeq(o.WatchRoutesFile, ",") { |
| 1246 | clients = append(clients, eskipfile.Watch(rf)) |
| 1247 | } |
| 1248 | } |
| 1249 | |
| 1250 | if len(o.RoutesURLs) > 0 { |
| 1251 | for _, url := range o.RoutesURLs { |
| 1252 | client, err := eskipfile.RemoteWatch(&eskipfile.RemoteWatchOptions{ |
| 1253 | RemoteFile: url, |
| 1254 | FailOnStartup: true, |
| 1255 | HTTPTimeout: o.SourcePollTimeout, |
| 1256 | }) |
| 1257 | if err != nil { |
| 1258 | return nil, fmt.Errorf("error while loading routes from url %s: %w", url, err) |
| 1259 | } |
| 1260 | clients = append(clients, client) |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | if o.InlineRoutes != "" { |
| 1265 | ir, err := routestring.New(o.InlineRoutes) |
| 1266 | if err != nil { |
| 1267 | return nil, fmt.Errorf("error while parsing inline routes: %w", err) |
| 1268 | } |
| 1269 | |
| 1270 | clients = append(clients, ir) |
| 1271 | } |
| 1272 | |
| 1273 | if len(o.EtcdUrls) > 0 { |
| 1274 | etcdClient, err := etcd.New(etcd.Options{ |
| 1275 | Endpoints: o.EtcdUrls, |
| 1276 | Prefix: o.EtcdPrefix, |
| 1277 | Timeout: o.EtcdWaitTimeout, |
| 1278 | Insecure: o.EtcdInsecure, |
| 1279 | OAuthToken: o.EtcdOAuthToken, |
| 1280 | Username: o.EtcdUsername, |
| 1281 | Password: o.EtcdPassword, |
| 1282 | }) |
| 1283 | |
| 1284 | if err != nil { |
| 1285 | return nil, fmt.Errorf("error while creating etcd client: %w", err) |
| 1286 | } |
| 1287 |
searching dependent graphs…