mirror of
https://github.com/goharbor/harbor
synced 2025-04-13 18:05:05 +00:00
fix: fix replication of multiple projects with numeric names (#21474)
Explicitly mark project names as strings This keeps the server from parsing all-numeric project names as integer values which it does not like. Signed-off-by: Chris Girard <cgirard@mirantis.com> Co-authored-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
6b2e6ba20c
commit
c2098f2ba3
|
@ -160,12 +160,15 @@ func (a *Adapter) PrepareForPush(resources []*model.Resource) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a list of the project names.
|
||||||
var ps []string
|
var ps []string
|
||||||
for p := range projects {
|
for p := range projects {
|
||||||
ps = append(ps, p)
|
// Surround name in 'quotes' to force the server to parse as a string.
|
||||||
|
// Handles the case where a project name consists entirely of numbers.
|
||||||
|
ps = append(ps, fmt.Sprintf("'%s'", p))
|
||||||
}
|
}
|
||||||
// query by project name, decorate the name as string to avoid parsed as int by server in case of pure numbers as project name
|
// query by project names
|
||||||
q := fmt.Sprintf("name={'%s'}", strings.Join(ps, " "))
|
q := fmt.Sprintf("name={%s}", strings.Join(ps, " "))
|
||||||
// get exist projects
|
// get exist projects
|
||||||
queryProjects, err := a.Client.ListProjectsWithQuery(q, false)
|
queryProjects, err := a.Client.ListProjectsWithQuery(q, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user