porter_app.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/server/handlers/porter_app"
  6. "github.com/porter-dev/porter/internal/models"
  7. appInternal "github.com/porter-dev/porter/internal/porter_app"
  8. v2 "github.com/porter-dev/porter/internal/porter_app/v2"
  9. "github.com/porter-dev/porter/api/types"
  10. )
  11. func (c *Client) NewGetPorterApp(
  12. ctx context.Context,
  13. projectID, clusterID uint,
  14. appName string,
  15. ) (*types.PorterApp, error) {
  16. resp := &types.PorterApp{}
  17. err := c.getRequest(
  18. fmt.Sprintf(
  19. "/projects/%d/clusters/%d/applications/%s",
  20. projectID, clusterID, appName,
  21. ),
  22. nil,
  23. resp,
  24. )
  25. return resp, err
  26. }
  27. func (c *Client) NewCreatePorterApp(
  28. ctx context.Context,
  29. projectID, clusterID uint,
  30. appName string,
  31. req *types.CreatePorterAppRequest,
  32. ) (*types.PorterApp, error) {
  33. resp := &types.PorterApp{}
  34. err := c.postRequest(
  35. fmt.Sprintf(
  36. "/projects/%d/clusters/%d/applications/%s",
  37. projectID, clusterID, appName,
  38. ),
  39. req,
  40. resp,
  41. )
  42. return resp, err
  43. }
  44. // NewCreateOrUpdatePorterAppEvent will create a porter app event if one does not exist, or else it will update the existing one if an ID is passed in the object
  45. func (c *Client) NewCreateOrUpdatePorterAppEvent(
  46. ctx context.Context,
  47. projectID, clusterID uint,
  48. appName string,
  49. req *types.CreateOrUpdatePorterAppEventRequest,
  50. ) (types.PorterAppEvent, error) {
  51. resp := &types.PorterAppEvent{}
  52. err := c.postRequest(
  53. fmt.Sprintf(
  54. "/projects/%d/clusters/%d/applications/%s/events",
  55. projectID, clusterID, appName,
  56. ),
  57. req,
  58. resp,
  59. )
  60. return *resp, err
  61. }
  62. // TODO: remove these functions once they are no longer called (check telemetry)
  63. func (c *Client) GetPorterApp(
  64. ctx context.Context,
  65. projectID, clusterID uint,
  66. stackName string,
  67. ) (*types.PorterApp, error) {
  68. resp := &types.PorterApp{}
  69. err := c.getRequest(
  70. fmt.Sprintf(
  71. "/projects/%d/clusters/%d/stacks/%s",
  72. projectID, clusterID, stackName,
  73. ),
  74. nil,
  75. resp,
  76. )
  77. return resp, err
  78. }
  79. func (c *Client) CreatePorterApp(
  80. ctx context.Context,
  81. projectID, clusterID uint,
  82. name string,
  83. req *types.CreatePorterAppRequest,
  84. ) (*types.PorterApp, error) {
  85. resp := &types.PorterApp{}
  86. err := c.postRequest(
  87. fmt.Sprintf(
  88. "/projects/%d/clusters/%d/stacks/%s",
  89. projectID, clusterID, name,
  90. ),
  91. req,
  92. resp,
  93. )
  94. return resp, err
  95. }
  96. // CreateOrUpdatePorterAppEvent will create a porter app event if one does not exist, or else it will update the existing one if an ID is passed in the object
  97. func (c *Client) CreateOrUpdatePorterAppEvent(
  98. ctx context.Context,
  99. projectID, clusterID uint,
  100. name string,
  101. req *types.CreateOrUpdatePorterAppEventRequest,
  102. ) (types.PorterAppEvent, error) {
  103. resp := &types.PorterAppEvent{}
  104. err := c.postRequest(
  105. fmt.Sprintf(
  106. "/projects/%d/clusters/%d/stacks/%s/events",
  107. projectID, clusterID, name,
  108. ),
  109. req,
  110. resp,
  111. )
  112. return *resp, err
  113. }
  114. // ListEnvGroups (List all Env Groups for a given cluster)
  115. func (c *Client) ListEnvGroups(
  116. ctx context.Context,
  117. projectID, clusterID uint,
  118. ) (types.ListEnvironmentGroupsResponse, error) {
  119. resp := &types.ListEnvironmentGroupsResponse{}
  120. err := c.getRequest(
  121. fmt.Sprintf(
  122. "/projects/%d/clusters/%d/environment-groups",
  123. projectID, clusterID,
  124. ),
  125. nil,
  126. resp,
  127. )
  128. return *resp, err
  129. }
  130. // ParseYAML takes in a base64 encoded porter yaml and returns an app proto
  131. func (c *Client) ParseYAML(
  132. ctx context.Context,
  133. projectID, clusterID uint,
  134. b64Yaml string,
  135. appName string,
  136. patchOperations []v2.PatchOperation,
  137. ) (*porter_app.ParsePorterYAMLToProtoResponse, error) {
  138. resp := &porter_app.ParsePorterYAMLToProtoResponse{}
  139. req := &porter_app.ParsePorterYAMLToProtoRequest{
  140. B64Yaml: b64Yaml,
  141. AppName: appName,
  142. PatchOperations: patchOperations,
  143. }
  144. err := c.postRequest(
  145. fmt.Sprintf(
  146. "/projects/%d/clusters/%d/apps/parse",
  147. projectID, clusterID,
  148. ),
  149. req,
  150. resp,
  151. )
  152. return resp, err
  153. }
  154. // GetAppManifests returns the manifests for a given app based on the latest successful app revision
  155. func (c *Client) GetAppManifests(
  156. ctx context.Context,
  157. projectID, clusterID uint,
  158. appName string,
  159. ) (*porter_app.AppManifestsResponse, error) {
  160. resp := &porter_app.AppManifestsResponse{}
  161. err := c.getRequest(
  162. fmt.Sprintf(
  163. "/projects/%d/clusters/%d/apps/%s/manifests",
  164. projectID, clusterID, appName,
  165. ),
  166. nil,
  167. resp,
  168. )
  169. return resp, err
  170. }
  171. // UpdateAppInput is the input struct to UpdateApp
  172. type UpdateAppInput struct {
  173. ProjectID uint
  174. ClusterID uint
  175. Name string
  176. ImageTagOverride string
  177. GitSource porter_app.GitSource
  178. DeploymentTargetId string
  179. DeploymentTargetName string
  180. CommitSHA string
  181. AppRevisionID string
  182. Base64AppProto string
  183. Base64PorterYAML string
  184. IsEnvOverride bool
  185. WithPredeploy bool
  186. Exact bool
  187. Variables map[string]string
  188. Secrets map[string]string
  189. Deletions porter_app.Deletions
  190. }
  191. // UpdateApp updates a porter app
  192. func (c *Client) UpdateApp(
  193. ctx context.Context,
  194. inp UpdateAppInput,
  195. ) (*porter_app.UpdateAppResponse, error) {
  196. resp := &porter_app.UpdateAppResponse{}
  197. req := &porter_app.UpdateAppRequest{
  198. Name: inp.Name,
  199. GitSource: inp.GitSource,
  200. DeploymentTargetId: inp.DeploymentTargetId,
  201. DeploymentTargetName: inp.DeploymentTargetName,
  202. CommitSHA: inp.CommitSHA,
  203. ImageTagOverride: inp.ImageTagOverride,
  204. AppRevisionID: inp.AppRevisionID,
  205. Base64AppProto: inp.Base64AppProto,
  206. Base64PorterYAML: inp.Base64PorterYAML,
  207. IsEnvOverride: inp.IsEnvOverride,
  208. WithPredeploy: inp.WithPredeploy,
  209. Exact: inp.Exact,
  210. Variables: inp.Variables,
  211. Secrets: inp.Secrets,
  212. Deletions: inp.Deletions,
  213. }
  214. err := c.postRequest(
  215. fmt.Sprintf(
  216. "/projects/%d/clusters/%d/apps/update",
  217. inp.ProjectID, inp.ClusterID,
  218. ),
  219. req,
  220. resp,
  221. )
  222. return resp, err
  223. }
  224. // DefaultDeploymentTarget returns the default deployment target for a given project and cluster
  225. func (c *Client) DefaultDeploymentTarget(
  226. ctx context.Context,
  227. projectID, clusterID uint,
  228. ) (*porter_app.DefaultDeploymentTargetResponse, error) {
  229. resp := &porter_app.DefaultDeploymentTargetResponse{}
  230. req := &porter_app.DefaultDeploymentTargetRequest{}
  231. err := c.getRequest(
  232. fmt.Sprintf(
  233. "/projects/%d/clusters/%d/default-deployment-target",
  234. projectID, clusterID,
  235. ),
  236. req,
  237. resp,
  238. )
  239. return resp, err
  240. }
  241. // CurrentAppRevisionInput is the input struct to CurrentAppRevision
  242. type CurrentAppRevisionInput struct {
  243. ProjectID uint
  244. ClusterID uint
  245. AppName string
  246. // DeploymentTargetName is the name of the deployment target to get the current app revision for. One of this or DeploymentTargetID must be set.
  247. DeploymentTargetName string
  248. // DeploymentTargetID is the id of the deployment target to get the current app revision for. One of this or DeploymentTargetName must be set.
  249. DeploymentTargetID string
  250. }
  251. // CurrentAppRevision returns the currently deployed app revision for a given project, app name and deployment target
  252. func (c *Client) CurrentAppRevision(
  253. ctx context.Context,
  254. input CurrentAppRevisionInput,
  255. ) (*porter_app.LatestAppRevisionResponse, error) {
  256. resp := &porter_app.LatestAppRevisionResponse{}
  257. req := &porter_app.LatestAppRevisionRequest{
  258. DeploymentTargetName: input.DeploymentTargetName,
  259. DeploymentTargetID: input.DeploymentTargetID,
  260. }
  261. err := c.getRequest(
  262. fmt.Sprintf(
  263. "/projects/%d/clusters/%d/apps/%s/latest",
  264. input.ProjectID, input.ClusterID, input.AppName,
  265. ),
  266. req,
  267. resp,
  268. )
  269. return resp, err
  270. }
  271. // CreatePorterAppDBEntryInput is the input struct to CreatePorterAppDBEntry
  272. type CreatePorterAppDBEntryInput struct {
  273. AppName string
  274. GitRepoName string
  275. GitRepoID uint
  276. GitBranch string
  277. ImageRepository string
  278. PorterYamlPath string
  279. ImageTag string
  280. Local bool
  281. DeploymentTargetID string
  282. }
  283. // CreatePorterAppDBEntry creates an entry in the porter app
  284. func (c *Client) CreatePorterAppDBEntry(
  285. ctx context.Context,
  286. projectID uint, clusterID uint,
  287. inp CreatePorterAppDBEntryInput,
  288. ) error {
  289. var sourceType appInternal.SourceType
  290. var image *appInternal.Image
  291. if inp.Local {
  292. sourceType = appInternal.SourceType_Local
  293. }
  294. if inp.GitRepoName != "" {
  295. sourceType = appInternal.SourceType_Github
  296. }
  297. if inp.ImageRepository != "" {
  298. sourceType = appInternal.SourceType_DockerRegistry
  299. image = &appInternal.Image{
  300. Repository: inp.ImageRepository,
  301. Tag: inp.ImageTag,
  302. }
  303. }
  304. req := &porter_app.CreateAppRequest{
  305. Name: inp.AppName,
  306. SourceType: sourceType,
  307. GitSource: porter_app.GitSource{
  308. GitBranch: inp.GitBranch,
  309. GitRepoName: inp.GitRepoName,
  310. GitRepoID: inp.GitRepoID,
  311. },
  312. Image: image,
  313. PorterYamlPath: inp.PorterYamlPath,
  314. DeploymentTargetID: inp.DeploymentTargetID,
  315. }
  316. err := c.postRequest(
  317. fmt.Sprintf(
  318. "/projects/%d/clusters/%d/apps/create",
  319. projectID, clusterID,
  320. ),
  321. req,
  322. &types.PorterApp{},
  323. )
  324. return err
  325. }
  326. // CreateSubdomain returns a subdomain for a given service that point to the ingress-nginx service in the cluster
  327. func (c *Client) CreateSubdomain(
  328. ctx context.Context,
  329. projectID uint, clusterID uint,
  330. appName string, serviceName string,
  331. ) (*porter_app.CreateSubdomainResponse, error) {
  332. resp := &porter_app.CreateSubdomainResponse{}
  333. req := &porter_app.CreateSubdomainRequest{
  334. ServiceName: serviceName,
  335. }
  336. err := c.postRequest(
  337. fmt.Sprintf(
  338. "/projects/%d/clusters/%d/apps/%s/subdomain",
  339. projectID, clusterID, appName,
  340. ),
  341. req,
  342. resp,
  343. )
  344. return resp, err
  345. }
  346. // PredeployStatus checks the current status of a predeploy job for an app revision
  347. func (c *Client) PredeployStatus(
  348. ctx context.Context,
  349. projectID uint, clusterID uint,
  350. appName string, appRevisionId string,
  351. ) (*porter_app.PredeployStatusResponse, error) {
  352. resp := &porter_app.PredeployStatusResponse{}
  353. err := c.getRequest(
  354. fmt.Sprintf(
  355. "/projects/%d/clusters/%d/apps/%s/%s/predeploy-status",
  356. projectID, clusterID, appName, appRevisionId,
  357. ),
  358. nil,
  359. resp,
  360. )
  361. if resp.Status == "" {
  362. return nil, fmt.Errorf("no predeploy status found")
  363. }
  364. return resp, err
  365. }
  366. // GetRevision returns an app revision
  367. func (c *Client) GetRevision(
  368. ctx context.Context,
  369. projectID uint, clusterID uint,
  370. appName string, appRevisionId string,
  371. ) (*porter_app.GetAppRevisionResponse, error) {
  372. resp := &porter_app.GetAppRevisionResponse{}
  373. err := c.getRequest(
  374. fmt.Sprintf(
  375. "/projects/%d/clusters/%d/apps/%s/revisions/%s",
  376. projectID, clusterID, appName, appRevisionId,
  377. ),
  378. nil,
  379. resp,
  380. )
  381. return resp, err
  382. }
  383. // GetRevisionStatus returns the status of an app revision
  384. func (c *Client) GetRevisionStatus(
  385. ctx context.Context,
  386. projectID uint, clusterID uint,
  387. appName string, appRevisionId string,
  388. ) (*porter_app.GetAppRevisionStatusResponse, error) {
  389. resp := &porter_app.GetAppRevisionStatusResponse{}
  390. err := c.getRequest(
  391. fmt.Sprintf(
  392. "/projects/%d/clusters/%d/apps/%s/revisions/%s/status",
  393. projectID, clusterID, appName, appRevisionId,
  394. ),
  395. nil,
  396. resp,
  397. )
  398. return resp, err
  399. }
  400. // UpdateRevisionStatus updates the status of an app revision
  401. func (c *Client) UpdateRevisionStatus(
  402. ctx context.Context,
  403. projectID uint, clusterID uint,
  404. appName string, appRevisionId string,
  405. status models.AppRevisionStatus,
  406. ) (*porter_app.UpdateAppRevisionStatusResponse, error) {
  407. resp := &porter_app.UpdateAppRevisionStatusResponse{}
  408. req := &porter_app.UpdateAppRevisionStatusRequest{
  409. Status: status,
  410. }
  411. err := c.postRequest(
  412. fmt.Sprintf(
  413. "/projects/%d/clusters/%d/apps/%s/revisions/%s",
  414. projectID, clusterID, appName, appRevisionId,
  415. ),
  416. req,
  417. resp,
  418. )
  419. return resp, err
  420. }
  421. // GetBuildEnv returns the build environment for a given app proto
  422. func (c *Client) GetBuildEnv(
  423. ctx context.Context,
  424. projectID uint, clusterID uint,
  425. appName string, appRevisionId string,
  426. ) (*porter_app.GetBuildEnvResponse, error) {
  427. resp := &porter_app.GetBuildEnvResponse{}
  428. err := c.getRequest(
  429. fmt.Sprintf(
  430. "/projects/%d/clusters/%d/apps/%s/revisions/%s/build-env",
  431. projectID, clusterID, appName, appRevisionId,
  432. ),
  433. nil,
  434. resp,
  435. )
  436. return resp, err
  437. }
  438. // GetAppEnvVariables returns all env variables for a given app
  439. func (c *Client) GetAppEnvVariables(
  440. ctx context.Context,
  441. projectID uint, clusterID uint,
  442. appName string,
  443. deploymentTargetName string,
  444. ) (*porter_app.AppEnvVariablesResponse, error) {
  445. resp := &porter_app.AppEnvVariablesResponse{}
  446. req := &porter_app.AppEnvVariablesRequest{
  447. DeploymentTargetName: deploymentTargetName,
  448. }
  449. err := c.getRequest(
  450. fmt.Sprintf(
  451. "/projects/%d/clusters/%d/apps/%s/env-variables",
  452. projectID, clusterID, appName,
  453. ),
  454. req,
  455. resp,
  456. )
  457. return resp, err
  458. }
  459. // GetBuildFromRevision returns the build environment for a given app proto
  460. func (c *Client) GetBuildFromRevision(
  461. ctx context.Context,
  462. projectID uint, clusterID uint,
  463. appName string, appRevisionId string,
  464. ) (*porter_app.GetBuildFromRevisionResponse, error) {
  465. resp := &porter_app.GetBuildFromRevisionResponse{}
  466. err := c.getRequest(
  467. fmt.Sprintf(
  468. "/projects/%d/clusters/%d/apps/%s/revisions/%s/build",
  469. projectID, clusterID, appName, appRevisionId,
  470. ),
  471. nil,
  472. resp,
  473. )
  474. return resp, err
  475. }
  476. // ReportRevisionStatusInput is the input struct to ReportRevisionStatus
  477. type ReportRevisionStatusInput struct {
  478. ProjectID uint
  479. ClusterID uint
  480. AppName string
  481. AppRevisionID string
  482. PRNumber int
  483. CommitSHA string
  484. }
  485. // ReportRevisionStatus reports the status of an app revision to external services
  486. func (c *Client) ReportRevisionStatus(
  487. ctx context.Context,
  488. inp ReportRevisionStatusInput,
  489. ) (*porter_app.ReportRevisionStatusResponse, error) {
  490. resp := &porter_app.ReportRevisionStatusResponse{}
  491. req := &porter_app.ReportRevisionStatusRequest{
  492. PRNumber: inp.PRNumber,
  493. CommitSHA: inp.CommitSHA,
  494. }
  495. err := c.postRequest(
  496. fmt.Sprintf(
  497. "/projects/%d/clusters/%d/apps/%s/revisions/%s/status",
  498. inp.ProjectID, inp.ClusterID, inp.AppName, inp.AppRevisionID,
  499. ),
  500. req,
  501. resp,
  502. )
  503. return resp, err
  504. }
  505. // PorterYamlV2Pods gets all pods for a given deployment target id and app name
  506. func (c *Client) PorterYamlV2Pods(
  507. ctx context.Context,
  508. projectID, clusterID uint,
  509. porterAppName string,
  510. deploymentTargetName string,
  511. ) (*types.GetReleaseAllPodsResponse, error) {
  512. req := &porter_app.PodStatusRequest{
  513. DeploymentTargetName: deploymentTargetName,
  514. }
  515. resp := &types.GetReleaseAllPodsResponse{}
  516. err := c.getRequest(
  517. fmt.Sprintf(
  518. "/projects/%d/clusters/%d/apps/%s/pods",
  519. projectID, clusterID,
  520. porterAppName,
  521. ),
  522. req,
  523. resp,
  524. )
  525. return resp, err
  526. }
  527. // UpdateImage updates the image for a porter app (porter yaml v2 only)
  528. func (c *Client) UpdateImage(
  529. ctx context.Context,
  530. projectID, clusterID uint,
  531. appName, deploymentTargetName, tag string,
  532. ) (*porter_app.UpdateImageResponse, error) {
  533. req := &porter_app.UpdateImageRequest{
  534. Tag: tag,
  535. DeploymentTargetName: deploymentTargetName,
  536. }
  537. resp := &porter_app.UpdateImageResponse{}
  538. err := c.postRequest(
  539. fmt.Sprintf(
  540. "/projects/%d/clusters/%d/apps/%s/update-image",
  541. projectID, clusterID, appName,
  542. ),
  543. &req,
  544. resp,
  545. )
  546. return resp, err
  547. }
  548. // ListAppRevisions lists the last ten app revisions for a given app
  549. func (c *Client) ListAppRevisions(
  550. ctx context.Context,
  551. projectID, clusterID uint,
  552. appName string,
  553. deploymentTargetID string,
  554. ) (*porter_app.ListAppRevisionsResponse, error) {
  555. resp := &porter_app.ListAppRevisionsResponse{}
  556. req := &porter_app.ListAppRevisionsRequest{
  557. DeploymentTargetID: deploymentTargetID,
  558. }
  559. err := c.getRequest(
  560. fmt.Sprintf(
  561. "/projects/%d/clusters/%d/apps/%s/revisions",
  562. projectID, clusterID,
  563. appName,
  564. ),
  565. req,
  566. resp,
  567. )
  568. return resp, err
  569. }
  570. // RollbackRevision reverts an app to a previous revision
  571. func (c *Client) RollbackRevision(
  572. ctx context.Context,
  573. projectID, clusterID uint,
  574. appName string,
  575. deploymentTargetName string,
  576. ) (*porter_app.RollbackAppRevisionResponse, error) {
  577. resp := &porter_app.RollbackAppRevisionResponse{}
  578. req := &porter_app.RollbackAppRevisionRequest{
  579. DeploymentTargetName: deploymentTargetName,
  580. }
  581. err := c.postRequest(
  582. fmt.Sprintf(
  583. "/projects/%d/clusters/%d/apps/%s/rollback",
  584. projectID, clusterID,
  585. appName,
  586. ),
  587. req,
  588. resp,
  589. )
  590. return resp, err
  591. }
  592. // RunAppJob runs a job for an app
  593. func (c *Client) RunAppJob(
  594. ctx context.Context,
  595. projectID, clusterID uint,
  596. appName string, jobName string,
  597. deploymentTargetName string,
  598. ) (*porter_app.RunAppJobResponse, error) {
  599. resp := &porter_app.RunAppJobResponse{}
  600. req := &porter_app.RunAppJobRequest{
  601. ServiceName: jobName,
  602. DeploymentTargetName: deploymentTargetName,
  603. }
  604. err := c.postRequest(
  605. fmt.Sprintf(
  606. "/projects/%d/clusters/%d/apps/%s/run",
  607. projectID, clusterID,
  608. appName,
  609. ),
  610. req,
  611. resp,
  612. )
  613. return resp, err
  614. }
  615. // RunAppJobStatusInput contains all the information necessary to check the status of a job
  616. type RunAppJobStatusInput struct {
  617. // AppName is the name of the app associated with the job
  618. AppName string
  619. // Cluster is the id of the cluster against which to retrieve a helm agent for
  620. ClusterID uint
  621. // DeploymentTargetName is the id of the deployment target the job was run against
  622. DeploymentTargetName string
  623. // ServiceName is the name of the app service that was triggered
  624. ServiceName string
  625. // JobRunID is the UID returned from the /apps/{porter_app_name}/run endpoint
  626. JobRunID string
  627. // ProjectID is the project in which the cluster exists
  628. ProjectID uint
  629. }
  630. // RunAppJobStatus gets the status for a job app run
  631. func (c *Client) RunAppJobStatus(
  632. ctx context.Context,
  633. input RunAppJobStatusInput,
  634. ) (*porter_app.AppJobRunStatusResponse, error) {
  635. resp := &porter_app.AppJobRunStatusResponse{}
  636. req := &porter_app.AppJobRunStatusRequest{
  637. DeploymentTargetName: input.DeploymentTargetName,
  638. JobRunID: input.JobRunID,
  639. ServiceName: input.ServiceName,
  640. }
  641. err := c.getRequest(
  642. fmt.Sprintf(
  643. "/projects/%d/clusters/%d/apps/%s/run-status",
  644. input.ProjectID, input.ClusterID,
  645. input.AppName,
  646. ),
  647. req,
  648. resp,
  649. )
  650. return resp, err
  651. }