Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Löwel <[email protected]>
  • Loading branch information
ChristianLoewel committed Apr 19, 2023
1 parent be6e9e7 commit ffefb50
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
9 changes: 3 additions & 6 deletions controllers/goharbor/project/memberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ func (r *Reconciler) reconcileMembership(hp *goharborv1.HarborProject, log logr.
log.Info("Start reconcile", "current members", currentMembershipsCnt, "desired members", desiredMembershipsCnt)

// find differences between current and desired members.
differences, err := findDifferences(currentMemberships, desiredMemberships, log)
if err != nil {
return err
}
differences := findDifferences(currentMemberships, desiredMemberships, log)

err = r.updateMemberships(hp, differences, log)
if err != nil {
Expand All @@ -105,7 +102,7 @@ func (r *Reconciler) reconcileMembership(hp *goharborv1.HarborProject, log logr.
return nil
}

func findDifferences(currentMemberships []*models.ProjectMemberEntity, desiredMemberships []models.ProjectMember, log logr.Logger) (*memberDifferences, error) {
func findDifferences(currentMemberships []*models.ProjectMemberEntity, desiredMemberships []models.ProjectMember, log logr.Logger) *memberDifferences {
differences := memberDifferences{
update: []memberUpdate{},
create: []*models.ProjectMember{},
Expand Down Expand Up @@ -156,7 +153,7 @@ func findDifferences(currentMemberships []*models.ProjectMemberEntity, desiredMe

log.Info("finished planning project member reconcile.", "create", len(differences.create), "update", len(differences.update), "delete", len(differences.delete))

return &differences, nil
return &differences
}

func (r *Reconciler) updateMemberships(p *goharborv1.HarborProject, differences *memberDifferences, log logr.Logger) error {
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/project/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (r *Reconciler) reconcileQuota(hp *goharborv1.HarborProject, log logr.Logge

var projectQuota *models.Quota

if hp.Status.QuotaID == 0 {
if hp.Status.QuotaID == 0 { //nolint:nestif
// QuotaID in custom resource still undefined. Get Quota via ProjectID
quota, err := r.Harbor.GetQuotaByProjectID(hp.Status.ProjectID)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/rest/v2/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

const (
paginationSize int64 = 25
baseInt10 int = 10
)

// EnsureProject ensures the specified project is on the harbor server
Expand Down Expand Up @@ -199,7 +200,7 @@ func (c *Client) DeleteProject(name string) error {

params := project.NewDeleteProjectParamsWithContext(c.context).
WithTimeout(c.timeout).
WithProjectNameOrID(strconv.FormatInt(int64(p.ProjectID), 10))
WithProjectNameOrID(strconv.FormatInt(int64(p.ProjectID), baseInt10))

if _, err = c.harborClient.Client.Project.DeleteProject(c.context, params); err != nil {
return fmt.Errorf("error while deleting project \"%s\" (%d): %w", name, p.ProjectID, err)
Expand Down

0 comments on commit ffefb50

Please sign in to comment.