weldr: Return error if source name matches system repo
System repos cannot be overridden by users, return an error if they try to push a source with the same name/id as a system source. Resolves: rhbz#1915359
This commit is contained in:
parent
3e510ffc99
commit
d62e813e75
1 changed files with 13 additions and 0 deletions
|
|
@ -666,6 +666,19 @@ func (api *API) sourceNewHandler(writer http.ResponseWriter, request *http.Reque
|
|||
return
|
||||
}
|
||||
|
||||
// Is there an existing System Repo using this id?
|
||||
for _, n := range api.systemRepoNames() {
|
||||
if n == source.GetKey() {
|
||||
// Users cannot replace system repos
|
||||
errors := responseError{
|
||||
ID: "SystemSource",
|
||||
Msg: fmt.Sprintf("%s is a system source, it cannot be changed.", source.GetKey()),
|
||||
}
|
||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
api.store.PushSource(source.GetKey(), source.SourceConfig())
|
||||
|
||||
statusResponseOK(writer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue