Commit Graph

73 Commits

Author SHA1 Message Date
appleboy
0ec46c4fd2
chore: update and streamline linting configuration and error formatting
- Update `.golangci.yaml` to version 2 and streamline settings
- Remove specific linters from `.golangci.yaml` configuration
- Add exclusion and formatter settings to `.golangci.yaml`
- Change error message formatting in `plugin.go` to lowercase
- Use `strings.ReplaceAll` instead of `strings.Replace` for better readability and performance in `plugin.go` and `plugin_test.go`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2025-03-29 09:39:55 +08:00
Bo-Yi Wu
883f947b4f
chore(log): remove prefix out: and err: prefix (#287)
- Simplify log output by removing "out:" and "err:" prefixes in `plugin.go`
- Update test expectations to match the new log output format

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-11-17 14:48:14 +08:00
appleboy
2519a9a894
ci(golangci): enable comprehensive linting and update variable initialization
- Add a `.golangci.yaml` configuration file with various linters enabled and specific settings for `gosec` and `perfsprint`.
- Change `isTimeout` from being initialized to `true` to being declared as a `bool` variable without an initial value in `plugin.go`.

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-11-16 09:58:21 +08:00
Lukáš Tesař
dc927a6123
fix: typo in success message (#283)
My OCD just kicks in :)) This has bothered me for a long time. Will also update README in https://github.com/appleboy/ssh-action to reflect this change.
2024-10-13 09:00:20 +08:00
Bo-Yi Wu
aa872a30be
style: refactor import aliases for easyssh library
- Alias `github.com/appleboy/easyssh-proxy` import as `easyssh` in `main.go`
- Alias `github.com/appleboy/easyssh-proxy` import as `easyssh` in `plugin.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-07-14 15:30:53 +08:00
Bo-Yi Wu
0914cd212b
test: enable comprehensive debugging in plugin execution (#278)
* test: enable comprehensive debugging in plugin execution

- Add debug logging to `exec` function in `plugin.go`
- Enable debug mode in `TestCommandOutput` and `TestSudoCommand` tests
- Remove redundant command blocks from multiple tests in `plugin_test.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* test: refactor codebase to improve performance and readability

- Remove debug command block from `TestSudoCommand` test

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* refactor: refactor test environment setup and command markers

- Add environment markers to `TestCommandOutput` for localhost and 127.0.0.1
- Remove command markers from `TestFingerprint`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix: improve environment variable handling in debug mode

- Add a check for non-empty environment variables when debug mode is enabled
- Remove redundant environment variable output in tests

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-07-14 15:24:36 +08:00
Bo-Yi Wu
a41d4afc40
chore(protocol): improve IPv6 address. (#268)
* docs: improve documentation and configuration handling

- Clarify valid values for the IP protocol in usage messages for both main application and proxy settings

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* test: improve IPv6 command execution tests

- Add a new test function `TestCommandWithIPv6` to check command execution with an IPv6 address
- Initialize test variables and expected output for the IPv6 command test
- Set up a `Plugin` struct with IPv6 host, user, port, key path, script, and command timeout for testing
- Verify that `plugin.Exec()` returns `nil` (no error) in the IPv6 test
- Assert that the output of the command execution matches the expected output in the IPv6 test

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* test: enhance test suite and CI robustness

- Add support for IPv6 protocol in `TestCommandWithIPv6` test case in `plugin_test.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update2

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update3

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update4

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update5

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-21 09:27:49 +08:00
Bo-Yi Wu
b34fffdbd3
feat: update plugin functionality in main.go and plugin.go files
- Add a new flag to the main.go file
- Add a new field to the Plugin type in the plugin.go file
- Remove two lines from the plugin_test.go file

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2024-01-07 17:44:54 +08:00
Bo-Yi Wu
32510c86bf
feat: implement and test all environment variables functionality (#264)
- Add a new flag `allenvs` to pass all environment variables to the shell script
- Implement the `AllEnvs` functionality in the `exec` function
- Add a new function `findEnvs` to find all environment variables with specified prefixes
- Add tests for the `findEnvs` function and the `AllEnvs` functionality
2023-07-23 09:41:09 +08:00
appleboy
80cecf1ed3 refactor: improve code clarity and logging functionality
- Add a comment to clarify the purpose of the `format` function
- Add a comment to clarify the purpose of the `log` function
- Modify the `log` function to always print the message, removing the previous conditional statement

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2023-07-23 07:30:08 +08:00
Yoan Tournade
905bb4cb1a
chore: allows to specify IP protocol (#261)
* Allows to specify IP protocol, including IPv4 only

* Add tests forcing IPv4 or IPv6
2023-06-23 16:45:44 +08:00
Bo-Yi Wu
49542638c6
refactor: set default environment variables format in plugin (#253)
- Add `INPUT_ENVS_FORMAT` to the list of environment variables in `main.go`
- Define `envsFormat` variable in `plugin.go`
- Add default value for `Config.EnvsFormat` in `plugin.go` `Exec()` function

fix https://github.com/appleboy/drone-ssh/pull/235
2023-04-13 09:32:31 +08:00
Vladimir Sigalkin
6464d9999f
chore: flexible configuration of environment value transfer (#235)
**Reason:**
I have to use drone-ssh to work with Windows SSH. Initially, drone-ssh is written so that it transmits environment variables through the `export` command. Which makes it unsuitable for working with Power Shell.

**Solution:**
I have added a new option to configure environment variable commands formatting, with default value: `export {NAME}={VALUE}`. When I use drone-ssh with PowerShell I set this option like this: `$env:{NAME} = {VALUE}`.
2023-04-13 09:13:07 +08:00
Bo-Yi Wu
a8d30dc133
feat: refactor code for parallel execution on multiple hosts (#249)
- Add `trimValues` function for cleaning up slice values
- Remove unused `wg.Done()` call
- Modify `Exec` function to launch goroutines for each host in `Config.Host`
- Add test for `ScriptStop` with multiple hosts and sync mode

refer to: https://github.com/appleboy/ssh-action/issues/233
2023-04-04 16:56:50 +08:00
Bo-Yi Wu
1a95b5f1b3
chore(auth): allow use password and key at same time (#240) 2023-02-28 17:04:39 +08:00
Prashant Shahi
cc7a2d5983
fix(envs): 🐛 set environment variable instead of bash variable (#219) 2023-01-08 08:36:33 +08:00
WangJun
307409651f
remove empty string output (#198) 2022-12-07 13:35:59 +08:00
Bo-Yi Wu
e059b33708
chore: support multiple port (#168)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-11-17 10:14:11 +08:00
Bo-Yi Wu
66bbf9b7cd
chore: support Multiline SSH commands interpreted as single lines (#160)
https://github.com/appleboy/ssh-action/issues/75
2020-08-08 15:31:57 +08:00
Bo-Yi Wu
7344ac6529
chore: support UseInsecureCipher (#158) 2020-05-24 10:43:11 +08:00
Bo-Yi Wu
a2c6be3c19
support Fingerprint (#157) 2020-05-19 14:01:28 +08:00
Bo-Yi Wu
ec9d02ec38 missing Ciphers config
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-04-30 15:49:00 +08:00
Bo-Yi Wu
9c9e7914ce support custom Ciphers value
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-04-30 15:38:46 +08:00
Bo-Yi Wu
6b488f1203
support ssh Passphrase (#149)
* support ssh Passphrase

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-12-30 16:16:37 +08:00
Bo-Yi Wu
9b57f85e47 chore(cmd): trim space in command
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-21 09:13:04 +08:00
Bo-Yi Wu
648e3c1321
chore: support split from string text (#148) 2019-11-21 09:05:32 +08:00
Bo-Yi Wu
414ebba911 chore: udpate success message 2019-09-29 12:47:36 +08:00
Bo-Yi Wu
f6128860ab chore: Add short variable 2019-05-14 22:15:29 +08:00
Bo-Yi Wu
29018dba3a
chore: switch finished to struct{} for zero allocate (#140) 2019-03-30 08:03:16 +08:00
Bo-Yi Wu
56b67e1314
chore: change command timeout flag (#138)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-11 14:36:17 +08:00
Bo-Yi Wu
89fce5b1d3 chore(variable): change UserName to Username
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-06 11:00:09 +08:00
Bo-Yi Wu
3342cdf59a refactor: error var missingXXX should have name of the form errFoo
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-04 14:47:28 +08:00
Bo-Yi Wu
aa95c51e7f refactor(error): update error
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-04 14:42:28 +08:00
Bo-Yi Wu
7ac526845d
Revert "feat: upgrade easyssh-proxy and update flag of timeout field (#127)" (#128)
This reverts commit eb33537e3f.
2018-10-23 15:54:40 +08:00
Bo-Yi Wu
eb33537e3f
feat: upgrade easyssh-proxy and update flag of timeout field (#127) 2018-10-23 15:14:48 +08:00
Marco Vito Moscaritolo
3499506089 exit after first error (#123)
Closes #121 

WIP
2018-09-26 15:23:31 +08:00
Josh Komoroske
6c0b475c15 Customization of logger output destination (#117)
* Customization of logger output destination

* Tests to verify output correctness
2018-02-28 14:52:15 +08:00
Josh Komoroske
60993a71e2 Preservation of forwarded environment (#113)
* Tests for omitting unset variables

* Preservation of forwarded environment
2018-02-28 13:44:44 +08:00
Damian Kaczmarek
7f4cb1c1d0 improve: shell escaping, allow for whitespace and single quotes (#108) 2018-02-27 14:48:38 +08:00
Damian Kaczmarek
4d443c40f2 fix: ssh process error not resulting in pipeline error (#105)
* fix: ssh process error not resulting in pipeline error

* Update main.go
2017-11-09 20:47:15 -06:00
Damian Kaczmarek
45f43d7ffd fix: escaping special characters when passing env to ssh (#104) 2017-11-09 19:01:28 -06:00
Bo-Yi Wu
7220c94832
Add sync mode. (#101)
* Add sync mode.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* close channel in sync mode.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* close channel in sync mode.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-10-29 21:31:51 -05:00
Bo-Yi Wu
ed83305de8 add debug mode. (#92)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-08-01 16:54:34 +08:00
Bo-Yi Wu
c79b44dca2 update env key.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-08-01 12:51:36 +08:00
Bo-Yi Wu
c86c472904 fix: env to ToUpper
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-08-01 12:40:35 +08:00
Bo-Yi Wu
ecfaecd46d feat(env): pass secret to remote server. (#91)
* feat(env): pass secret to remote server.

* add testing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-08-01 12:01:37 +08:00
Bo-Yi Wu
b5b13e8b72 upgrade easyssh to 1.1.6 (#81)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-16 15:45:00 +08:00
Bo-Yi Wu
88b5394dac
update output
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-10 21:26:34 +08:00
Bo-Yi Wu
1637772e0b hide domain if only single host in config. (#80)
* hide domain if only single host in config.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* fix host

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* refactor

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-10 21:17:31 +08:00
Bo-Yi Wu
efdac217bd
update log format.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-10 16:42:37 +08:00