configstore: rename GetParentPath to GetPath
and rename file from parent.go to resolve.go
This commit is contained in:
parent
984efb539e
commit
2215aaebfa
|
@ -119,7 +119,7 @@ func (h *SecretsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
err = h.readDB.Do(func(tx *db.Tx) error {
|
||||
// populate parent path
|
||||
for _, s := range resSecrets {
|
||||
pp, err := h.readDB.GetParentPath(tx, s.Parent.Type, s.Parent.ID)
|
||||
pp, err := h.readDB.GetPath(tx, s.Parent.Type, s.Parent.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ func (h *VariablesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
err = h.readDB.Do(func(tx *db.Tx) error {
|
||||
// populate parent path
|
||||
for _, v := range resVariables {
|
||||
pp, err := h.readDB.GetParentPath(tx, v.Parent.Type, v.Parent.ID)
|
||||
pp, err := h.readDB.GetPath(tx, v.Parent.Type, v.Parent.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -48,33 +48,35 @@ func (r *ReadDB) ResolveConfigID(tx *db.Tx, configType types.ConfigType, ref str
|
|||
}
|
||||
}
|
||||
|
||||
func (r *ReadDB) GetParentPath(tx *db.Tx, parentType types.ConfigType, parentID string) (string, error) {
|
||||
func (r *ReadDB) GetPath(tx *db.Tx, configType types.ConfigType, id string) (string, error) {
|
||||
var p string
|
||||
switch parentType {
|
||||
switch configType {
|
||||
case types.ConfigTypeProjectGroup:
|
||||
projectGroup, err := r.GetProjectGroup(tx, parentID)
|
||||
projectGroup, err := r.GetProjectGroup(tx, id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if projectGroup == nil {
|
||||
return "", errors.Errorf("projectgroup with id %q doesn't exist", parentID)
|
||||
return "", errors.Errorf("projectgroup with id %q doesn't exist", id)
|
||||
}
|
||||
p, err = r.GetProjectGroupPath(tx, projectGroup)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
case types.ConfigTypeProject:
|
||||
project, err := r.GetProject(tx, parentID)
|
||||
project, err := r.GetProject(tx, id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if project == nil {
|
||||
return "", errors.Errorf("project with id %q doesn't exist", parentID)
|
||||
return "", errors.Errorf("project with id %q doesn't exist", id)
|
||||
}
|
||||
p, err = r.GetProjectPath(tx, project)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
default:
|
||||
return "", errors.Errorf("config type %q doesn't provide a path", configType)
|
||||
}
|
||||
|
||||
return p, nil
|
Loading…
Reference in New Issue