Skip to content

Commit

Permalink
Explicitly mark project names as strings
Browse files Browse the repository at this point in the history
This keeps the server from parsing all-numeric project names as integer
values which it does not like.

Signed-off-by: Chris Girard <[email protected]>
  • Loading branch information
cgirard-mir committed Jan 31, 2025
1 parent 2d1e20c commit dd06536
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pkg/reg/adapter/harbor/base/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit dd06536

Please sign in to comment.