-
Notifications
You must be signed in to change notification settings - Fork 1
adding initial functionality for scp and ssh plugins #1
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1 +/- ##
=======================================
Coverage ? 93.40%
=======================================
Files ? 3
Lines ? 288
Branches ? 0
=======================================
Hits ? 269
Misses ? 13
Partials ? 6 |
add integration tests
kaymckay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! holy testing 🤯
kaymckay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
|
For others looking at this PR in the future. There was also some feedback via the Gopher Slack channel that had a bit of feedback. |
wass3r
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first pass - thanks for all the work. love the thorough commenting and testing! see inline comments for more.
| // would be in its own package somewhere so it wasn't tied to any particular plugin. | ||
| // If this gets changed in the future, be sure to update the Makefile references | ||
| // for the build-time injection of the Git Tag, Commit, etc. | ||
| "github.com/go-vela/vela-kaniko/version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree.. a vela-plugin-utils-go would do nicely - i know there's been conversation elsewhere on this. it doesn't feel right to depend on a "random" package's version implementation. if we move forward with this for now, i'd vote to create a story (if it doesn't exist) to create this new repo and update this and other plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely agree and I don't mind taking on the creation and movement and orchestration of all the other repos to get them pointing at this updated utils if we go that route. For now it was just to move forward with something and highlight an area of potential future improvement.
|
|
||
| // Log some good debugging information here. There is a purposeful choice | ||
| // here to NOT expand the arguments with environmental variables yet | ||
| // as those might contain secrets or other information we don't want to leak. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
| // as it aims to provide a common structure to use for converting binaries | ||
| // into plugins. Along the way it allows for some setup tasks, validation, | ||
| // and execution. | ||
| package binarywrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can definitely see this as part of something like vela-plugin-utils-go like version
| "formats arguments with env vars before executing": { | ||
| execStyle: binarywrapper.OSExecCommand, | ||
| config: &mockExecConfig{ | ||
| binaryPath: os.Args[0], | ||
| arguments: []string{"$SOME_TEST"}, | ||
| environment: map[string]string{ | ||
| "GO_MAIN_TEST_CASE": testMainEnvVar, | ||
| "SOME_TEST": "Howdy!", | ||
| }, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm more familiar with having the first field in the struct be name and then using that for t.Run (eg: https://github.com/go-vela/server/blob/master/secret/vault/delete_test.go#L38-L51) instead of using a map. that said, we definitely have table tests without any naming, so this better than that. however, now we have a total of three styles: no name, name struct field, and this map approach. we should probably standardize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not hard on any stance other than the fact that named tests are easier to debug when they fail. I've been leaning and experimenting more with map[string]struct style tests because of some of the points made on this article talking about table drive tests. Map iteration is randomized each passthrough so if there is any reliance between tests it should come out in repeated tests. Doesn't matter to me much either way though and can refactor and fix things here along the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fair and hard to argue against. seems like a safe(r) approach, probably. something we should probably adopt across the board and somehow document for contributors as well?
plyr4
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of code, so the initial pass LGTM. I checked for target IP + obvious issues.
This contains the initial logic for the SCP & SSH plugins. These are a rewrite to wrap the respective scp and ssh binaries in a thin plugin initialization app so that folks can generally use these in their pipelines as they would from the command line.
The parameter names and formats were to be as close as possible to the OpenSSH usage manuals so that it is easier to crossreference what each parameter is or does. There are a few things that the plugin takes care of such as taking the contents of a private identity file and placing them in the plugin container and changing the permissions so that the ssh and scp binaries can use them during the plugin execution.
E.g.
scp -i ~/.ssh/id_rsa file1 file2 remote-host:/some/locationwould look like a plugin use ofAnd for an ssh action of
ssh ~/.ssh/id_rsa some-user@some-host some-commandit would look like