@@ -15,8 +15,14 @@ defmodule Core.Services.Dependencies do
1515 @ spec valid? ( Dependencies . t | Dependencies.Dependency . t | nil , User . t ) :: boolean
1616 def valid? ( nil , _ ) , do: true
1717 def valid? ( % Dependencies { dependencies: nil } , _ ) , do: true
18- def valid? ( % Dependencies { dependencies: deps } , user ) when is_list ( deps ) ,
19- do: Enum . all? ( deps , & valid? ( & 1 , user ) )
18+ def valid? ( % Dependencies { dependencies: [ ] } , _ ) , do: true
19+ def valid? ( % Dependencies { dependencies: [ dep | deps ] } = dependency , user ) do
20+ case valid? ( dep , user ) do
21+ { :locked , _ } = locked -> locked
22+ false -> false
23+ _ -> valid? ( % { dependency | dependencies: deps } , user )
24+ end
25+ end
2026 def valid? ( % Dependencies.Dependency { type: :terraform , repo: repo } = dep , % User { id: user_id } ) do
2127 TerraformInstallation . for_repo_name ( repo )
2228 |> TerraformInstallation . for_terraform_name ( find_names ( dep ) )
@@ -58,6 +64,7 @@ defmodule Core.Services.Dependencies do
5864 def validate ( [ dep | rest ] , user ) do
5965 case valid? ( dep , user ) do
6066 true -> validate ( rest , user )
67+ { :locked , repo } -> { :error , "you have a pending breaking change, apply it locally then run `plural repos unlock #{ repo } ` to allow future installs" }
6168 false -> { :error , { :missing_dep , dep } }
6269 end
6370 end
@@ -92,7 +99,7 @@ defmodule Core.Services.Dependencies do
9299 def closure ( nil ) , do: [ ]
93100 def closure ( deps ) when is_list ( deps ) , do: closure ( deps , MapSet . new ( ) , [ ] )
94101
95- defp valid_version? ( [ % { locked: true } | _ ] , _ ) , do: false # don't deliver updates when an installation is locked
102+ defp valid_version? ( [ % { locked: true } | _ ] , % { repo: repo } ) , do: { :locked , repo } # don't deliver updates when an installation is locked
96103 defp valid_version? ( [ _ | _ ] , % { version: nil } ) , do: true
97104 defp valid_version? ( versions , % { any_of: [ _ | _ ] = deps } ) do
98105 by_name = Enum . into ( deps , % { } , & { & 1 . name , & 1 } )
0 commit comments