-
Notifications
You must be signed in to change notification settings - Fork 183
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
feat: support deleting a manifest from a remote registry #506
Conversation
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Codecov Report
@@ Coverage Diff @@
## main #506 +/- ##
==========================================
+ Coverage 71.37% 72.33% +0.96%
==========================================
Files 12 13 +1
Lines 489 506 +17
==========================================
+ Hits 349 366 +17
Misses 112 112
Partials 28 28
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
6067ca7
to
f4e876b
Compare
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
fs.BoolVarP(&opts.Confirmed, "yes", "y", false, "do not prompt for confirmation") | ||
} | ||
|
||
func (opts *Confirmation) AskForConfirmation(message string) (bool, error) { |
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.
Suggest having io.Writer
passed in for better unit tests.
func (opts *Confirmation) AskForConfirmation(message string) (bool, error) { | |
func (opts *Confirmation) AskForConfirmation(w io.Writer, prompt string) (bool, error) { |
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.
Suggest having
io.Writer
passed in for better unit tests.
I found a different approach to test a func with fmt.Scanln()
in its body. Details are shown below, not sure which way makes more sense.
fmt.Print(message) | ||
|
||
var response string | ||
if _, err := scanln(&response); err != nil { |
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.
Try fmt.Fscanln
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 wrote in this way because in the unit test, I can easily override the scanln()
func.
var scanln func(a ...any) (n int, err error) = fmt.Scanln
func AskForConfirmation() {
var response string
scanln(&response)
}
Then, in the unit test, I can do things like.
TestConfirmation_AskForConfirmation(t *testing.T) {
reset := func(input string) {
scanln = func(a ...any) (n int, err error) {
*a[0].(*string) = input
return len([]byte(input)), nil
}
}
reset("yes")
// test for user input "yes"
reset("no")
// test for user input "no"
}
Compare to introducing w io.Writer
to the func, it is a different way that I found to handle fmt.Scanln()
. I think it's good, does it make sense to you? @shizhMSFT
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.
The way of doing var scanln
is too hacky. Since it is just for unit test, it does not worth 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.
The way of doing
var scanln
is too hacky. Since it is just for unit test, it does not worth it.
No problem, will change to use w io.Writer
and fmt.Fscanln()
.
Example - Delete a manifest by digest '99e4703fbf30916f549cd6bfa9cdbab614b5392fbe64fdee971359a77073cdf9' from repository 'locahost:5000/hello': | ||
oras manifest delete localhost:5000/hello@sha:99e4703fbf30916f549cd6bfa9cdbab614b5392fbe64fdee971359a77073cdf9 | ||
`, | ||
Args: cobra.ExactArgs(1), |
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.
Question: Can we delete multiple manifests at the same time?
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.
/cc @FeynmanZhou
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.
@yuehaoliang-microsoft Please create an issue for this question, and only address it in another PR after being well discussed.
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.
@yuehaoliang-microsoft Please create an issue for this question, and only address it in another PR after being well discussed.
Created issue #560 to follow up deleting multiple manifest in a single command.
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
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.
LGTM
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
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.
LGTM
…t#506) Signed-off-by: Haoliang Yue <yuehaoliang@microsoft.com>
Resolve #473
Signed-off-by: Haoliang Yue yuehaoliang@microsoft.com