Skip to content

Commit

Permalink
fix(resources): get all build resources (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 authored Aug 7, 2024
1 parent b83bba0 commit 8284887
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 13 deletions.
52 changes: 52 additions & 0 deletions src/elm/Api/Operations.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Api.Operations exposing
, enableRepo
, expandPipelineConfig
, finishAuthentication
, getAllBuildServices
, getAllBuildSteps
, getBuild
, getBuildGraph
, getBuildServiceLog
Expand Down Expand Up @@ -681,6 +683,31 @@ getBuildSteps baseUrl session options =
|> withAuth session


{-| getAllBuildSteps : retrieves all steps for a build.
-}
getAllBuildSteps :
String
-> Session
->
{ a
| org : String
, repo : String
, build : String
}
-> Request Vela.Step
getAllBuildSteps baseUrl session options =
get baseUrl
(Api.Endpoint.Steps
(Just 1)
(Just 100)
options.org
options.repo
options.build
)
Vela.decodeStep
|> withAuth session


{-| getBuildServices : retrieves services for a build.
-}
getBuildServices :
Expand Down Expand Up @@ -708,6 +735,31 @@ getBuildServices baseUrl session options =
|> withAuth session


{-| getAllBuildServices : retrieves all services for a build.
-}
getAllBuildServices :
String
-> Session
->
{ a
| org : String
, repo : String
, build : String
}
-> Request Vela.Service
getAllBuildServices baseUrl session options =
get baseUrl
(Api.Endpoint.Services
(Just 1)
(Just 100)
options.org
options.repo
options.build
)
Vela.decodeService
|> withAuth session


{-| getBuildStepLog : retrieves a log for a step.
-}
getBuildStepLog :
Expand Down
42 changes: 41 additions & 1 deletion src/elm/Effect.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Effect exposing
, sendCmd, sendMsg
, pushRoute, replaceRoute, loadExternalUrl
, map, toCmd
, addAlertError, addAlertSuccess, addDeployment, addFavorites, addOrgSecret, addRepoSchedule, addRepoSecret, addSharedSecret, alertsUpdate, approveBuild, cancelBuild, chownRepo, clearRedirect, deleteOrgSecret, deleteRepoSchedule, deleteRepoSecret, deleteSharedSecret, disableRepo, downloadFile, enableRepo, expandPipelineConfig, finishAuthentication, focusOn, getBuild, getBuildGraph, getBuildServiceLog, getBuildServices, getBuildStepLog, getBuildSteps, getCurrentUser, getCurrentUserShared, getDashboard, getOrgBuilds, getOrgRepos, getOrgSecret, getOrgSecrets, getPipelineConfig, getPipelineTemplates, getRepo, getRepoBuilds, getRepoBuildsShared, getRepoDeployments, getRepoHooks, getRepoHooksShared, getRepoSchedule, getRepoSchedules, getRepoSecret, getRepoSecrets, getSettings, getSharedSecret, getSharedSecrets, getWorkers, handleHttpError, logout, pushPath, redeliverHook, repairRepo, replacePath, replaceRouteRemoveTabHistorySkipDomFocus, restartBuild, setRedirect, setTheme, updateFavicon, updateFavorite, updateOrgSecret, updateRepo, updateRepoHooksShared, updateRepoSchedule, updateRepoSecret, updateSettings, updateSharedSecret, updateSourceReposShared
, addAlertError, addAlertSuccess, addDeployment, addFavorites, addOrgSecret, addRepoSchedule, addRepoSecret, addSharedSecret, alertsUpdate, approveBuild, cancelBuild, chownRepo, clearRedirect, deleteOrgSecret, deleteRepoSchedule, deleteRepoSecret, deleteSharedSecret, disableRepo, downloadFile, enableRepo, expandPipelineConfig, finishAuthentication, focusOn, getAllBuildServices, getAllBuildSteps, getBuild, getBuildGraph, getBuildServiceLog, getBuildServices, getBuildStepLog, getBuildSteps, getCurrentUser, getCurrentUserShared, getDashboard, getOrgBuilds, getOrgRepos, getOrgSecret, getOrgSecrets, getPipelineConfig, getPipelineTemplates, getRepo, getRepoBuilds, getRepoBuildsShared, getRepoDeployments, getRepoHooks, getRepoHooksShared, getRepoSchedule, getRepoSchedules, getRepoSecret, getRepoSecrets, getSettings, getSharedSecret, getSharedSecrets, getWorkers, handleHttpError, logout, pushPath, redeliverHook, repairRepo, replacePath, replaceRouteRemoveTabHistorySkipDomFocus, restartBuild, setRedirect, setTheme, updateFavicon, updateFavorite, updateOrgSecret, updateRepo, updateRepoHooksShared, updateRepoSchedule, updateRepoSecret, updateSettings, updateSharedSecret, updateSourceReposShared
)

