feat: Added retention command #364
Conversation
Signed-off-by: ALTHAF <althafasharaf02@gmail.com>
Signed-off-by: ALTHAF <althafasharaf02@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <112455393+rizul2108@users.noreply.github.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
…nges-pr Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
rizul@rizu:~/OSS/harbor-cli$ ./harbor-cli tag retention create
INFO[0036] Added Tag Retention Rule rizul@rizu:~/OSS/harbor-cli$ ./harbor-cli tag retention list --project-name asdfghj
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ID Action Disabled Params Priority Scope Selectors Tag Selectors Template │
│ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │
│ 0 retain false latestPushedK: 2, 0 repository: [{repoMatches **}] &{matches {"untagged":true} **} latestPushedK │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘rizul@rizu:~/OSS/harbor-cli$ ./harbor-cli tag retention delete
INFO[0010] retention rule deleted successfully
INFO[0010] Retention Policy deleted successfully all 3 are happening smoothly |
|
BUG: Inconsistent behavior from Harbor API after deleting a retention policy.
This is error from harbor API side I think. |
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
this seems to be a problem with upstream Harbor. I suggest creating an issue there explaining the problem and referencing it here. |
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
retention command
fb007fb to
a830729
Compare
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com> fix lint issues Signed-off-by: Rizul Gupta <mail2rizul@gmail.com> lint errors fix Signed-off-by: Rizul Gupta <mail2rizul@gmail.com> minor fixes Signed-off-by: Rizul Gupta <mail2rizul@gmail.com> uncomment login test Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
bupd
left a comment
There was a problem hiding this comment.
@rizul2108 do we currently have a workaround for the tag deletion issue: goharbor/harbor#21783
|
No currently not should I add that ? |
bupd
left a comment
There was a problem hiding this comment.
Retention tag delete fails. because of the problem with harbor. for now we should do workaround as in UI.
|
Currently in the UI, there's only an option to delete a single rule at a time — not the entire tag retention policy for a project. Given this, should we update the CLI |
@bupd is this approach correct can I move forward with this ? |
|
Sure go ahead |
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Signed-off-by: Rizul Gupta <mail2rizul@gmail.com>
Screencast.from.09-04-25.01.22.53.PM.IST.webm |
|
@bupd @Vad1mo As a workaround, we're forced to pass the entire rule object between functions to delete a specific rule, rather than using a simple ID. While this approach works, it feels like a poor and error-prone design. This seems like a design oversight on Harbor's side. Below is the JSON data that is being rendered in the above image. {
"algorithm": "or",
"id": 132,
"rules": [
{
"action": "retain",
"params": {
"latestPushedK": 10
},
"scope_selectors": {
"repository": [
{
"decoration": "repoMatches",
"pattern": "**"
}
]
},
"tag_selectors": [
{
"decoration": "matches",
"extras": "{\"untagged\":true}",
"pattern": "**"
}
],
"template": "latestPushedK"
},
{
"action": "retain",
"params": {
"nDaysSinceLastPush": 3
},
"scope_selectors": {
"repository": [
{
"decoration": "repoMatches",
"kind": "doublestar",
"pattern": "**"
}
]
},
"tag_selectors": [
{
"decoration": "matches",
"extras": "{\"untagged\":true}",
"kind": "doublestar",
"pattern": "**"
}
],
"template": "nDaysSinceLastPush"
}
],
"scope": {
"level": "project",
"ref": 1532
},
"trigger": {
"kind": "Schedule",
"settings": {
"cron": ""
}
}
} |
Signed-off-by: Rizul Gupta <112455393+rizul2108@users.noreply.github.com>
retention command|
Updated and rebased in #564 |
|
closing this in favor of #564 |

Description
Fixes #183
This PR continues the work started by @Althaf66 in #184.
Changes and Fixes:
Incorporating changes suggested by @bupd
Related Issue: goharbor/harbor#21783