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

feat: new apply functionality #446

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

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.
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