Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

feat: support stdin #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: support stdin #95

wants to merge 1 commit into from

Conversation

knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Mar 16, 2020

fanal supported - to take an image content from stdin before, but the feature was dropped when moving to containers/image. But some users want this feature, so this PR makes it possible to do it again.
Related to aquasecurity/trivy#418

For example,

$ docker save centos:7 | fanal -f -

@knqyf263 knqyf263 self-assigned this Mar 16, 2020
@knqyf263 knqyf263 requested a review from simar7 March 16, 2020 19:37
@@ -69,6 +73,16 @@ func NewImage(ctx context.Context, image Reference, transports []string, option
auth = GetToken(ctx, domain, option)
}

// Receive an image content from stdin
var tmpImageFileName string
if image.IsFile && image.Name == "-" && !terminal.IsTerminal(0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to set something up so that !terminal.IsTerminal(0) can evaluate to true in a test? If so we should add a test for it.

@knqyf263 knqyf263 changed the base branch from master to main December 17, 2020 13:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants