Skip to content

Commit

Permalink
fix: no policy in project check
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Dec 13, 2024
1 parent 47906c0 commit 65bedd7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/messenger/task_harborpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

harborclientv5model "github.com/mittwald/goharbor-client/v5/apiv2/model"
"github.com/uselagoon/machinery/utils/cron"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (m *Messenger) HarborPolicy(ctx context.Context, jobSpec *lagoonv1beta2.Lag
}
// get the existing one if one exists
existingPolicy, err := lagoonHarbor.ClientV5.GetRetentionPolicyByProject(ctx, projectName)
if err != nil {
if err != nil && !strings.Contains(err.Error(), "project metadata value is empty: retention_id") {
opLog.Info(fmt.Sprintf("Error getting retention policy %s: %v", project.Name, err))
return err
}
Expand All @@ -104,13 +105,15 @@ func (m *Messenger) HarborPolicy(ctx context.Context, jobSpec *lagoonv1beta2.Lag
opLog.Info(fmt.Sprintf("Error updating retention policy %s: %v", project.Name, string(f)))
return err
}
opLog.Info(fmt.Sprintf("retention policy for %s updated", project.Name))
}
} else {
// create it if it doesn't
if err := lagoonHarbor.ClientV5.NewRetentionPolicy(ctx, retentionPolicy); err != nil {
opLog.Info(fmt.Sprintf("Error creating retention policy %s: %v", project.Name, err))
return err
}
opLog.Info(fmt.Sprintf("retention policy for %s created", project.Name))
}
return nil
}
Expand Down

0 comments on commit 65bedd7

Please sign in to comment.