release.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. package router
  2. import (
  3. "github.com/go-chi/chi"
  4. "github.com/porter-dev/porter/api/server/handlers/release"
  5. "github.com/porter-dev/porter/api/server/shared"
  6. "github.com/porter-dev/porter/api/server/shared/config"
  7. "github.com/porter-dev/porter/api/types"
  8. )
  9. func NewReleaseScopedRegisterer(children ...*Registerer) *Registerer {
  10. return &Registerer{
  11. GetRoutes: GetReleaseScopedRoutes,
  12. Children: children,
  13. }
  14. }
  15. func GetReleaseScopedRoutes(
  16. r chi.Router,
  17. config *config.Config,
  18. basePath *types.Path,
  19. factory shared.APIEndpointFactory,
  20. children ...*Registerer,
  21. ) []*Route {
  22. routes, projPath := getReleaseRoutes(r, config, basePath, factory)
  23. if len(children) > 0 {
  24. r.Route(projPath.RelativePath, func(r chi.Router) {
  25. for _, child := range children {
  26. childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
  27. routes = append(routes, childRoutes...)
  28. }
  29. })
  30. }
  31. return routes
  32. }
  33. func getReleaseRoutes(
  34. r chi.Router,
  35. config *config.Config,
  36. basePath *types.Path,
  37. factory shared.APIEndpointFactory,
  38. ) ([]*Route, *types.Path) {
  39. relPath := "/releases/{name}/{version}"
  40. newPath := &types.Path{
  41. Parent: basePath,
  42. RelativePath: relPath,
  43. }
  44. routes := make([]*Route, 0)
  45. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version} -> release.NewReleaseGetHandler
  46. getEndpoint := factory.NewAPIEndpoint(
  47. &types.APIRequestMetadata{
  48. Verb: types.APIVerbGet,
  49. Method: types.HTTPVerbGet,
  50. Path: &types.Path{
  51. Parent: basePath,
  52. RelativePath: relPath,
  53. },
  54. Scopes: []types.PermissionScope{
  55. types.UserScope,
  56. types.ProjectScope,
  57. types.ClusterScope,
  58. types.NamespaceScope,
  59. types.ReleaseScope,
  60. },
  61. },
  62. )
  63. getHandler := release.NewReleaseGetHandler(
  64. config,
  65. factory.GetResultWriter(),
  66. )
  67. routes = append(routes, &Route{
  68. Endpoint: getEndpoint,
  69. Handler: getHandler,
  70. Router: r,
  71. })
  72. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/form_stream -> release.NewStreamFormHandler
  73. streamFormEndpoint := factory.NewAPIEndpoint(
  74. &types.APIRequestMetadata{
  75. Verb: types.APIVerbGet,
  76. Method: types.HTTPVerbGet,
  77. Path: &types.Path{
  78. Parent: basePath,
  79. RelativePath: relPath + "/form_stream",
  80. },
  81. Scopes: []types.PermissionScope{
  82. types.UserScope,
  83. types.ProjectScope,
  84. types.ClusterScope,
  85. types.NamespaceScope,
  86. types.ReleaseScope,
  87. },
  88. IsWebsocket: true,
  89. },
  90. )
  91. streamFormHandler := release.NewStreamFormHandler(
  92. config,
  93. factory.GetDecoderValidator(),
  94. factory.GetResultWriter(),
  95. )
  96. routes = append(routes, &Route{
  97. Endpoint: streamFormEndpoint,
  98. Handler: streamFormHandler,
  99. Router: r,
  100. })
  101. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/controllers -> release.NewGetControllersHandler
  102. getControllersEndpoint := factory.NewAPIEndpoint(
  103. &types.APIRequestMetadata{
  104. Verb: types.APIVerbGet,
  105. Method: types.HTTPVerbGet,
  106. Path: &types.Path{
  107. Parent: basePath,
  108. RelativePath: relPath + "/controllers",
  109. },
  110. Scopes: []types.PermissionScope{
  111. types.UserScope,
  112. types.ProjectScope,
  113. types.ClusterScope,
  114. types.NamespaceScope,
  115. types.ReleaseScope,
  116. },
  117. },
  118. )
  119. getControllersHandler := release.NewGetControllersHandler(
  120. config,
  121. factory.GetResultWriter(),
  122. )
  123. routes = append(routes, &Route{
  124. Endpoint: getControllersEndpoint,
  125. Handler: getControllersHandler,
  126. Router: r,
  127. })
  128. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/components -> release.NewGetComponentsHandler
  129. getComponentsEndpoint := factory.NewAPIEndpoint(
  130. &types.APIRequestMetadata{
  131. Verb: types.APIVerbGet,
  132. Method: types.HTTPVerbGet,
  133. Path: &types.Path{
  134. Parent: basePath,
  135. RelativePath: relPath + "/components",
  136. },
  137. Scopes: []types.PermissionScope{
  138. types.UserScope,
  139. types.ProjectScope,
  140. types.ClusterScope,
  141. types.NamespaceScope,
  142. types.ReleaseScope,
  143. },
  144. },
  145. )
  146. getComponentsHandler := release.NewGetComponentsHandler(
  147. config,
  148. factory.GetResultWriter(),
  149. )
  150. routes = append(routes, &Route{
  151. Endpoint: getComponentsEndpoint,
  152. Handler: getComponentsHandler,
  153. Router: r,
  154. })
  155. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/history -> release.NewGetHistoryHandler
  156. getHistoryEndpoint := factory.NewAPIEndpoint(
  157. &types.APIRequestMetadata{
  158. Verb: types.APIVerbGet,
  159. Method: types.HTTPVerbGet,
  160. Path: &types.Path{
  161. Parent: basePath,
  162. RelativePath: "/releases/{name}/history",
  163. },
  164. Scopes: []types.PermissionScope{
  165. types.UserScope,
  166. types.ProjectScope,
  167. types.ClusterScope,
  168. types.NamespaceScope,
  169. },
  170. },
  171. )
  172. getHistoryHandler := release.NewGetReleaseHistoryHandler(
  173. config,
  174. factory.GetDecoderValidator(),
  175. factory.GetResultWriter(),
  176. )
  177. routes = append(routes, &Route{
  178. Endpoint: getHistoryEndpoint,
  179. Handler: getHistoryHandler,
  180. Router: r,
  181. })
  182. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/pods/all -> release.NewGetAllPodsHandler
  183. getAllPodsEndpoint := factory.NewAPIEndpoint(
  184. &types.APIRequestMetadata{
  185. Verb: types.APIVerbGet,
  186. Method: types.HTTPVerbGet,
  187. Path: &types.Path{
  188. Parent: basePath,
  189. RelativePath: relPath + "/pods/all",
  190. },
  191. Scopes: []types.PermissionScope{
  192. types.UserScope,
  193. types.ProjectScope,
  194. types.ClusterScope,
  195. types.NamespaceScope,
  196. types.ReleaseScope,
  197. },
  198. },
  199. )
  200. getAllPodsHandler := release.NewGetAllPodsHandler(
  201. config,
  202. factory.GetResultWriter(),
  203. )
  204. routes = append(routes, &Route{
  205. Endpoint: getAllPodsEndpoint,
  206. Handler: getAllPodsHandler,
  207. Router: r,
  208. })
  209. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/notifications -> release.NewUpdateNotificationHandler
  210. updateNotifsEndpoint := factory.NewAPIEndpoint(
  211. &types.APIRequestMetadata{
  212. Verb: types.APIVerbUpdate,
  213. Method: types.HTTPVerbPost,
  214. Path: &types.Path{
  215. Parent: basePath,
  216. RelativePath: "/releases/{name}/notifications",
  217. },
  218. Scopes: []types.PermissionScope{
  219. types.UserScope,
  220. types.ProjectScope,
  221. types.ClusterScope,
  222. types.NamespaceScope,
  223. },
  224. },
  225. )
  226. updateNotifsHandler := release.NewUpdateNotificationHandler(
  227. config,
  228. factory.GetDecoderValidator(),
  229. factory.GetResultWriter(),
  230. )
  231. routes = append(routes, &Route{
  232. Endpoint: updateNotifsEndpoint,
  233. Handler: updateNotifsHandler,
  234. Router: r,
  235. })
  236. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/notifications -> release.NewGetNotificationHandler
  237. getNotifsEndpoint := factory.NewAPIEndpoint(
  238. &types.APIRequestMetadata{
  239. Verb: types.APIVerbGet,
  240. Method: types.HTTPVerbGet,
  241. Path: &types.Path{
  242. Parent: basePath,
  243. RelativePath: "/releases/{name}/notifications",
  244. },
  245. Scopes: []types.PermissionScope{
  246. types.UserScope,
  247. types.ProjectScope,
  248. types.ClusterScope,
  249. types.NamespaceScope,
  250. },
  251. },
  252. )
  253. getNotifsHandler := release.NewGetNotificationHandler(
  254. config,
  255. factory.GetResultWriter(),
  256. )
  257. routes = append(routes, &Route{
  258. Endpoint: getNotifsEndpoint,
  259. Handler: getNotifsHandler,
  260. Router: r,
  261. })
  262. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/webhook -> release.NewGetWebhookHandler
  263. getWebhookEndpoint := factory.NewAPIEndpoint(
  264. &types.APIRequestMetadata{
  265. Verb: types.APIVerbGet,
  266. Method: types.HTTPVerbGet,
  267. Path: &types.Path{
  268. Parent: basePath,
  269. RelativePath: "/releases/{name}/webhook",
  270. },
  271. Scopes: []types.PermissionScope{
  272. types.UserScope,
  273. types.ProjectScope,
  274. types.ClusterScope,
  275. types.NamespaceScope,
  276. },
  277. },
  278. )
  279. getWebhookHandler := release.NewGetWebhookHandler(
  280. config,
  281. factory.GetResultWriter(),
  282. )
  283. routes = append(routes, &Route{
  284. Endpoint: getWebhookEndpoint,
  285. Handler: getWebhookHandler,
  286. Router: r,
  287. })
  288. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/webhook -> release.NewCreateWebhookHandler
  289. createWebhookEndpoint := factory.NewAPIEndpoint(
  290. &types.APIRequestMetadata{
  291. Verb: types.APIVerbCreate,
  292. Method: types.HTTPVerbPost,
  293. Path: &types.Path{
  294. Parent: basePath,
  295. RelativePath: relPath + "/webhook",
  296. },
  297. Scopes: []types.PermissionScope{
  298. types.UserScope,
  299. types.ProjectScope,
  300. types.ClusterScope,
  301. types.NamespaceScope,
  302. types.ReleaseScope,
  303. },
  304. },
  305. )
  306. createWebhookHandler := release.NewCreateWebhookHandler(
  307. config,
  308. factory.GetResultWriter(),
  309. )
  310. routes = append(routes, &Route{
  311. Endpoint: createWebhookEndpoint,
  312. Handler: createWebhookHandler,
  313. Router: r,
  314. })
  315. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/steps -> release.NewGetReleaseStepsHandler
  316. getStepsEndpoint := factory.NewAPIEndpoint(
  317. &types.APIRequestMetadata{
  318. Verb: types.APIVerbGet,
  319. Method: types.HTTPVerbGet,
  320. Path: &types.Path{
  321. Parent: basePath,
  322. RelativePath: "/releases/{name}/steps",
  323. },
  324. Scopes: []types.PermissionScope{
  325. types.UserScope,
  326. types.ProjectScope,
  327. types.ClusterScope,
  328. types.NamespaceScope,
  329. },
  330. },
  331. )
  332. getStepsHandler := release.NewGetReleaseStepsHandler(
  333. config,
  334. factory.GetDecoderValidator(),
  335. factory.GetResultWriter(),
  336. )
  337. routes = append(routes, &Route{
  338. Endpoint: getStepsEndpoint,
  339. Handler: getStepsHandler,
  340. Router: r,
  341. })
  342. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/steps -> release.NewUpdateReleaseStepsHandler
  343. updateStepsEndpoint := factory.NewAPIEndpoint(
  344. &types.APIRequestMetadata{
  345. Verb: types.APIVerbCreate,
  346. Method: types.HTTPVerbPost,
  347. Path: &types.Path{
  348. Parent: basePath,
  349. RelativePath: "/releases/{name}/steps",
  350. },
  351. Scopes: []types.PermissionScope{
  352. types.UserScope,
  353. types.ProjectScope,
  354. types.ClusterScope,
  355. types.NamespaceScope,
  356. },
  357. },
  358. )
  359. updateStepsHandler := release.NewUpdateReleaseStepsHandler(
  360. config,
  361. factory.GetDecoderValidator(),
  362. factory.GetResultWriter(),
  363. )
  364. routes = append(routes, &Route{
  365. Endpoint: updateStepsEndpoint,
  366. Handler: updateStepsHandler,
  367. Router: r,
  368. })
  369. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases -> release.NewCreateReleaseHandler
  370. createReleaseEndpoint := factory.NewAPIEndpoint(
  371. &types.APIRequestMetadata{
  372. Verb: types.APIVerbCreate,
  373. Method: types.HTTPVerbPost,
  374. Path: &types.Path{
  375. Parent: basePath,
  376. RelativePath: "/releases",
  377. },
  378. Scopes: []types.PermissionScope{
  379. types.UserScope,
  380. types.ProjectScope,
  381. types.ClusterScope,
  382. types.NamespaceScope,
  383. },
  384. },
  385. )
  386. createReleaseHandler := release.NewCreateReleaseHandler(
  387. config,
  388. factory.GetDecoderValidator(),
  389. factory.GetResultWriter(),
  390. )
  391. routes = append(routes, &Route{
  392. Endpoint: createReleaseEndpoint,
  393. Handler: createReleaseHandler,
  394. Router: r,
  395. })
  396. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/addons -> release.NewCreateAddonHandler
  397. createAddonEndpoint := factory.NewAPIEndpoint(
  398. &types.APIRequestMetadata{
  399. Verb: types.APIVerbCreate,
  400. Method: types.HTTPVerbPost,
  401. Path: &types.Path{
  402. Parent: basePath,
  403. RelativePath: "/addons",
  404. },
  405. Scopes: []types.PermissionScope{
  406. types.UserScope,
  407. types.ProjectScope,
  408. types.ClusterScope,
  409. types.NamespaceScope,
  410. },
  411. },
  412. )
  413. createAddonHandler := release.NewCreateAddonHandler(
  414. config,
  415. factory.GetDecoderValidator(),
  416. factory.GetResultWriter(),
  417. )
  418. routes = append(routes, &Route{
  419. Endpoint: createAddonEndpoint,
  420. Handler: createAddonHandler,
  421. Router: r,
  422. })
  423. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/gha_template -> release.NewGetGHATemplateHandler
  424. getGHATemplateEndpoint := factory.NewAPIEndpoint(
  425. &types.APIRequestMetadata{
  426. Verb: types.APIVerbGet,
  427. Method: types.HTTPVerbPost,
  428. Path: &types.Path{
  429. Parent: basePath,
  430. RelativePath: "/releases/gha_template",
  431. },
  432. Scopes: []types.PermissionScope{
  433. types.UserScope,
  434. types.ProjectScope,
  435. types.ClusterScope,
  436. types.NamespaceScope,
  437. },
  438. },
  439. )
  440. getGHATemplateHandler := release.NewGetGHATemplateHandler(
  441. config,
  442. factory.GetDecoderValidator(),
  443. factory.GetResultWriter(),
  444. )
  445. routes = append(routes, &Route{
  446. Endpoint: getGHATemplateEndpoint,
  447. Handler: getGHATemplateHandler,
  448. Router: r,
  449. })
  450. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/rollback ->
  451. // release.NewRollbackReleaseHandler
  452. rollbackEndpoint := factory.NewAPIEndpoint(
  453. &types.APIRequestMetadata{
  454. Verb: types.APIVerbUpdate,
  455. Method: types.HTTPVerbPost,
  456. Path: &types.Path{
  457. Parent: basePath,
  458. RelativePath: relPath + "/rollback",
  459. },
  460. Scopes: []types.PermissionScope{
  461. types.UserScope,
  462. types.ProjectScope,
  463. types.ClusterScope,
  464. types.NamespaceScope,
  465. types.ReleaseScope,
  466. },
  467. },
  468. )
  469. rollbackHandler := release.NewRollbackReleaseHandler(
  470. config,
  471. factory.GetDecoderValidator(),
  472. factory.GetResultWriter(),
  473. )
  474. routes = append(routes, &Route{
  475. Endpoint: rollbackEndpoint,
  476. Handler: rollbackHandler,
  477. Router: r,
  478. })
  479. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/upgrade ->
  480. // release.NewUpgradeReleaseHandler
  481. upgradeEndpoint := factory.NewAPIEndpoint(
  482. &types.APIRequestMetadata{
  483. Verb: types.APIVerbUpdate,
  484. Method: types.HTTPVerbPost,
  485. Path: &types.Path{
  486. Parent: basePath,
  487. RelativePath: relPath + "/upgrade",
  488. },
  489. Scopes: []types.PermissionScope{
  490. types.UserScope,
  491. types.ProjectScope,
  492. types.ClusterScope,
  493. types.NamespaceScope,
  494. types.ReleaseScope,
  495. },
  496. },
  497. )
  498. upgradeHandler := release.NewUpgradeReleaseHandler(
  499. config,
  500. factory.GetDecoderValidator(),
  501. factory.GetResultWriter(),
  502. )
  503. routes = append(routes, &Route{
  504. Endpoint: upgradeEndpoint,
  505. Handler: upgradeHandler,
  506. Router: r,
  507. })
  508. // DELETE /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version} ->
  509. // release.NewDeleteReleaseHandler
  510. deleteEndpoint := factory.NewAPIEndpoint(
  511. &types.APIRequestMetadata{
  512. Verb: types.APIVerbDelete,
  513. Method: types.HTTPVerbDelete,
  514. Path: &types.Path{
  515. Parent: basePath,
  516. RelativePath: relPath,
  517. },
  518. Scopes: []types.PermissionScope{
  519. types.UserScope,
  520. types.ProjectScope,
  521. types.ClusterScope,
  522. types.NamespaceScope,
  523. types.ReleaseScope,
  524. },
  525. },
  526. )
  527. deleteHandler := release.NewDeleteReleaseHandler(
  528. config,
  529. factory.GetDecoderValidator(),
  530. factory.GetResultWriter(),
  531. )
  532. routes = append(routes, &Route{
  533. Endpoint: deleteEndpoint,
  534. Handler: deleteHandler,
  535. Router: r,
  536. })
  537. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/image/batch ->
  538. // release.NewUpdateImageBatchHandler
  539. updateImageBatchEndpoint := factory.NewAPIEndpoint(
  540. &types.APIRequestMetadata{
  541. Verb: types.APIVerbUpdate,
  542. Method: types.HTTPVerbPost,
  543. Path: &types.Path{
  544. Parent: basePath,
  545. RelativePath: "/releases/image/batch",
  546. },
  547. Scopes: []types.PermissionScope{
  548. types.UserScope,
  549. types.ProjectScope,
  550. types.ClusterScope,
  551. types.NamespaceScope,
  552. },
  553. },
  554. )
  555. updateImageBatchHandler := release.NewUpdateImageBatchHandler(
  556. config,
  557. factory.GetDecoderValidator(),
  558. factory.GetResultWriter(),
  559. )
  560. routes = append(routes, &Route{
  561. Endpoint: updateImageBatchEndpoint,
  562. Handler: updateImageBatchHandler,
  563. Router: r,
  564. })
  565. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/jobs ->
  566. // release.NewGetJobsHandler
  567. getJobsEndpoint := factory.NewAPIEndpoint(
  568. &types.APIRequestMetadata{
  569. Verb: types.APIVerbGet,
  570. Method: types.HTTPVerbGet,
  571. Path: &types.Path{
  572. Parent: basePath,
  573. RelativePath: relPath + "/jobs",
  574. },
  575. Scopes: []types.PermissionScope{
  576. types.UserScope,
  577. types.ProjectScope,
  578. types.ClusterScope,
  579. types.NamespaceScope,
  580. types.ReleaseScope,
  581. },
  582. },
  583. )
  584. getJobsHandler := release.NewGetJobsHandler(
  585. config,
  586. factory.GetResultWriter(),
  587. )
  588. routes = append(routes, &Route{
  589. Endpoint: getJobsEndpoint,
  590. Handler: getJobsHandler,
  591. Router: r,
  592. })
  593. // GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version}/jobs/status ->
  594. // release.NewGetJobsHandler
  595. getJobsStatusEndpoint := factory.NewAPIEndpoint(
  596. &types.APIRequestMetadata{
  597. Verb: types.APIVerbGet,
  598. Method: types.HTTPVerbGet,
  599. Path: &types.Path{
  600. Parent: basePath,
  601. RelativePath: relPath + "/jobs/status",
  602. },
  603. Scopes: []types.PermissionScope{
  604. types.UserScope,
  605. types.ProjectScope,
  606. types.ClusterScope,
  607. types.NamespaceScope,
  608. types.ReleaseScope,
  609. },
  610. },
  611. )
  612. getJobsStatusHandler := release.NewGetJobsStatusHandler(
  613. config,
  614. factory.GetResultWriter(),
  615. )
  616. routes = append(routes, &Route{
  617. Endpoint: getJobsStatusEndpoint,
  618. Handler: getJobsStatusHandler,
  619. Router: r,
  620. })
  621. // POST /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/subdomain -> release.NewCreateSubdomainHandler
  622. createSubdomainEndpoint := factory.NewAPIEndpoint(
  623. &types.APIRequestMetadata{
  624. Verb: types.APIVerbCreate,
  625. Method: types.HTTPVerbPost,
  626. Path: &types.Path{
  627. Parent: basePath,
  628. RelativePath: "/releases/{name}/subdomain",
  629. },
  630. Scopes: []types.PermissionScope{
  631. types.UserScope,
  632. types.ProjectScope,
  633. types.ClusterScope,
  634. types.NamespaceScope,
  635. },
  636. },
  637. )
  638. createSubdomainHandler := release.NewCreateSubdomainHandler(
  639. config,
  640. factory.GetResultWriter(),
  641. )
  642. routes = append(routes, &Route{
  643. Endpoint: createSubdomainEndpoint,
  644. Handler: createSubdomainHandler,
  645. Router: r,
  646. })
  647. return routes, newPath
  648. }