mlabouardy / nexus-cli

Nexus CLI for Docker Registry v2 🐳
MIT License
285 stars 118 forks source link

nexus-cli image delete and keep option (wrong sorting) #33

Open jakubek opened 6 years ago

jakubek commented 6 years ago

I had registry with 190 tags for image, tags were generated automagically and images were pushed with incremented version number from 1 to 190.

nexus@reg:~$ ./nexus-cli image tags -n testimage
1
10
100
101
102
103
104
105
106
107
108
109
11
110
111
112
113
114
115
116
117
118
119
12
120
121
122
123
...

I have decided to remove old images and keep only last 20:

nexus@reg:~$ ./nexus-cli image delete -n testimage -k 20

and the effect is:

nexus@reg:~$ ./nexus-cli image tags -n testimage
81
82
83
84
85
86
87
88
89
9
90
91
92
93
94
95
96
97
98
99
There are 20 images for testimage

Nexus-cli version: nexus@reg:~$ ./nexus-cli --version Nexus CLI version 1.0.0-beta

hkamalakannan commented 6 years ago

That is because the code is sorting images by name (string comparison) so 100 will appear before 90 and be deleted. Believe pull request #29 might resolve it.

denis111 commented 5 years ago

So, when we can expect it to be merged?

Basster commented 4 years ago

Its even worse.

I had

nexus-cli image tags -name ff-cfp
latest
v13
v14
v16
v17
v18
v19
v21
v23
v25
v27
v31
v32
v33
v36
v37
v38
v39
v41
v42
v43
v46
v50
v51
There are 24 images for ff-cfp

And did a:

nexus-cli image delete --name ff-cfp --keep 5
ff-cfp:latest image will be deleted ...
ff-cfp:latest has been successful deleted
ff-cfp:v13 image will be deleted ...
ff-cfp:v13 has been successful deleted
ff-cfp:v14 image will be deleted ...
ff-cfp:v14 has been successful deleted
ff-cfp:v16 image will be deleted ...

And it deleted my freshly created latest tag immediately, This makes the whole --keep option useless!

zt-sv commented 3 years ago

Looks like the repository is not maintained already.

I fork the repo and fix sorting issue by made image sorting by last modified date. If you still need fix, you can get build binaries from my repo: https://github.com/13rentgen/nexus-cli/releases/tag/v1.1.0