project.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. package router
  2. import (
  3. "github.com/go-chi/chi"
  4. "github.com/porter-dev/porter/api/server/handlers/billing"
  5. "github.com/porter-dev/porter/api/server/handlers/cluster"
  6. "github.com/porter-dev/porter/api/server/handlers/gitinstallation"
  7. "github.com/porter-dev/porter/api/server/handlers/project"
  8. "github.com/porter-dev/porter/api/server/handlers/provision"
  9. "github.com/porter-dev/porter/api/server/handlers/registry"
  10. "github.com/porter-dev/porter/api/server/shared"
  11. "github.com/porter-dev/porter/api/server/shared/config"
  12. "github.com/porter-dev/porter/api/types"
  13. )
  14. func NewProjectScopedRegisterer(children ...*Registerer) *Registerer {
  15. return &Registerer{
  16. GetRoutes: GetProjectScopedRoutes,
  17. Children: children,
  18. }
  19. }
  20. func GetProjectScopedRoutes(
  21. r chi.Router,
  22. config *config.Config,
  23. basePath *types.Path,
  24. factory shared.APIEndpointFactory,
  25. children ...*Registerer,
  26. ) []*Route {
  27. routes, projPath := getProjectRoutes(r, config, basePath, factory)
  28. if len(children) > 0 {
  29. r.Route(projPath.RelativePath, func(r chi.Router) {
  30. for _, child := range children {
  31. childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
  32. routes = append(routes, childRoutes...)
  33. }
  34. })
  35. }
  36. return routes
  37. }
  38. func getProjectRoutes(
  39. r chi.Router,
  40. config *config.Config,
  41. basePath *types.Path,
  42. factory shared.APIEndpointFactory,
  43. ) ([]*Route, *types.Path) {
  44. relPath := "/projects/{project_id}"
  45. newPath := &types.Path{
  46. Parent: basePath,
  47. RelativePath: relPath,
  48. }
  49. routes := make([]*Route, 0)
  50. // GET /api/projects/{project_id} -> project.NewProjectGetHandler
  51. getEndpoint := factory.NewAPIEndpoint(
  52. &types.APIRequestMetadata{
  53. Verb: types.APIVerbGet,
  54. Method: types.HTTPVerbGet,
  55. Path: &types.Path{
  56. Parent: basePath,
  57. RelativePath: relPath,
  58. },
  59. Scopes: []types.PermissionScope{
  60. types.UserScope,
  61. types.ProjectScope,
  62. },
  63. },
  64. )
  65. getHandler := project.NewProjectGetHandler(
  66. config,
  67. factory.GetResultWriter(),
  68. )
  69. routes = append(routes, &Route{
  70. Endpoint: getEndpoint,
  71. Handler: getHandler,
  72. Router: r,
  73. })
  74. // DELETE /api/projects/{project_id} -> project.NewProjectDeleteHandler
  75. deleteEndpoint := factory.NewAPIEndpoint(
  76. &types.APIRequestMetadata{
  77. Verb: types.APIVerbDelete,
  78. Method: types.HTTPVerbDelete,
  79. Path: &types.Path{
  80. Parent: basePath,
  81. RelativePath: relPath,
  82. },
  83. Scopes: []types.PermissionScope{
  84. types.UserScope,
  85. types.ProjectScope,
  86. },
  87. },
  88. )
  89. deleteHandler := project.NewProjectDeleteHandler(
  90. config,
  91. factory.GetResultWriter(),
  92. )
  93. routes = append(routes, &Route{
  94. Endpoint: deleteEndpoint,
  95. Handler: deleteHandler,
  96. Router: r,
  97. })
  98. // GET /api/projects/{project_id}/policy -> project.NewProjectGetPolicyHandler
  99. getPolicyEndpoint := factory.NewAPIEndpoint(
  100. &types.APIRequestMetadata{
  101. Verb: types.APIVerbGet,
  102. Method: types.HTTPVerbGet,
  103. Path: &types.Path{
  104. Parent: basePath,
  105. RelativePath: relPath + "/policy",
  106. },
  107. Scopes: []types.PermissionScope{
  108. types.UserScope,
  109. types.ProjectScope,
  110. },
  111. },
  112. )
  113. getPolicyHandler := project.NewProjectGetPolicyHandler(
  114. config,
  115. factory.GetResultWriter(),
  116. )
  117. routes = append(routes, &Route{
  118. Endpoint: getPolicyEndpoint,
  119. Handler: getPolicyHandler,
  120. Router: r,
  121. })
  122. // GET /api/projects/{project_id}/usage -> project.NewProjectGetUsageHandler
  123. getUsageEndpoint := factory.NewAPIEndpoint(
  124. &types.APIRequestMetadata{
  125. Verb: types.APIVerbGet,
  126. Method: types.HTTPVerbGet,
  127. Path: &types.Path{
  128. Parent: basePath,
  129. RelativePath: relPath + "/usage",
  130. },
  131. Scopes: []types.PermissionScope{
  132. types.UserScope,
  133. types.ProjectScope,
  134. },
  135. },
  136. )
  137. getUsageHandler := project.NewProjectGetUsageHandler(
  138. config,
  139. factory.GetResultWriter(),
  140. )
  141. routes = append(routes, &Route{
  142. Endpoint: getUsageEndpoint,
  143. Handler: getUsageHandler,
  144. Router: r,
  145. })
  146. // GET /api/projects/{project_id}/billing/token -> billing.NewBillingGetTokenEndpoint
  147. getBillingTokenEndpoint := factory.NewAPIEndpoint(
  148. &types.APIRequestMetadata{
  149. Verb: types.APIVerbGet,
  150. Method: types.HTTPVerbGet,
  151. Path: &types.Path{
  152. Parent: basePath,
  153. RelativePath: relPath + "/billing/token",
  154. },
  155. Scopes: []types.PermissionScope{
  156. types.UserScope,
  157. types.ProjectScope,
  158. types.SettingsScope,
  159. },
  160. },
  161. )
  162. getBillingTokenHandler := billing.NewBillingGetTokenHandler(
  163. config,
  164. factory.GetDecoderValidator(),
  165. factory.GetResultWriter(),
  166. )
  167. routes = append(routes, &Route{
  168. Endpoint: getBillingTokenEndpoint,
  169. Handler: getBillingTokenHandler,
  170. Router: r,
  171. })
  172. // GET /api/billing_webhook -> billing.NewBillingWebhookHandler
  173. getBillingWebhookEndpoint := factory.NewAPIEndpoint(
  174. &types.APIRequestMetadata{
  175. Verb: types.APIVerbCreate,
  176. Method: types.HTTPVerbPost,
  177. Path: &types.Path{
  178. Parent: basePath,
  179. RelativePath: "/billing_webhook",
  180. },
  181. Scopes: []types.PermissionScope{},
  182. },
  183. )
  184. getBillingWebhookHandler := billing.NewBillingWebhookHandler(
  185. config,
  186. factory.GetDecoderValidator(),
  187. )
  188. routes = append(routes, &Route{
  189. Endpoint: getBillingWebhookEndpoint,
  190. Handler: getBillingWebhookHandler,
  191. Router: r,
  192. })
  193. // GET /api/projects/{project_id}/clusters -> cluster.NewClusterListHandler
  194. listClusterEndpoint := factory.NewAPIEndpoint(
  195. &types.APIRequestMetadata{
  196. Verb: types.APIVerbList,
  197. Method: types.HTTPVerbGet,
  198. Path: &types.Path{
  199. Parent: basePath,
  200. RelativePath: relPath + "/clusters",
  201. },
  202. Scopes: []types.PermissionScope{
  203. types.UserScope,
  204. types.ProjectScope,
  205. },
  206. },
  207. )
  208. listClusterHandler := cluster.NewClusterListHandler(
  209. config,
  210. factory.GetResultWriter(),
  211. )
  212. routes = append(routes, &Route{
  213. Endpoint: listClusterEndpoint,
  214. Handler: listClusterHandler,
  215. Router: r,
  216. })
  217. // GET /api/projects/{project_id}/gitrepos -> gitinstallation.NewGitRepoListHandler
  218. listGitReposEndpoint := factory.NewAPIEndpoint(
  219. &types.APIRequestMetadata{
  220. Verb: types.APIVerbList,
  221. Method: types.HTTPVerbGet,
  222. Path: &types.Path{
  223. Parent: basePath,
  224. RelativePath: relPath + "/gitrepos",
  225. },
  226. Scopes: []types.PermissionScope{
  227. types.UserScope,
  228. types.ProjectScope,
  229. },
  230. },
  231. )
  232. listGitReposHandler := gitinstallation.NewGitRepoListHandler(
  233. config,
  234. factory.GetResultWriter(),
  235. )
  236. routes = append(routes, &Route{
  237. Endpoint: listGitReposEndpoint,
  238. Handler: listGitReposHandler,
  239. Router: r,
  240. })
  241. // GET /api/projects/{project_id}/collaborators -> project.NewCollaboratorsListHandler
  242. listCollaboratorsEndpoint := factory.NewAPIEndpoint(
  243. &types.APIRequestMetadata{
  244. Verb: types.APIVerbList,
  245. Method: types.HTTPVerbGet,
  246. Path: &types.Path{
  247. Parent: basePath,
  248. RelativePath: relPath + "/collaborators",
  249. },
  250. Scopes: []types.PermissionScope{
  251. types.UserScope,
  252. types.ProjectScope,
  253. },
  254. },
  255. )
  256. listCollaboratorsHandler := project.NewCollaboratorsListHandler(
  257. config,
  258. factory.GetResultWriter(),
  259. )
  260. routes = append(routes, &Route{
  261. Endpoint: listCollaboratorsEndpoint,
  262. Handler: listCollaboratorsHandler,
  263. Router: r,
  264. })
  265. // GET /api/projects/{project_id}/roles -> project.NewRolesListHandler
  266. listRolesEndpoint := factory.NewAPIEndpoint(
  267. &types.APIRequestMetadata{
  268. Verb: types.APIVerbList,
  269. Method: types.HTTPVerbGet,
  270. Path: &types.Path{
  271. Parent: basePath,
  272. RelativePath: relPath + "/roles",
  273. },
  274. Scopes: []types.PermissionScope{
  275. types.UserScope,
  276. types.ProjectScope,
  277. },
  278. },
  279. )
  280. listRolesHandler := project.NewRolesListHandler(
  281. config,
  282. factory.GetResultWriter(),
  283. )
  284. routes = append(routes, &Route{
  285. Endpoint: listRolesEndpoint,
  286. Handler: listRolesHandler,
  287. Router: r,
  288. })
  289. // POST /api/projects/{project_id}/roles -> project.NewRoleUpdateHandler
  290. updateRoleEndpoint := factory.NewAPIEndpoint(
  291. &types.APIRequestMetadata{
  292. Verb: types.APIVerbUpdate,
  293. Method: types.HTTPVerbPost,
  294. Path: &types.Path{
  295. Parent: basePath,
  296. RelativePath: relPath + "/roles",
  297. },
  298. Scopes: []types.PermissionScope{
  299. types.UserScope,
  300. types.ProjectScope,
  301. },
  302. },
  303. )
  304. updateRoleHandler := project.NewRoleUpdateHandler(
  305. config,
  306. factory.GetDecoderValidator(),
  307. factory.GetResultWriter(),
  308. )
  309. routes = append(routes, &Route{
  310. Endpoint: updateRoleEndpoint,
  311. Handler: updateRoleHandler,
  312. Router: r,
  313. })
  314. // DELETE /api/projects/{project_id}/roles -> project.NewRoleDeleteHandler
  315. deleteRoleEndpoint := factory.NewAPIEndpoint(
  316. &types.APIRequestMetadata{
  317. Verb: types.APIVerbDelete,
  318. Method: types.HTTPVerbDelete,
  319. Path: &types.Path{
  320. Parent: basePath,
  321. RelativePath: relPath + "/roles",
  322. },
  323. Scopes: []types.PermissionScope{
  324. types.UserScope,
  325. types.ProjectScope,
  326. },
  327. },
  328. )
  329. deleteRoleHandler := project.NewRoleDeleteHandler(
  330. config,
  331. factory.GetDecoderValidator(),
  332. factory.GetResultWriter(),
  333. )
  334. routes = append(routes, &Route{
  335. Endpoint: deleteRoleEndpoint,
  336. Handler: deleteRoleHandler,
  337. Router: r,
  338. })
  339. // GET /api/projects/{project_id}/registries -> registry.NewRegistryListHandler
  340. listRegistriesEndpoint := factory.NewAPIEndpoint(
  341. &types.APIRequestMetadata{
  342. Verb: types.APIVerbList,
  343. Method: types.HTTPVerbGet,
  344. Path: &types.Path{
  345. Parent: basePath,
  346. RelativePath: relPath + "/registries",
  347. },
  348. Scopes: []types.PermissionScope{
  349. types.UserScope,
  350. types.ProjectScope,
  351. },
  352. },
  353. )
  354. listRegistriesHandler := registry.NewRegistryListHandler(
  355. config,
  356. factory.GetResultWriter(),
  357. )
  358. routes = append(routes, &Route{
  359. Endpoint: listRegistriesEndpoint,
  360. Handler: listRegistriesHandler,
  361. Router: r,
  362. })
  363. // POST /api/projects/{project_id}/registries -> registry.NewRegistryCreateHandler
  364. createRegistryEndpoint := factory.NewAPIEndpoint(
  365. &types.APIRequestMetadata{
  366. Verb: types.APIVerbCreate,
  367. Method: types.HTTPVerbPost,
  368. Path: &types.Path{
  369. Parent: basePath,
  370. RelativePath: relPath + "/registries",
  371. },
  372. Scopes: []types.PermissionScope{
  373. types.UserScope,
  374. types.ProjectScope,
  375. },
  376. },
  377. )
  378. createRegistryHandler := registry.NewRegistryCreateHandler(
  379. config,
  380. factory.GetDecoderValidator(),
  381. factory.GetResultWriter(),
  382. )
  383. routes = append(routes, &Route{
  384. Endpoint: createRegistryEndpoint,
  385. Handler: createRegistryHandler,
  386. Router: r,
  387. })
  388. // GET /api/projects/{project_id}/registries/ecr/token -> registry.NewRegistryGetECRTokenHandler
  389. getECRTokenEndpoint := factory.NewAPIEndpoint(
  390. &types.APIRequestMetadata{
  391. Verb: types.APIVerbGet,
  392. Method: types.HTTPVerbGet,
  393. Path: &types.Path{
  394. Parent: basePath,
  395. RelativePath: relPath + "/registries/ecr/token",
  396. },
  397. Scopes: []types.PermissionScope{
  398. types.UserScope,
  399. types.ProjectScope,
  400. },
  401. },
  402. )
  403. getECRTokenHandler := registry.NewRegistryGetECRTokenHandler(
  404. config,
  405. factory.GetDecoderValidator(),
  406. factory.GetResultWriter(),
  407. )
  408. routes = append(routes, &Route{
  409. Endpoint: getECRTokenEndpoint,
  410. Handler: getECRTokenHandler,
  411. Router: r,
  412. })
  413. // GET /api/projects/{project_id}/registries/docr/token -> registry.NewRegistryGetDOCRTokenHandler
  414. getDOCRTokenEndpoint := factory.NewAPIEndpoint(
  415. &types.APIRequestMetadata{
  416. Verb: types.APIVerbGet,
  417. Method: types.HTTPVerbGet,
  418. Path: &types.Path{
  419. Parent: basePath,
  420. RelativePath: relPath + "/registries/docr/token",
  421. },
  422. Scopes: []types.PermissionScope{
  423. types.UserScope,
  424. types.ProjectScope,
  425. },
  426. },
  427. )
  428. getDOCRTokenHandler := registry.NewRegistryGetDOCRTokenHandler(
  429. config,
  430. factory.GetDecoderValidator(),
  431. factory.GetResultWriter(),
  432. )
  433. routes = append(routes, &Route{
  434. Endpoint: getDOCRTokenEndpoint,
  435. Handler: getDOCRTokenHandler,
  436. Router: r,
  437. })
  438. // GET /api/projects/{project_id}/registries/gcr/token -> registry.NewRegistryGetGCRTokenHandler
  439. getGCRTokenEndpoint := factory.NewAPIEndpoint(
  440. &types.APIRequestMetadata{
  441. Verb: types.APIVerbGet,
  442. Method: types.HTTPVerbGet,
  443. Path: &types.Path{
  444. Parent: basePath,
  445. RelativePath: relPath + "/registries/gcr/token",
  446. },
  447. Scopes: []types.PermissionScope{
  448. types.UserScope,
  449. types.ProjectScope,
  450. },
  451. },
  452. )
  453. getGCRTokenHandler := registry.NewRegistryGetGCRTokenHandler(
  454. config,
  455. factory.GetDecoderValidator(),
  456. factory.GetResultWriter(),
  457. )
  458. routes = append(routes, &Route{
  459. Endpoint: getGCRTokenEndpoint,
  460. Handler: getGCRTokenHandler,
  461. Router: r,
  462. })
  463. // GET /api/projects/{project_id}/registries/dockerhub/token -> registry.NewRegistryGetDockerhubTokenHandler
  464. getDockerhubTokenEndpoint := factory.NewAPIEndpoint(
  465. &types.APIRequestMetadata{
  466. Verb: types.APIVerbGet,
  467. Method: types.HTTPVerbGet,
  468. Path: &types.Path{
  469. Parent: basePath,
  470. RelativePath: relPath + "/registries/dockerhub/token",
  471. },
  472. Scopes: []types.PermissionScope{
  473. types.UserScope,
  474. types.ProjectScope,
  475. },
  476. },
  477. )
  478. getDockerhubTokenHandler := registry.NewRegistryGetDockerhubTokenHandler(
  479. config,
  480. factory.GetDecoderValidator(),
  481. factory.GetResultWriter(),
  482. )
  483. routes = append(routes, &Route{
  484. Endpoint: getDockerhubTokenEndpoint,
  485. Handler: getDockerhubTokenHandler,
  486. Router: r,
  487. })
  488. // POST /api/projects/{project_id}/provision/ecr -> provision.NewProvisionECRHandler
  489. provisionECREndpoint := factory.NewAPIEndpoint(
  490. &types.APIRequestMetadata{
  491. Verb: types.APIVerbCreate,
  492. Method: types.HTTPVerbPost,
  493. Path: &types.Path{
  494. Parent: basePath,
  495. RelativePath: relPath + "/provision/ecr",
  496. },
  497. Scopes: []types.PermissionScope{
  498. types.UserScope,
  499. types.ProjectScope,
  500. },
  501. },
  502. )
  503. provisionECRHandler := provision.NewProvisionECRHandler(
  504. config,
  505. factory.GetDecoderValidator(),
  506. factory.GetResultWriter(),
  507. )
  508. routes = append(routes, &Route{
  509. Endpoint: provisionECREndpoint,
  510. Handler: provisionECRHandler,
  511. Router: r,
  512. })
  513. // POST /api/projects/{project_id}/provision/eks -> provision.NewProvisionEKSHandler
  514. provisionEKSEndpoint := factory.NewAPIEndpoint(
  515. &types.APIRequestMetadata{
  516. Verb: types.APIVerbCreate,
  517. Method: types.HTTPVerbPost,
  518. Path: &types.Path{
  519. Parent: basePath,
  520. RelativePath: relPath + "/provision/eks",
  521. },
  522. Scopes: []types.PermissionScope{
  523. types.UserScope,
  524. types.ProjectScope,
  525. },
  526. CheckUsage: true,
  527. UsageMetric: types.Clusters,
  528. },
  529. )
  530. provisionEKSHandler := provision.NewProvisionEKSHandler(
  531. config,
  532. factory.GetDecoderValidator(),
  533. factory.GetResultWriter(),
  534. )
  535. routes = append(routes, &Route{
  536. Endpoint: provisionEKSEndpoint,
  537. Handler: provisionEKSHandler,
  538. Router: r,
  539. })
  540. // POST /api/projects/{project_id}/provision/docr -> provision.NewProvisionDOCRHandler
  541. provisionDOCREndpoint := factory.NewAPIEndpoint(
  542. &types.APIRequestMetadata{
  543. Verb: types.APIVerbCreate,
  544. Method: types.HTTPVerbPost,
  545. Path: &types.Path{
  546. Parent: basePath,
  547. RelativePath: relPath + "/provision/docr",
  548. },
  549. Scopes: []types.PermissionScope{
  550. types.UserScope,
  551. types.ProjectScope,
  552. },
  553. },
  554. )
  555. provisionDOCRHandler := provision.NewProvisionDOCRHandler(
  556. config,
  557. factory.GetDecoderValidator(),
  558. factory.GetResultWriter(),
  559. )
  560. routes = append(routes, &Route{
  561. Endpoint: provisionDOCREndpoint,
  562. Handler: provisionDOCRHandler,
  563. Router: r,
  564. })
  565. // POST /api/projects/{project_id}/provision/doks -> provision.NewProvisionDOKSHandler
  566. provisionDOKSEndpoint := factory.NewAPIEndpoint(
  567. &types.APIRequestMetadata{
  568. Verb: types.APIVerbCreate,
  569. Method: types.HTTPVerbPost,
  570. Path: &types.Path{
  571. Parent: basePath,
  572. RelativePath: relPath + "/provision/doks",
  573. },
  574. Scopes: []types.PermissionScope{
  575. types.UserScope,
  576. types.ProjectScope,
  577. },
  578. CheckUsage: true,
  579. UsageMetric: types.Clusters,
  580. },
  581. )
  582. provisionDOKSHandler := provision.NewProvisionDOKSHandler(
  583. config,
  584. factory.GetDecoderValidator(),
  585. factory.GetResultWriter(),
  586. )
  587. routes = append(routes, &Route{
  588. Endpoint: provisionDOKSEndpoint,
  589. Handler: provisionDOKSHandler,
  590. Router: r,
  591. })
  592. // POST /api/projects/{project_id}/provision/gcr -> provision.NewProvisionGCRHandler
  593. provisionGCREndpoint := factory.NewAPIEndpoint(
  594. &types.APIRequestMetadata{
  595. Verb: types.APIVerbCreate,
  596. Method: types.HTTPVerbPost,
  597. Path: &types.Path{
  598. Parent: basePath,
  599. RelativePath: relPath + "/provision/gcr",
  600. },
  601. Scopes: []types.PermissionScope{
  602. types.UserScope,
  603. types.ProjectScope,
  604. },
  605. },
  606. )
  607. provisionGCRHandler := provision.NewProvisionGCRHandler(
  608. config,
  609. factory.GetDecoderValidator(),
  610. factory.GetResultWriter(),
  611. )
  612. routes = append(routes, &Route{
  613. Endpoint: provisionGCREndpoint,
  614. Handler: provisionGCRHandler,
  615. Router: r,
  616. })
  617. // POST /api/projects/{project_id}/provision/gke -> provision.NewProvisionGKEHandler
  618. provisionGKEEndpoint := factory.NewAPIEndpoint(
  619. &types.APIRequestMetadata{
  620. Verb: types.APIVerbCreate,
  621. Method: types.HTTPVerbPost,
  622. Path: &types.Path{
  623. Parent: basePath,
  624. RelativePath: relPath + "/provision/gke",
  625. },
  626. Scopes: []types.PermissionScope{
  627. types.UserScope,
  628. types.ProjectScope,
  629. },
  630. CheckUsage: true,
  631. UsageMetric: types.Clusters,
  632. },
  633. )
  634. provisionGKEHandler := provision.NewProvisionGKEHandler(
  635. config,
  636. factory.GetDecoderValidator(),
  637. factory.GetResultWriter(),
  638. )
  639. routes = append(routes, &Route{
  640. Endpoint: provisionGKEEndpoint,
  641. Handler: provisionGKEHandler,
  642. Router: r,
  643. })
  644. return routes, newPath
  645. }