Use Blueprint.DeepCopy for blueprints/freeze
Without making a deep copy of the blueprint the changes made to the package and module versions will persist in memory, causing it to lose the package and module version globs. This can be seen by executing a freeze request and then a depsolve. The blueprint included in the depsolve had the version globs replaced by the frozen EVRA values.
This commit is contained in:
parent
3ce066a91a
commit
8ccc95a473
1 changed files with 14 additions and 4 deletions
|
|
@ -898,8 +898,8 @@ func (api *API) blueprintsFreezeHandler(writer http.ResponseWriter, request *htt
|
|||
if i == 0 {
|
||||
name = name[1:]
|
||||
}
|
||||
blueprint, _ := api.store.GetBlueprint(name)
|
||||
if blueprint == nil {
|
||||
bp, _ := api.store.GetBlueprint(name)
|
||||
if bp == nil {
|
||||
rerr := responseError{
|
||||
ID: "UnknownBlueprint",
|
||||
Msg: fmt.Sprintf("%s: blueprint_not_found", name),
|
||||
|
|
@ -907,8 +907,18 @@ func (api *API) blueprintsFreezeHandler(writer http.ResponseWriter, request *htt
|
|||
errors = append(errors, rerr)
|
||||
break
|
||||
}
|
||||
// Make a copy of the blueprint since we will be replacing the version globs
|
||||
blueprint, err := bp.DeepCopy()
|
||||
if err != nil {
|
||||
rerr := responseError{
|
||||
ID: "BlueprintDeepCopyError",
|
||||
Msg: fmt.Sprintf("%s: %s", name, err.Error()),
|
||||
}
|
||||
errors = append(errors, rerr)
|
||||
break
|
||||
}
|
||||
|
||||
dependencies, _, _, err := api.depsolveBlueprint(blueprint, "", api.arch, false)
|
||||
dependencies, _, _, err := api.depsolveBlueprint(&blueprint, "", api.arch, false)
|
||||
if err != nil {
|
||||
rerr := responseError{
|
||||
ID: "BlueprintsError",
|
||||
|
|
@ -941,7 +951,7 @@ func (api *API) blueprintsFreezeHandler(writer http.ResponseWriter, request *htt
|
|||
errors = append(errors, rerr)
|
||||
break
|
||||
}
|
||||
blueprints = append(blueprints, blueprintFrozen{*blueprint})
|
||||
blueprints = append(blueprints, blueprintFrozen{blueprint})
|
||||
}
|
||||
|
||||
json.NewEncoder(writer).Encode(reply{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue