Skip to content

Conversation

@GregoryDosh
Copy link
Contributor

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/location would look like a plugin use of

steps:
  - name: scp to some server
    image: target/vela-scp
    secrets: [ identity_file_contents ]
    parameters:
      source:
      - file1
      - file2
      target: remote-host:/some/location

And for an ssh action of ssh ~/.ssh/id_rsa some-user@some-host some-command it would look like

steps:
  - name: ssh to some server
    image: target/vela-ssh
    secrets: [ identity_file_contents ]
    parameters:
      destination: some-user@some-host
      command:
      - echo This is in a command block which is maybe confusing to folks about the commands block so it also is aliased with script if needed for doc purposes. 

@codecov
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@8de474d). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #1   +/-   ##
=======================================
  Coverage        ?   93.40%           
=======================================
  Files           ?        3           
  Lines           ?      288           
  Branches        ?        0           
=======================================
  Hits            ?      269           
  Misses          ?       13           
  Partials        ?        6           

Copy link
Contributor

@kaymckay kaymckay left a 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 🤯

@GregoryDosh GregoryDosh changed the title initial copy & paste from GregoryDosh/vela-openssh adding initial functionality for scp and ssh plugins Feb 1, 2022
kaymckay
kaymckay previously approved these changes Feb 2, 2022
Copy link
Contributor

@kaymckay kaymckay left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@GregoryDosh
Copy link
Contributor Author

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.

Copy link
Collaborator

@wass3r wass3r left a 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"
Copy link
Collaborator

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.

Copy link
Contributor Author

@GregoryDosh GregoryDosh Feb 9, 2022

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.
Copy link
Collaborator

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
Copy link
Collaborator

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

Comment on lines +104 to +114
"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!",
},
},
},
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor

@plyr4 plyr4 left a 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.

@GregoryDosh GregoryDosh merged commit 72d2d6e into main Feb 15, 2022
@GregoryDosh GregoryDosh deleted the ready-for-pr branch February 15, 2022 14:39
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.

5 participants