{-|
Expand Down Expand Up @@ -796,6 +796,26 @@ getBuildSteps options =
|> sendCmd


getAllBuildSteps :
{ baseUrl : String
, session : Auth.Session.Session
, onResponse : Result (Http.Detailed.Error String) ( Http.Metadata, List Vela.Step ) -> msg
, org : String
, repo : String
, build : String
}
-> Effect msg
getAllBuildSteps options =
Api.tryAll
options.onResponse
(Api.Operations.getAllBuildSteps
options.baseUrl
options.session
options
)
|> sendCmd


getBuildServices :
{ baseUrl : String
, session : Auth.Session.Session
Expand All @@ -818,6 +838,26 @@ getBuildServices options =
|> sendCmd


getAllBuildServices :
{ baseUrl : String
, session : Auth.Session.Session
, onResponse : Result (Http.Detailed.Error String) ( Http.Metadata, List Vela.Service ) -> msg
, org : String
, repo : String
, build : String
}
-> Effect msg
getAllBuildServices options =
Api.tryAll
options.onResponse
(Api.Operations.getAllBuildServices
options.baseUrl
options.session
options
)
|> sendCmd


getBuildStepLog :
{ baseUrl : String
, session : Auth.Session.Session
Expand Down
8 changes: 2 additions & 6 deletions src/elm/Pages/Org_/Repo_/Build_.elm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ init shared route () =
, logFollow = 0
}
, Effect.batch
[ Effect.getBuildSteps
[ Effect.getAllBuildSteps
{ baseUrl = shared.velaAPIBaseURL
, session = shared.session
, onResponse =
Expand All @@ -206,8 +206,6 @@ init shared route () =
|> Maybe.withDefault "false"
|> (==) "false"
}
, pageNumber = Nothing
, perPage = Just 100
, org = route.params.org
, repo = route.params.repo
, build = route.params.build
Expand Down Expand Up @@ -625,12 +623,10 @@ update shared route msg model =

runEffect =
if isAnyStepRunning then
Effect.getBuildSteps
Effect.getAllBuildSteps
{ baseUrl = shared.velaAPIBaseURL
, session = shared.session
, onResponse = GetBuildStepsRefreshResponse
, pageNumber = Nothing
, perPage = Just 100
, org = route.params.org
, repo = route.params.repo
, build = route.params.build
Expand Down
8 changes: 2 additions & 6 deletions src/elm/Pages/Org_/Repo_/Build_/Services.elm
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,10 @@ init shared route () =
, logFollow = 0
}
, Effect.batch
[ Effect.getBuildServices
[ Effect.getAllBuildServices
{ baseUrl = shared.velaAPIBaseURL
, session = shared.session
, onResponse = GetBuildServicesResponse
, pageNumber = Nothing
, perPage = Just 100
, org = route.params.org
, repo = route.params.repo
, build = route.params.build
Expand Down Expand Up @@ -617,12 +615,10 @@ update shared route msg model =

runEffect =
if isAnyServiceRunning then
Effect.getBuildServices
Effect.getAllBuildServices
{ baseUrl = shared.velaAPIBaseURL
, session = shared.session
, onResponse = GetBuildServicesRefreshResponse
, pageNumber = Nothing
, perPage = Just 100
, org = route.params.org
, repo = route.params.repo
, build = route.params.build
Expand Down
2 changes: 2 additions & 0 deletions src/elm/Vela.elm
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ module Vela exposing
, decodeSchedules
, decodeSecret
, decodeSecrets
, decodeService
, decodeServices
, decodeSettings
, decodeSourceRepositories
, decodeStep
, decodeSteps
, decodeUser
, decodeWorkers
Expand Down

0 comments on commit 8284887

Please sign in to comment.