-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some features improvement #11
base: master
Are you sure you want to change the base?
Conversation
Add back maximum repo count as parameter
Wow! this is a huge PR. Thanks for the effort. Please give me some time to review it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think from this commit, the only thing that we should keep are the insecure
, user
, and password
flags. However, we should find a better way to read passwords and avoid plain texts in the command line (readable through history
)
log "github.com/Sirupsen/logrus" | ||
"github.com/docker/distribution/context" | ||
schema2 "github.com/docker/distribution/manifest/schema2" | ||
"github.com/docker/distribution/reference" | ||
"github.com/docker/distribution/registry/client" | ||
"github.com/heroku/docker-registry-client/registry" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we need this!?
// registry username (default = "") | ||
username = flag.String("username", "", "registry username to login") | ||
// registry password (default = "") | ||
password = flag.String("password", "", "registry password to login") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fond of Plaintext passwords as args, we should do this in an extra step (just as mysql -u root -p
does)
main.go
Outdated
// Create registry object | ||
r, err := client.NewRegistry(*registryURL, nil) | ||
r, err := client.NewRegistry(ctx, *registryURL, wrapTransport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context is not used anymore in Docker API. See this: 9931cc7
main.go
Outdated
@@ -125,7 +154,7 @@ func main() { | |||
logger.Fatalf("Could not parse repo from name! (err: %v)", err) | |||
} | |||
|
|||
repo, err := client.NewRepository(repoName, *registryURL, nil) | |||
repo, err := client.NewRepository(ctx, repoName, *registryURL, wrapTransport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. ctx
is not required.
main.go
Outdated
// Maximum age of iamges to consider for deletion in days (default = 0) | ||
day = flag.Int("day", 0, "max age in days") | ||
// Maximum age of months to consider for deletion in days (default = 0) | ||
month = flag.Int("month", 0, "max age in months") | ||
// Maximum age of iamges to consider for deletion in years (default = 0) | ||
year = flag.Int("year", 0, "max age in days") | ||
// Regexp for images (default = .*) | ||
repoRegexp = flag.String("repo", ".*", "matching repositories (allows regexp)") | ||
repoRegexp = flag.String("repo", ".*", "matching repositories (allows mulitple value seperates by ,)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant as it's equal to '|' in a regular expression and IMHO does not provide any added value. 🙃
main.go
Outdated
if err != nil { | ||
log.Fatalf("Could not create registry object! (err: %s", err) | ||
} | ||
|
||
fetchAll := strings.Compare(*repoRegexp, ".*") == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the side-effect when we use 2 different parameters for the same goal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate on this bug? I'm not following what exactly is happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested this? My favorite base image is alpine. Moreover, this guide is a generic way of generating a Docker image. I would remove it from the README
and put it at best in the wiki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For such changes please use git rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented in the first commit of this PR, we should stick to regex
and not complicate the whole procedure.
So I reviewed the first commits and the rest seems to be fixing typos and what seems to be reverting some changes. The following points are what to be done and what will be merged:
The following is going to be removed:
I appreciate the PR. 👍 |
Thank you for your throughly review. Here are some illustrations regarding to your concerns:
Let me know if you have any different opinions. |
It makes sense! Thanks. Please try to avoid commits that fix previous commits and just rebase if you think something needs to be changed. Otherwise the review procedure would be really confusing 😅 So I think we agree on all points 😄 ! |
Thank you for the tips. 👍 |
@@ -33,6 +33,8 @@ We run our own private registry on a server with limited storage and it was only | |||
username for docker login | |||
-password string | |||
password for docker login | |||
-promote | |||
promote user to enter docker login password; If specified will ignore `-password` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave this out and see if any value is given after -password
or not. If not, prompt user.
|
||
if *enterPwd { | ||
fmt.Println("Enter registry login password:") | ||
fmt.Scanln(password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the proper way to read passwords in terminal. See here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comments.
2. Upgraded to support latest docker distribution API 3. Added support for native module 4. Fix an import package error owing renaming
What does this PR do?
This only happens when duplicate tags share the same hash. If one should be removed but the other should remain, both will be deleted.
What issues does this PR fix or reference?
#1
#2
#9
Previous Behavior
Parameters
-repo
and-tag
were used for filtering repo/tag by regexpParameter
-repos
was used as the maximum repo count to fetchNew Behavior
Parameter changes include:
-username
stringusername for docker login
-password
stringpassword for docker login
-insecure
ignore https verification error
-repos
matching repositories by name (allows multiple value separates by ,); If specifies will ignore
-repo_regexp
-repo_regexp
stringmatching repositories (allows regexp) (default ".")
-max_repos
intmax number of repositories to garbage collect (default to no limit)
-tag_regexp
stringmatching tags (allows regexp) (default ".")