Skip to content
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

[REQ] Add option to "silent" the output #643

Open
1 task
ashnamehrotra opened this issue May 30, 2024 · 9 comments · May be fixed by #699
Open
1 task

[REQ] Add option to "silent" the output #643

ashnamehrotra opened this issue May 30, 2024 · 9 comments · May be fixed by #699
Assignees
Labels
enhancement New feature or request

Comments

@ashnamehrotra
Copy link
Contributor

ashnamehrotra commented May 30, 2024

What kind of request is this?

Add option to silent copa patch and buildkit output.

What is your request or suggestion?

No response

Are you willing to submit PRs to contribute to this feature request?

  • Yes, I am willing to implement it.
@ashnamehrotra ashnamehrotra added the enhancement New feature or request label May 30, 2024
@shishir-11
Copy link
Contributor

I was exploring this issue and thought of a way to implement this , I was hoping to use a bool like ignoreError in the cmd.go file and

using a conditional at this block of code

eg.Go(func() error {
    // not using shared context to not disrupt display but let us finish reporting errors
    mode := progressui.AutoMode
    if log.GetLevel() >= log.DebugLevel {
    mode = progressui.PlainMode
    }
    display, err := progressui.NewDisplay(os.Stderr, mode)
    if err != nil {
    return err
    }
    
    _, err = display.UpdateFrom(ctx, buildChannel)
    return err
})

Please point me in the right direction and assign me this issue if I'm correct.

@ashnamehrotra
Copy link
Contributor Author

@shishir-11 yes, I think a flag like --silent would be good and this approach lgtm for silencing output while still showing debug/errors.

@shishir-11
Copy link
Contributor

@ashnamehrotra I've opened a PR which will hopefully solve this issue , please take a look at it , thank you.

@shishir-11
Copy link
Contributor

I was trying to add some tests for the new flag I made and some other flags but I run into some docker related issues with authorization , do you know how to bypass them , if possible that would allow me to write tests for more flags.

Unexpected error: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

I get this error when i try to use -i flag .

@ashnamehrotra
Copy link
Contributor Author

@shishir-11 where are you getting this error and what does the setup look like before calling copa?

@shishir-11
Copy link
Contributor

I was trying to extend the tests in cmd_test.go and

{
	name:     "Silent flag check",
	args:     []string{"-r", "trivy.json", "-t", "3.7-alpine-patched", "-i", "images/python:3.7-alpine", "--silent"},
	....
},

I modified the struct a bit to give it some more fields but this part was giving me the error.

@ashnamehrotra
Copy link
Contributor Author

ashnamehrotra commented Jul 18, 2024

@shishir-11 I am not able to recreate this error. I am not sure if we should test this in cmd_test.go since we are not actually running copa here, just checking for the error when the required image argument is not provided. We will not be able to do the same for the silent command which requires copa to run.

@shishir-11
Copy link
Contributor

How can we write tests for other flags then, I think it would be beneficial if the code coverage was improved by adding more tests.

@ashnamehrotra
Copy link
Contributor Author

@shishir-11 To add a check here, you would need to ensure copa can run in the workflow and check for expected log output to match something like INFO[0018] Loaded image: nginx:1.21.6-patched while ignoring INFO[0018] since that varies between runs. I don't receive any error locally. Can you try "python:3.7-alpine" as the image argument?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

2 participants