mirror of
https://github.com/goharbor/harbor
synced 2025-04-12 18:14:01 +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
|
||||
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
|
||||
q := fmt.Sprintf("name={'%s'}", strings.Join(ps, " "))
|
||||
// query by project names
|
||||
q := fmt.Sprintf("name={%s}", strings.Join(ps, " "))
|
||||
// get exist projects
|
||||
queryProjects, err := a.Client.ListProjectsWithQuery(q, false)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user