operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.24k stars 1.74k forks source link

OperatorSDK generate command cannot take input from STDIN redirected from a file #4951

Closed nikhil-thomas closed 2 years ago

nikhil-thomas commented 3 years ago

Bug Report

operator-sdk generate bundle command can only read from pipe but not from STDIN redirected from a file.

What did you do?

kustomize <manifests-dir> | operator-sdk generate bundle <--args> works fine.

However, i cannot provide a pre-rendered (for example from ko resolve) yaml file as input to this command.

At present, we have to do:

cat release.yaml | operator-sdk generate bundle --args

this works.

but I want to do

operator-sdk generate bundle --args < release.yaml

What did you expect to see?

operator-sdk generate bundle --args < release.yaml

generating bundle manifests.

What did you see instead? Under which circumstances?

Environment

Operator type:

Kubernetes cluster type:

$ operator-sdk version 1.8.0

$ go version (if language is Go)

$ kubectl version

Possible Solution

This happens because the STDIN use case of the command is validated using IsPipeReader().

Currently, the function checks of type of STDIN using return info.Mode()&os.ModeNamedPipe != 0. So regular files will not be accepted.

I could get operator-sdk generate bundle --args < release.yaml working locally by,

replacing (checks whether input is a Pipe)

return info.Mode()&os.ModeNamedPipe != 0

with (checks whether input is a Pipe or a regular file)

return info.Mode()&os.ModeNamedPipe != 0 || info.Mode()&os.ModeType == 0

Additional context

estroz commented 3 years ago

@nikhil-thomas mind making a PR?

/kind feature

nikhil-thomas commented 3 years ago

sure :+1: /assign @nikhil-thomas

openshift-bot commented 3 years ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 3 years ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot commented 2 years ago

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-ci[bot] commented 2 years ago

@openshift-bot: Closing this issue.

In response to [this](https://github.com/operator-framework/operator-sdk/issues/4951#issuecomment-961441014): >Rotten issues close after 30d of inactivity. > >Reopen the issue by commenting `/reopen`. >Mark the issue as fresh by commenting `/remove-lifecycle rotten`. >Exclude this issue from closing again by commenting `/lifecycle frozen`. > >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.