diff --git a/internal/services/configstore/api/secret.go b/internal/services/configstore/api/secret.go index 5914696..c55d6d7 100644 --- a/internal/services/configstore/api/secret.go +++ b/internal/services/configstore/api/secret.go @@ -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 } diff --git a/internal/services/configstore/api/variable.go b/internal/services/configstore/api/variable.go index bef7d0c..2bb2352 100644 --- a/internal/services/configstore/api/variable.go +++ b/internal/services/configstore/api/variable.go @@ -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 } diff --git a/internal/services/configstore/readdb/parent.go b/internal/services/configstore/readdb/resolve.go similarity index 87% rename from internal/services/configstore/readdb/parent.go rename to internal/services/configstore/readdb/resolve.go index 2ac0478..b9feaa0 100644 --- a/internal/services/configstore/readdb/parent.go +++ b/internal/services/configstore/readdb/resolve.go @@ -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