weldr: Update projects/source/info to support API v1
This commit changes the store.GetAllSources to distinguish between getting the source by the Name field, or by the ID (the key to the map) using GetAllSourcesByName and ...ByID. SourceConfig.RepoConfig() now takes an id parameter because SourceConfig only stores the Name, not the ID. In weldr I split the sourceInfoHandler into 2 separate functions for v0 and v1 behavior, with the core of the old function refactored as getSourceConfigs and used by both of them. This also adds new structs for the SourceResponseV0 and SourceResponseV1 as well as helper functions for converting to/from store.SourceConfig
This commit is contained in:
parent
ddd2010815
commit
982d292a96
5 changed files with 193 additions and 27 deletions
|
|
@ -45,7 +45,21 @@ func GetSourceInfoV0(socket *http.Client, sourceNames string) (map[string]weldr.
|
|||
if resp != nil || err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
var info weldr.SourceInfoV0
|
||||
var info weldr.SourceInfoResponseV0
|
||||
err = json.Unmarshal(body, &info)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return info.Sources, nil, nil
|
||||
}
|
||||
|
||||
// GetSourceInfoV1 returns detailed information on the named sources
|
||||
func GetSourceInfoV1(socket *http.Client, sourceNames string) (map[string]weldr.SourceConfigV1, *APIResponse, error) {
|
||||
body, resp, err := GetRaw(socket, "GET", "/api/v1/projects/source/info/"+sourceNames)
|
||||
if resp != nil || err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
var info weldr.SourceInfoResponseV1
|
||||
err = json.Unmarshal(body, &info)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue