Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(deployments): use scm default for target and adjust ref resolution #720

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,11 @@ update msg model =
RepoResponse response ->
case response of
Ok ( _, repoResponse ) ->
( { model | repo = updateRepo (RemoteData.succeed repoResponse) rm }, Cmd.none )
let
dm =
model.deploymentModel
in
( { model | repo = updateRepo (RemoteData.succeed repoResponse) rm, deploymentModel = { dm | repo_settings = RemoteData.succeed repoResponse } }, Cmd.none )

Err error ->
( { model | repo = updateRepo (toFailure error) rm }, addError error )
Expand Down Expand Up @@ -3452,7 +3456,7 @@ loadRepoSubPage model org repo toPage =
{ dm
| org = org
, repo = repo
, repo_settings = rm.repo
, repo_settings = model.repo.repo
, form = form
}
, repo =
Expand Down Expand Up @@ -3607,7 +3611,7 @@ loadRepoSubPage model org repo toPage =

-- page is not a repo subpage
_ ->
( model, Cmd.none )
( model, getRepo model org repo )
in
( { loadModel | page = toPage }, loadCmd )

Expand Down
14 changes: 2 additions & 12 deletions src/elm/Pages/Deployments/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,8 @@ applyDefaults form =
form.description
)
form.payload
(if form.ref == "" then
"refs/heads/master"

else
form.ref
)
(if form.target == "" then
"production"

else
form.target
)
form.ref
form.target
(if form.task == "" then
"deploy:vela"

Expand Down
12 changes: 11 additions & 1 deletion src/elm/Pages/Deployments/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,22 @@ addForm deploymentModel =
let
deployment =
deploymentModel.form

branch =
case deploymentModel.repo_settings of
RemoteData.Success repo ->
repo.branch

_ ->
""
in
div [ class "deployment-form" ]
[ h2 [ class "deployment-header" ] [ text "Add Deployment" ]
, viewDeployEnabled deploymentModel.repo_settings

-- GitHub default is "production". If we support more SCMs, this line may need tweaking
, viewValueInput "Target" deployment.target "provide the name for the target deployment environment (default: \"production\")"
, viewValueInput "Ref" deployment.ref "provide the reference to deploy - this can be a branch, commit (SHA) or tag (default: \"refs/heads/master\")"
, viewValueInput "Ref" deployment.ref <| "provide the reference to deploy - this can be a branch, commit (SHA) or tag (default: " ++ branch ++ ")"
, viewValueInput "Description" deployment.description "provide the description for the deployment (default: \"Deployment request from Vela\")"
, viewValueInput "Task" deployment.task "Provide the task for the deployment (default: \"deploy:vela\")"
, viewParameterInput deployment
Expand Down
Loading