release.go 18 KB

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