Skip to content

Conversation

@mfrancisc
Copy link
Contributor

THIS IS EXPERIMENTAL and the PR might be closed!

This is an attempt to leverage the kubectl apply package for applying objects on the clusters.

Unfortunately atm the package only supports applying from files and stdin, it doesn't support custom input.
See: kubernetes/kubectl#1670

wrt: KUBESAW-139

… fashion

so that we can use the kubectl functionality with streams.
@sonarqubecloud
Copy link

return nil, err
}

f := &replacedStdin{orig: os.Stdin}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

why pointing os.File to os.Stdin ?


f := &replacedStdin{orig: os.Stdin}

os.Stdin = stdinRead
Copy link
Contributor Author

Choose a reason for hiding this comment

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

again , I'm not sure I follow why we need this . Could we point stdinRead to *os.File directly ?

Also does this mean it's using a file for storing the data or it's using the stdin stream?

os.Stdin = stdinRead

if _, err = io.Copy(stdinWrite, data); err != nil {
os.Stdin = f.orig
Copy link
Contributor Author

Choose a reason for hiding this comment

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

why setting back os.Stdin to f only on error ?

orig *os.File
}

func pumpToStdin(data io.Reader) (*replacedStdin, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you please add a few comments explaining how the "trick" works ? I'm not 100% following all the swaps between the various variables ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants