mirror of
https://github.com/appleboy/drone-ssh.git
synced 2026-06-16 14:49:25 +08:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1efc71c743 | |||
| f11e2ed931 | |||
| cf159c578b | |||
| c7df4b7f8c | |||
| 4e6b85e4c7 | |||
| 0dd29f2223 | |||
| bf697d7977 | |||
| 1944689d90 | |||
| 7b035f27e3 | |||
| 492a5db6ae | |||
| 2407d7a56b | |||
| 642891be17 | |||
| 471976f1d8 | |||
| c4e24b1ab9 | |||
| 9c88ecd501 | |||
| b96b4db8cb | |||
| 6850ed1bff | |||
| 5750d46265 | |||
| 9edff25d7f | |||
| 79f4c2408b | |||
| 76fb630345 | |||
| e059b33708 | |||
| bb733a53de | |||
| f725d02d7b | |||
| ac47ca3480 | |||
| 66bbf9b7cd | |||
| 77a818a94d | |||
| 1d89d2d875 | |||
| b447da961e | |||
| 4d46a02d53 | |||
| 7994d5555e | |||
| c7d8b0f2e9 | |||
| 7755fdb39f | |||
| 83417639b9 | |||
| 7344ac6529 | |||
| 1288a4b20d | |||
| 11ec0bec7e | |||
| a2c6be3c19 | |||
| 923defc397 | |||
| ec9d02ec38 | |||
| 9c9e7914ce | |||
| 9e205a756f | |||
| 99f63aaaa8 | |||
| 6bdace5138 | |||
| 54cdb693e4 | |||
| 81d0430ffd | |||
| a046be092b | |||
| 6b488f1203 | |||
| 8d0b62974a |
+97
-164
@@ -1,105 +1,69 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: testing
|
name: testing
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
os: linux
|
||||||
steps:
|
steps:
|
||||||
- name: vet
|
- commands:
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make vet
|
- make vet
|
||||||
|
image: golang:1.18
|
||||||
|
name: vet
|
||||||
|
pull: always
|
||||||
volumes:
|
volumes:
|
||||||
- name: gopath
|
- name: gopath
|
||||||
path: /go
|
path: /go
|
||||||
|
- image: robertstettner/drone-codecov
|
||||||
- name: lint
|
name: codecov
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make lint
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: misspell
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make misspell-check
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: test
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13-alpine
|
|
||||||
commands:
|
|
||||||
- apk add git make curl perl bash build-base zlib-dev ucl-dev
|
|
||||||
- make ssh-server
|
|
||||||
- make test
|
|
||||||
- make coverage
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: codecov
|
|
||||||
pull: always
|
|
||||||
image: robertstettner/drone-codecov
|
|
||||||
settings:
|
settings:
|
||||||
token:
|
token:
|
||||||
from_secret: codecov_token
|
from_secret: codecov_token
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: gopath
|
- name: gopath
|
||||||
temp: {}
|
temp: {}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
depends_on:
|
||||||
|
- testing
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-amd64
|
name: linux-amd64
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
os: linux
|
||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- commands:
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-ssh
|
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-ssh
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: "0"
|
||||||
|
image: golang:1.18
|
||||||
|
name: build-push
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- tag
|
- tag
|
||||||
|
- commands:
|
||||||
- name: build-tag
|
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}'
|
||||||
pull: always
|
-a -o release/linux/amd64/drone-ssh
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-ssh
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: "0"
|
||||||
|
image: golang:1.18
|
||||||
|
name: build-tag
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
- commands:
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- ./release/linux/amd64/drone-ssh --help
|
- ./release/linux/amd64/drone-ssh --help
|
||||||
|
image: golang:1.18
|
||||||
- name: dryrun
|
name: executable
|
||||||
|
pull: always
|
||||||
|
- image: plugins/docker:linux-amd64
|
||||||
|
name: dryrun
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/docker:linux-amd64
|
|
||||||
settings:
|
settings:
|
||||||
cache_from: appleboy/drone-ssh
|
cache_from: appleboy/drone-ssh
|
||||||
|
daemon_off: false
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
dockerfile: docker/Dockerfile.linux.amd64
|
||||||
dry_run: true
|
dry_run: true
|
||||||
repo: appleboy/drone-ssh
|
repo: appleboy/drone-ssh
|
||||||
@@ -107,15 +71,14 @@ steps:
|
|||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
- image: plugins/docker:linux-amd64
|
||||||
- name: publish
|
name: publish
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/docker:linux-amd64
|
|
||||||
settings:
|
settings:
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64
|
auto_tag_suffix: linux-amd64
|
||||||
cache_from: appleboy/drone-ssh
|
cache_from: appleboy/drone-ssh
|
||||||
daemon_off: false
|
daemon_off: "false"
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
dockerfile: docker/Dockerfile.linux.amd64
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
@@ -126,59 +89,53 @@ steps:
|
|||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/pull/**
|
- refs/pull/**
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
|
---
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-arm64
|
name: linux-arm64
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
|
||||||
arch: arm64
|
arch: arm64
|
||||||
|
os: linux
|
||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- commands:
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-ssh
|
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-ssh
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: "0"
|
||||||
|
image: golang:1.18
|
||||||
|
name: build-push
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- tag
|
- tag
|
||||||
|
- commands:
|
||||||
- name: build-tag
|
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}'
|
||||||
pull: always
|
-a -o release/linux/arm64/drone-ssh
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-ssh
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: "0"
|
||||||
|
image: golang:1.18
|
||||||
|
name: build-tag
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
- commands:
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- ./release/linux/arm64/drone-ssh --help
|
- ./release/linux/arm64/drone-ssh --help
|
||||||
|
image: golang:1.18
|
||||||
- name: dryrun
|
name: executable
|
||||||
|
pull: always
|
||||||
|
- image: plugins/docker:linux-arm64
|
||||||
|
name: dryrun
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/docker:linux-arm64
|
|
||||||
settings:
|
settings:
|
||||||
cache_from: appleboy/drone-ssh
|
cache_from: appleboy/drone-ssh
|
||||||
|
daemon_off: false
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
dockerfile: docker/Dockerfile.linux.arm64
|
||||||
dry_run: true
|
dry_run: true
|
||||||
repo: appleboy/drone-ssh
|
repo: appleboy/drone-ssh
|
||||||
@@ -186,15 +143,14 @@ steps:
|
|||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
- image: plugins/docker:linux-arm64
|
||||||
- name: publish
|
name: publish
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/docker:linux-arm64
|
|
||||||
settings:
|
settings:
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-arm64
|
auto_tag_suffix: linux-arm64
|
||||||
cache_from: appleboy/drone-ssh
|
cache_from: appleboy/drone-ssh
|
||||||
daemon_off: false
|
daemon_off: "false"
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
dockerfile: docker/Dockerfile.linux.arm64
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
@@ -205,59 +161,53 @@ steps:
|
|||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/pull/**
|
- refs/pull/**
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
|
---
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-arm
|
name: linux-arm
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
|
||||||
arch: arm
|
arch: arm
|
||||||
|
os: linux
|
||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- commands:
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-ssh
|
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-ssh
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: "0"
|
||||||
|
image: golang:1.18
|
||||||
|
name: build-push
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- tag
|
- tag
|
||||||
|
- commands:
|
||||||
- name: build-tag
|
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}'
|
||||||
pull: always
|
-a -o release/linux/arm/drone-ssh
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-ssh
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: "0"
|
||||||
|
image: golang:1.18
|
||||||
|
name: build-tag
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
- commands:
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- ./release/linux/arm/drone-ssh --help
|
- ./release/linux/arm/drone-ssh --help
|
||||||
|
image: golang:1.18
|
||||||
- name: dryrun
|
name: executable
|
||||||
|
pull: always
|
||||||
|
- image: plugins/docker:linux-arm
|
||||||
|
name: dryrun
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/docker:linux-arm
|
|
||||||
settings:
|
settings:
|
||||||
cache_from: appleboy/drone-ssh
|
cache_from: appleboy/drone-ssh
|
||||||
|
daemon_off: false
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
dockerfile: docker/Dockerfile.linux.arm
|
||||||
dry_run: true
|
dry_run: true
|
||||||
repo: appleboy/drone-ssh
|
repo: appleboy/drone-ssh
|
||||||
@@ -265,15 +215,14 @@ steps:
|
|||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
- image: plugins/docker:linux-arm
|
||||||
- name: publish
|
name: publish
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/docker:linux-arm
|
|
||||||
settings:
|
settings:
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-arm
|
auto_tag_suffix: linux-arm
|
||||||
cache_from: appleboy/drone-ssh
|
cache_from: appleboy/drone-ssh
|
||||||
daemon_off: false
|
daemon_off: "false"
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
dockerfile: docker/Dockerfile.linux.arm
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
@@ -284,37 +233,32 @@ steps:
|
|||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/pull/**
|
- refs/pull/**
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
|
---
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- testing
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: release-binary
|
name: release-binary
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
os: linux
|
||||||
steps:
|
steps:
|
||||||
- name: build-all-binary
|
- commands:
|
||||||
pull: always
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make release
|
- make release
|
||||||
|
image: techknowlogick/xgo:go-1.18.x
|
||||||
|
name: build-all-binary
|
||||||
|
pull: always
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
- image: plugins/github-release
|
||||||
- name: deploy-all-binary
|
name: deploy-all-binary
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/github-release
|
|
||||||
settings:
|
settings:
|
||||||
api_key:
|
api_key:
|
||||||
from_secret: github_release_api_key
|
from_secret: github_release_api_key
|
||||||
@@ -323,26 +267,24 @@ steps:
|
|||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
depends_on:
|
||||||
|
- linux-amd64
|
||||||
|
- linux-arm64
|
||||||
|
- linux-arm
|
||||||
|
- release-binary
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: notifications
|
name: notifications
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
os: linux
|
||||||
steps:
|
steps:
|
||||||
- name: manifest
|
- image: plugins/manifest
|
||||||
|
name: manifest
|
||||||
pull: always
|
pull: always
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
settings:
|
||||||
ignore_missing: true
|
ignore_missing: true
|
||||||
password:
|
password:
|
||||||
@@ -350,16 +292,7 @@ steps:
|
|||||||
spec: docker/manifest.tmpl
|
spec: docker/manifest.tmpl
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- linux-amd64
|
|
||||||
- linux-arm64
|
|
||||||
- linux-arm
|
|
||||||
- release-binary
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
# unifying the coding style for different editors and IDEs => editorconfig.org
|
|
||||||
|
|
||||||
; indicate this is the root of the project
|
|
||||||
root = true
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; common
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
|
|
||||||
end_of_line = LF
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; make
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[Makefile]
|
|
||||||
indent_style = tab
|
|
||||||
|
|
||||||
[makefile]
|
|
||||||
indent_style = tab
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; markdown
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; golang
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[*.go]
|
|
||||||
indent_style = tab
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
custom: ['https://www.paypal.me/appleboy46']
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
- package-ecosystem: gomod
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ master ]
|
||||||
|
schedule:
|
||||||
|
- cron: '41 23 * * 6'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'go' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
|
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
name: Run Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '^1'
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: v1.46.2
|
||||||
|
args: --verbose
|
||||||
|
|
||||||
|
# build:
|
||||||
|
# strategy:
|
||||||
|
# matrix:
|
||||||
|
# os: [ubuntu-latest]
|
||||||
|
# go: [ 1.18]
|
||||||
|
# include:
|
||||||
|
# - os: ubuntu-latest
|
||||||
|
# go-build: ~/.cache/go-build
|
||||||
|
# name: ${{ matrix.os }} @ Go ${{ matrix.go }}
|
||||||
|
# runs-on: ${{ matrix.os }}
|
||||||
|
# env:
|
||||||
|
# GO111MODULE: on
|
||||||
|
# GOPROXY: https://proxy.golang.org
|
||||||
|
# steps:
|
||||||
|
# - name: Set up Go ${{ matrix.go }}
|
||||||
|
# uses: actions/setup-go@v3
|
||||||
|
# with:
|
||||||
|
# go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
# - name: Checkout Code
|
||||||
|
# uses: actions/checkout@v3
|
||||||
|
# with:
|
||||||
|
# ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
# - uses: actions/cache@v3
|
||||||
|
# with:
|
||||||
|
# path: |
|
||||||
|
# ${{ matrix.go-build }}
|
||||||
|
# ~/go/pkg/mod
|
||||||
|
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
# restore-keys: |
|
||||||
|
# ${{ runner.os }}-go-
|
||||||
|
# - name: initial docker
|
||||||
|
# uses: docker-practice/actions-setup-docker@master
|
||||||
|
# - name: build all binaries
|
||||||
|
# run: |
|
||||||
|
# set -x
|
||||||
|
# make release
|
||||||
@@ -28,3 +28,4 @@ coverage.txt
|
|||||||
release
|
release
|
||||||
drone-ssh
|
drone-ssh
|
||||||
.cover
|
.cover
|
||||||
|
dist
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
ignoreGeneratedHeader = false
|
|
||||||
severity = "warning"
|
|
||||||
confidence = 0.8
|
|
||||||
errorCode = 1
|
|
||||||
warningCode = 1
|
|
||||||
|
|
||||||
[rule.blank-imports]
|
|
||||||
[rule.context-as-argument]
|
|
||||||
[rule.context-keys-type]
|
|
||||||
[rule.dot-imports]
|
|
||||||
[rule.error-return]
|
|
||||||
[rule.error-strings]
|
|
||||||
[rule.error-naming]
|
|
||||||
[rule.exported]
|
|
||||||
[rule.if-return]
|
|
||||||
[rule.increment-decrement]
|
|
||||||
[rule.var-naming]
|
|
||||||
[rule.var-declaration]
|
|
||||||
[rule.package-comments]
|
|
||||||
[rule.range]
|
|
||||||
[rule.receiver-naming]
|
|
||||||
[rule.time-naming]
|
|
||||||
[rule.unexported-return]
|
|
||||||
[rule.indent-error-flow]
|
|
||||||
[rule.errorf]
|
|
||||||
@@ -40,6 +40,23 @@ Example configuration in your `.drone.yml` file for multiple hosts:
|
|||||||
- echo world
|
- echo world
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example configuration for multiple hosts with different port:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- name: ssh commands
|
||||||
|
image: appleboy/drone-ssh
|
||||||
|
settings:
|
||||||
|
host:
|
||||||
|
+ - foo.com:1234
|
||||||
|
+ - bar.com:5678
|
||||||
|
username: root
|
||||||
|
password: 1234
|
||||||
|
- port: 22
|
||||||
|
script:
|
||||||
|
- echo hello
|
||||||
|
- echo world
|
||||||
|
```
|
||||||
|
|
||||||
Example configuration for command timeout, default value is 60 seconds:
|
Example configuration for command timeout, default value is 60 seconds:
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
@@ -112,6 +129,8 @@ Example configuration for exporting custom secrets:
|
|||||||
```diff
|
```diff
|
||||||
- name: ssh commands
|
- name: ssh commands
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
|
environment:
|
||||||
|
commit: ${DRONE_BUILD_NUMBER}
|
||||||
settings:
|
settings:
|
||||||
host: foo.com
|
host: foo.com
|
||||||
username: root
|
username: root
|
||||||
@@ -119,8 +138,10 @@ Example configuration for exporting custom secrets:
|
|||||||
port: 22
|
port: 22
|
||||||
+ envs:
|
+ envs:
|
||||||
- aws_access_key_id
|
- aws_access_key_id
|
||||||
|
- commit
|
||||||
script:
|
script:
|
||||||
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
|
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
|
||||||
|
- echo $commit
|
||||||
```
|
```
|
||||||
|
|
||||||
Example configuration for stoping script after first failure:
|
Example configuration for stoping script after first failure:
|
||||||
@@ -139,6 +160,23 @@ Example configuration for stoping script after first failure:
|
|||||||
- echo "you can't see the steps."
|
- echo "you can't see the steps."
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example configuration for passphrase which protecting a private key:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- name: ssh commands
|
||||||
|
image: appleboy/drone-ssh
|
||||||
|
settings:
|
||||||
|
host: foo.com
|
||||||
|
username: root
|
||||||
|
+ key:
|
||||||
|
+ from_secret: ssh_key
|
||||||
|
+ passphrase: 1234
|
||||||
|
port: 22
|
||||||
|
script:
|
||||||
|
- mkdir abc/def/efg
|
||||||
|
- echo "you can't see the steps."
|
||||||
|
```
|
||||||
|
|
||||||
## Secret Reference
|
## Secret Reference
|
||||||
|
|
||||||
ssh_username
|
ssh_username
|
||||||
@@ -147,6 +185,9 @@ ssh_username
|
|||||||
ssh_password
|
ssh_password
|
||||||
: password for target host user
|
: password for target host user
|
||||||
|
|
||||||
|
ssh_passphrase
|
||||||
|
: The purpose of the passphrase is usually to encrypt the private key.
|
||||||
|
|
||||||
ssh_key
|
ssh_key
|
||||||
: plain text of user private key
|
: plain text of user private key
|
||||||
|
|
||||||
@@ -156,6 +197,9 @@ proxy_ssh_username
|
|||||||
proxy_ssh_password
|
proxy_ssh_password
|
||||||
: password for user of proxy server
|
: password for user of proxy server
|
||||||
|
|
||||||
|
proxy_ssh_passphrase
|
||||||
|
: The purpose of the passphrase is usually to encrypt the private key.
|
||||||
|
|
||||||
proxy_ssh_key
|
proxy_ssh_key
|
||||||
: plain text of user private key for proxy server
|
: plain text of user private key for proxy server
|
||||||
|
|
||||||
@@ -189,10 +233,10 @@ script_stop
|
|||||||
: stop script after first failure
|
: stop script after first failure
|
||||||
|
|
||||||
timeout
|
timeout
|
||||||
: Timeout is the maximum amount of time for the TCP connection to establish.
|
: Timeout is the maximum amount of time for the ssh connection to establish, default is 30 seconds.
|
||||||
|
|
||||||
command_timeout
|
command_timeout
|
||||||
: Command timeout is the maximum amount of time for the execute commands, default is 60 secs.
|
: Command timeout is the maximum amount of time for the execute commands, default is 10 minutes.
|
||||||
|
|
||||||
proxy_host
|
proxy_host
|
||||||
: proxy hostname or IP
|
: proxy hostname or IP
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
DIST := dist
|
DIST := dist
|
||||||
EXECUTABLE := drone-ssh
|
EXECUTABLE := drone-ssh
|
||||||
GOFMT ?= gofmt "-s"
|
GOFMT ?= gofumpt -l -s
|
||||||
|
DIST := dist
|
||||||
|
DIST_DIRS := $(DIST)/binaries $(DIST)/release
|
||||||
GO ?= go
|
GO ?= go
|
||||||
|
SHASUM ?= shasum -a 256
|
||||||
|
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
||||||
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
|
XGO_VERSION := go-1.18.x
|
||||||
|
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10
|
||||||
|
|
||||||
# for dockerhub
|
LINUX_ARCHS ?= linux/amd64,linux/arm64
|
||||||
DEPLOY_ACCOUNT := appleboy
|
DARWIN_ARCHS ?= darwin-12/amd64,darwin-12/arm64
|
||||||
DEPLOY_IMAGE := $(EXECUTABLE)
|
WINDOWS_ARCHS ?= windows/amd64
|
||||||
|
|
||||||
TARGETS ?= linux darwin windows
|
|
||||||
ARCHS ?= amd64 386
|
|
||||||
PACKAGES ?= $(shell $(GO) list ./...)
|
|
||||||
SOURCES ?= $(shell find . -name "*.go" -type f)
|
|
||||||
TAGS ?=
|
|
||||||
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
|
||||||
|
|
||||||
ifneq ($(shell uname), Darwin)
|
ifneq ($(shell uname), Darwin)
|
||||||
EXTLDFLAGS = -extldflags "-static" $(null)
|
EXTLDFLAGS = -extldflags "-static" $(null)
|
||||||
@@ -20,42 +20,64 @@ else
|
|||||||
EXTLDFLAGS =
|
EXTLDFLAGS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(DRONE_TAG),)
|
ifeq ($(HAS_GO), GO)
|
||||||
VERSION ?= $(DRONE_TAG)
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
||||||
else
|
export PATH := $(GOPATH)/bin:$(PATH)
|
||||||
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
|
|
||||||
|
CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
|
||||||
|
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
GOFLAGS := -v -buildmode=exe
|
||||||
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
||||||
|
else ifeq ($(OS), Windows)
|
||||||
|
GOFLAGS := -v -buildmode=exe
|
||||||
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
||||||
|
else
|
||||||
|
GOFLAGS := -v
|
||||||
|
EXECUTABLE ?= $(EXECUTABLE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
STORED_VERSION_FILE := VERSION
|
||||||
|
|
||||||
|
ifneq ($(DRONE_TAG),)
|
||||||
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
||||||
|
RELASE_VERSION ?= $(VERSION)
|
||||||
|
else
|
||||||
|
ifneq ($(DRONE_BRANCH),)
|
||||||
|
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
||||||
|
else
|
||||||
|
VERSION ?= master
|
||||||
|
endif
|
||||||
|
|
||||||
|
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
||||||
|
ifneq ($(STORED_VERSION),)
|
||||||
|
RELASE_VERSION ?= $(STORED_VERSION)
|
||||||
|
else
|
||||||
|
RELASE_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
TAGS ?=
|
||||||
|
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
|
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) get -u mvdan.cc/gofumpt; \
|
||||||
|
fi
|
||||||
$(GOFMT) -w $(SOURCES)
|
$(GOFMT) -w $(SOURCES)
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
$(GO) vet $(PACKAGES)
|
$(GO) vet ./...
|
||||||
|
|
||||||
lint:
|
|
||||||
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/mgechev/revive; \
|
|
||||||
fi
|
|
||||||
revive -config .revive.toml ./... || exit 1
|
|
||||||
|
|
||||||
.PHONY: misspell-check
|
|
||||||
misspell-check:
|
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
misspell -error $(SOURCES)
|
|
||||||
|
|
||||||
.PHONY: misspell
|
|
||||||
misspell:
|
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
misspell -w $(SOURCES)
|
|
||||||
|
|
||||||
.PHONY: fmt-check
|
.PHONY: fmt-check
|
||||||
fmt-check:
|
fmt-check:
|
||||||
|
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) get -u mvdan.cc/gofumpt; \
|
||||||
|
fi
|
||||||
@diff=$$($(GOFMT) -d $(SOURCES)); \
|
@diff=$$($(GOFMT) -d $(SOURCES)); \
|
||||||
if [ -n "$$diff" ]; then \
|
if [ -n "$$diff" ]; then \
|
||||||
echo "Please run 'make fmt' and commit the result:"; \
|
echo "Please run 'make fmt' and commit the result:"; \
|
||||||
@@ -64,7 +86,7 @@ fmt-check:
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
test: fmt-check
|
test: fmt-check
|
||||||
@$(GO) test -v -cover -coverprofile coverage.txt $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
@$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
||||||
|
|
||||||
install: $(SOURCES)
|
install: $(SOURCES)
|
||||||
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
||||||
@@ -74,23 +96,6 @@ build: $(EXECUTABLE)
|
|||||||
$(EXECUTABLE): $(SOURCES)
|
$(EXECUTABLE): $(SOURCES)
|
||||||
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@
|
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@
|
||||||
|
|
||||||
release: release-dirs release-build release-copy release-check
|
|
||||||
|
|
||||||
release-dirs:
|
|
||||||
mkdir -p $(DIST)/binaries $(DIST)/release
|
|
||||||
|
|
||||||
release-build:
|
|
||||||
@which gox > /dev/null; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/mitchellh/gox; \
|
|
||||||
fi
|
|
||||||
gox -os="$(TARGETS)" -arch="$(ARCHS)" -tags="$(TAGS)" -ldflags="-s -w $(LDFLAGS)" -output="$(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
|
||||||
|
|
||||||
release-copy:
|
|
||||||
$(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
|
|
||||||
|
|
||||||
release-check:
|
|
||||||
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
|
|
||||||
|
|
||||||
build_linux_amd64:
|
build_linux_amd64:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE)
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE)
|
||||||
|
|
||||||
@@ -103,36 +108,69 @@ build_linux_arm64:
|
|||||||
build_linux_arm:
|
build_linux_arm:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE)
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE)
|
||||||
|
|
||||||
docker_image:
|
|
||||||
docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) .
|
|
||||||
|
|
||||||
docker: docker_image
|
|
||||||
|
|
||||||
docker_deploy:
|
|
||||||
ifeq ($(tag),)
|
|
||||||
@echo "Usage: make $@ tag=<tag>"
|
|
||||||
@exit 1
|
|
||||||
endif
|
|
||||||
# deploy image
|
|
||||||
docker tag $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):latest $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
|
|
||||||
docker push $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
|
|
||||||
|
|
||||||
ssh-server:
|
ssh-server:
|
||||||
adduser -h /home/drone-scp -s /bin/bash -D -S drone-scp
|
adduser -h /home/drone-scp -s /bin/sh -D -S drone-scp
|
||||||
echo drone-scp:1234 | chpasswd
|
echo drone-scp:1234 | chpasswd
|
||||||
mkdir -p /home/drone-scp/.ssh
|
mkdir -p /home/drone-scp/.ssh
|
||||||
chmod 700 /home/drone-scp/.ssh
|
chmod 700 /home/drone-scp/.ssh
|
||||||
cp tests/.ssh/id_rsa.pub /home/drone-scp/.ssh/authorized_keys
|
cat tests/.ssh/id_rsa.pub >> /home/drone-scp/.ssh/authorized_keys
|
||||||
|
cat tests/.ssh/test.pub >> /home/drone-scp/.ssh/authorized_keys
|
||||||
|
chmod 600 /home/drone-scp/.ssh/authorized_keys
|
||||||
chown -R drone-scp /home/drone-scp/.ssh
|
chown -R drone-scp /home/drone-scp/.ssh
|
||||||
# install ssh and start server
|
|
||||||
apk add --update openssh openrc
|
apk add --update openssh openrc
|
||||||
rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
|
rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
|
||||||
|
sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
|
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
|
||||||
./tests/entrypoint.sh /usr/sbin/sshd -D &
|
./tests/entrypoint.sh /usr/sbin/sshd -D &
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
sed -i '/main.go/d' coverage.txt
|
sed -i '/main.go/d' coverage.txt
|
||||||
|
|
||||||
|
.PHONY: deps-backend
|
||||||
|
deps-backend:
|
||||||
|
$(GO) mod download
|
||||||
|
$(GO) install $(GXZ_PAGAGE)
|
||||||
|
$(GO) install $(XGO_PACKAGE)
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: release-windows release-linux release-darwin release-copy release-compress release-check
|
||||||
|
|
||||||
|
$(DIST_DIRS):
|
||||||
|
mkdir -p $(DIST_DIRS)
|
||||||
|
|
||||||
|
.PHONY: release-windows
|
||||||
|
release-windows: | $(DIST_DIRS)
|
||||||
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(WINDOWS_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
||||||
|
ifeq ($(CI),true)
|
||||||
|
cp -r /build/* $(DIST)/binaries/
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release-linux
|
||||||
|
release-linux: | $(DIST_DIRS)
|
||||||
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
||||||
|
ifeq ($(CI),true)
|
||||||
|
cp -r /build/* $(DIST)/binaries/
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release-darwin
|
||||||
|
release-darwin: | $(DIST_DIRS)
|
||||||
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets '$(DARWIN_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
||||||
|
ifeq ($(CI),true)
|
||||||
|
cp -r /build/* $(DIST)/binaries/
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release-copy
|
||||||
|
release-copy: | $(DIST_DIRS)
|
||||||
|
cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
|
||||||
|
|
||||||
|
.PHONY: release-check
|
||||||
|
release-check: | $(DIST_DIRS)
|
||||||
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
|
||||||
|
|
||||||
|
.PHONY: release-compress
|
||||||
|
release-compress: | $(DIST_DIRS)
|
||||||
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PAGAGE) -k -9 $${file}; done;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(GO) clean -x -i ./...
|
$(GO) clean -x -i ./...
|
||||||
rm -rf coverage.txt $(EXECUTABLE) $(DIST)
|
rm -rf coverage.txt $(EXECUTABLE) $(DIST)
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
module github.com/appleboy/drone-ssh
|
module github.com/appleboy/drone-ssh
|
||||||
|
|
||||||
go 1.13
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/appleboy/easyssh-proxy v1.2.0
|
github.com/appleboy/easyssh-proxy v1.3.9
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.4.0
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.7.2
|
||||||
github.com/urfave/cli v1.22.1
|
github.com/urfave/cli v1.22.9
|
||||||
|
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5 // indirect
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.0 // indirect
|
||||||
|
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,29 +1,48 @@
|
|||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/appleboy/easyssh-proxy v1.2.0 h1:KvaUGC18WkBFet+N1oofQy03jkC5HaKFn2XGxFxCTtg=
|
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5 h1:VauE2GcJNZFun2Och6tIT2zJZK1v6jxALQDA9BIji/E=
|
||||||
github.com/appleboy/easyssh-proxy v1.2.0/go.mod h1:vHskChUNhxwW4dXMe2MNE/k+UBCkBagrQDm70UWZrS0=
|
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
github.com/appleboy/easyssh-proxy v1.3.9 h1:b+sVSTz+cVFvfA23HQywMMpm0s5g3gH7jYdBcQqaCQI=
|
||||||
|
github.com/appleboy/easyssh-proxy v1.3.9/go.mod h1:G1eQomBEME7NWKA3hE49s5HsT44S5fn0aBxX7k9Yjug=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0=
|
||||||
|
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||||
|
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
|
||||||
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
|
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.9 h1:cv3/KhXGBGjEXLC4bH0sLuJ9BewaAbpk5oyMOveu4pw=
|
||||||
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 h1:jsG6UpNLt9iAsb0S2AGW28DveNzzgmbXR+ENoPjUeIU=
|
github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
|
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
|
||||||
|
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 h1:PgOr27OhUx2IRqGJ2RxAWI4dJQ7bi9cSrB82uzFzfUA=
|
||||||
|
golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/appleboy/easyssh-proxy"
|
"github.com/appleboy/easyssh-proxy"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,6 +19,10 @@ func main() {
|
|||||||
_ = godotenv.Load(filename)
|
_ = godotenv.Load(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||||
|
_ = godotenv.Overload("/run/drone/env")
|
||||||
|
}
|
||||||
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "Drone SSH"
|
app.Name = "Drone SSH"
|
||||||
app.Usage = "Executing remote ssh commands"
|
app.Usage = "Executing remote ssh commands"
|
||||||
@@ -38,6 +41,11 @@ func main() {
|
|||||||
Usage: "private ssh key",
|
Usage: "private ssh key",
|
||||||
EnvVar: "PLUGIN_SSH_KEY,PLUGIN_KEY,SSH_KEY,KEY,INPUT_KEY",
|
EnvVar: "PLUGIN_SSH_KEY,PLUGIN_KEY,SSH_KEY,KEY,INPUT_KEY",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "ssh-passphrase",
|
||||||
|
Usage: "The purpose of the passphrase is usually to encrypt the private key.",
|
||||||
|
EnvVar: "PLUGIN_SSH_PASSPHRASE,PLUGIN_PASSPHRASE,SSH_PASSPHRASE,PASSPHRASE,INPUT_PASSPHRASE",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "key-path,i",
|
Name: "key-path,i",
|
||||||
Usage: "ssh private key path",
|
Usage: "ssh private key path",
|
||||||
@@ -55,9 +63,25 @@ func main() {
|
|||||||
EnvVar: "PLUGIN_PASSWORD,SSH_PASSWORD,PASSWORD,INPUT_PASSWORD",
|
EnvVar: "PLUGIN_PASSWORD,SSH_PASSWORD,PASSWORD,INPUT_PASSWORD",
|
||||||
},
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "host,H",
|
Name: "ciphers",
|
||||||
Usage: "connect to host",
|
Usage: "The allowed cipher algorithms. If unspecified then a sensible",
|
||||||
EnvVar: "PLUGIN_HOST,SSH_HOST,HOST,INPUT_HOST",
|
EnvVar: "PLUGIN_CIPHERS,SSH_CIPHERS,CIPHERS,INPUT_CIPHERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "useInsecureCipher",
|
||||||
|
Usage: "include more ciphers with use_insecure_cipher",
|
||||||
|
EnvVar: "PLUGIN_USE_INSECURE_CIPHER,SSH_USE_INSECURE_CIPHER,USE_INSECURE_CIPHER,INPUT_USE_INSECURE_CIPHER",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "fingerprint",
|
||||||
|
Usage: "fingerprint SHA256 of the host public key, default is to skip verification",
|
||||||
|
EnvVar: "PLUGIN_FINGERPRINT,SSH_FINGERPRINT,FINGERPRINT,INPUT_FINGERPRINT",
|
||||||
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "host,H",
|
||||||
|
Usage: "connect to host",
|
||||||
|
EnvVar: "PLUGIN_HOST,SSH_HOST,HOST,INPUT_HOST",
|
||||||
|
FilePath: ".host",
|
||||||
},
|
},
|
||||||
cli.IntFlag{
|
cli.IntFlag{
|
||||||
Name: "port,p",
|
Name: "port,p",
|
||||||
@@ -80,7 +104,7 @@ func main() {
|
|||||||
Name: "command.timeout,T",
|
Name: "command.timeout,T",
|
||||||
Usage: "command timeout",
|
Usage: "command timeout",
|
||||||
EnvVar: "PLUGIN_COMMAND_TIMEOUT,SSH_COMMAND_TIMEOUT,COMMAND_TIMEOUT,INPUT_COMMAND_TIMEOUT",
|
EnvVar: "PLUGIN_COMMAND_TIMEOUT,SSH_COMMAND_TIMEOUT,COMMAND_TIMEOUT,INPUT_COMMAND_TIMEOUT",
|
||||||
Value: 60 * time.Second,
|
Value: 10 * time.Minute,
|
||||||
},
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "script,s",
|
Name: "script,s",
|
||||||
@@ -102,6 +126,11 @@ func main() {
|
|||||||
Usage: "private ssh key of proxy",
|
Usage: "private ssh key of proxy",
|
||||||
EnvVar: "PLUGIN_PROXY_SSH_KEY,PLUGIN_PROXY_KEY,PROXY_SSH_KEY,INPUT_PROXY_KEY",
|
EnvVar: "PLUGIN_PROXY_SSH_KEY,PLUGIN_PROXY_KEY,PROXY_SSH_KEY,INPUT_PROXY_KEY",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "proxy.ssh-passphrase",
|
||||||
|
Usage: "The purpose of the passphrase is usually to encrypt the private key.",
|
||||||
|
EnvVar: "PLUGIN_PROXY_SSH_PASSPHRASE,PLUGIN_PROXY_PASSPHRASE,PROXY_SSH_PASSPHRASE,PROXY_PASSPHRASE,INPUT_PROXY_PASSPHRASE",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "proxy.key-path",
|
Name: "proxy.key-path",
|
||||||
Usage: "ssh private key path of proxy",
|
Usage: "ssh private key path of proxy",
|
||||||
@@ -134,6 +163,21 @@ func main() {
|
|||||||
Usage: "proxy connection timeout",
|
Usage: "proxy connection timeout",
|
||||||
EnvVar: "PLUGIN_PROXY_TIMEOUT,PROXY_SSH_TIMEOUT,INPUT_PROXY_TIMEOUT",
|
EnvVar: "PLUGIN_PROXY_TIMEOUT,PROXY_SSH_TIMEOUT,INPUT_PROXY_TIMEOUT",
|
||||||
},
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "proxy.ciphers",
|
||||||
|
Usage: "The allowed cipher algorithms. If unspecified then a sensible",
|
||||||
|
EnvVar: "PLUGIN_PROXY_CIPHERS,SSH_PROXY_CIPHERS,PROXY_CIPHERS,INPUT_PROXY_CIPHERS",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "proxy.useInsecureCipher",
|
||||||
|
Usage: "include more ciphers with use_insecure_cipher",
|
||||||
|
EnvVar: "PLUGIN_PROXY_USE_INSECURE_CIPHER,SSH_PROXY_USE_INSECURE_CIPHER,PROXY_USE_INSECURE_CIPHER,INPUT_PROXY_USE_INSECURE_CIPHER",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "proxy.fingerprint",
|
||||||
|
Usage: "fingerprint SHA256 of the host public key, default is to skip verification",
|
||||||
|
EnvVar: "PLUGIN_PROXY_FINGERPRINT,SSH_PROXY_FINGERPRINT,PROXY_FINGERPRINT,INPUT_PROXY_FINGERPRINT",
|
||||||
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "envs",
|
Name: "envs",
|
||||||
Usage: "pass environment variable to shell script",
|
Usage: "pass environment variable to shell script",
|
||||||
@@ -191,27 +235,35 @@ func run(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Key: c.String("ssh-key"),
|
Key: c.String("ssh-key"),
|
||||||
KeyPath: c.String("key-path"),
|
KeyPath: c.String("key-path"),
|
||||||
Username: c.String("user"),
|
Username: c.String("user"),
|
||||||
Password: c.String("password"),
|
Password: c.String("password"),
|
||||||
Host: c.StringSlice("host"),
|
Passphrase: c.String("ssh-passphrase"),
|
||||||
Port: c.Int("port"),
|
Fingerprint: c.String("fingerprint"),
|
||||||
Timeout: c.Duration("timeout"),
|
Host: c.StringSlice("host"),
|
||||||
CommandTimeout: c.Duration("command.timeout"),
|
Port: c.Int("port"),
|
||||||
Script: scripts,
|
Timeout: c.Duration("timeout"),
|
||||||
ScriptStop: c.Bool("script.stop"),
|
CommandTimeout: c.Duration("command.timeout"),
|
||||||
Envs: c.StringSlice("envs"),
|
Script: scripts,
|
||||||
Debug: c.Bool("debug"),
|
ScriptStop: c.Bool("script.stop"),
|
||||||
Sync: c.Bool("sync"),
|
Envs: c.StringSlice("envs"),
|
||||||
|
Debug: c.Bool("debug"),
|
||||||
|
Sync: c.Bool("sync"),
|
||||||
|
Ciphers: c.StringSlice("ciphers"),
|
||||||
|
UseInsecureCipher: c.Bool("useInsecureCipher"),
|
||||||
Proxy: easyssh.DefaultConfig{
|
Proxy: easyssh.DefaultConfig{
|
||||||
Key: c.String("proxy.ssh-key"),
|
Key: c.String("proxy.ssh-key"),
|
||||||
KeyPath: c.String("proxy.key-path"),
|
KeyPath: c.String("proxy.key-path"),
|
||||||
User: c.String("proxy.username"),
|
User: c.String("proxy.username"),
|
||||||
Password: c.String("proxy.password"),
|
Password: c.String("proxy.password"),
|
||||||
Server: c.String("proxy.host"),
|
Passphrase: c.String("proxy.ssh-passphrase"),
|
||||||
Port: c.String("proxy.port"),
|
Fingerprint: c.String("proxy.fingerprint"),
|
||||||
Timeout: c.Duration("proxy.timeout"),
|
Server: c.String("proxy.host"),
|
||||||
|
Port: c.String("proxy.port"),
|
||||||
|
Timeout: c.Duration("proxy.timeout"),
|
||||||
|
Ciphers: c.StringSlice("proxy.ciphers"),
|
||||||
|
UseInsecureCipher: c.Bool("proxy.useInsecureCipher"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Writer: os.Stdout,
|
Writer: os.Stdout,
|
||||||
|
|||||||
+23
-50
@@ -9,7 +9,7 @@
|
|||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
name: 'vet',
|
name: 'vet',
|
||||||
image: 'golang:1.13',
|
image: 'golang:1.18',
|
||||||
pull: 'always',
|
pull: 'always',
|
||||||
commands: [
|
commands: [
|
||||||
'make vet',
|
'make vet',
|
||||||
@@ -21,51 +21,23 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
name: 'lint',
|
// name: 'test',
|
||||||
image: 'golang:1.13',
|
// image: 'golang:1.18-alpine',
|
||||||
pull: 'always',
|
// pull: 'always',
|
||||||
commands: [
|
// commands: [
|
||||||
'make lint',
|
// 'apk add git make curl perl bash build-base zlib-dev ucl-dev',
|
||||||
],
|
// 'make ssh-server',
|
||||||
volumes: [
|
// 'make test',
|
||||||
{
|
// 'make coverage',
|
||||||
name: 'gopath',
|
// ],
|
||||||
path: '/go',
|
// volumes: [
|
||||||
},
|
// {
|
||||||
],
|
// name: 'gopath',
|
||||||
},
|
// path: '/go',
|
||||||
{
|
// },
|
||||||
name: 'misspell',
|
// ],
|
||||||
image: 'golang:1.13',
|
// },
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'make misspell-check',
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
path: '/go',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'test',
|
|
||||||
image: 'golang:1.13-alpine',
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'apk add git make curl perl bash build-base zlib-dev ucl-dev',
|
|
||||||
'make ssh-server',
|
|
||||||
'make test',
|
|
||||||
'make coverage',
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
path: '/go',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'codecov',
|
name: 'codecov',
|
||||||
image: 'robertstettner/drone-codecov',
|
image: 'robertstettner/drone-codecov',
|
||||||
@@ -93,7 +65,7 @@
|
|||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
name: 'build-push',
|
name: 'build-push',
|
||||||
image: 'golang:1.13',
|
image: 'golang:1.18',
|
||||||
pull: 'always',
|
pull: 'always',
|
||||||
environment: {
|
environment: {
|
||||||
CGO_ENABLED: '0',
|
CGO_ENABLED: '0',
|
||||||
@@ -109,7 +81,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'build-tag',
|
name: 'build-tag',
|
||||||
image: 'golang:1.13',
|
image: 'golang:1.18',
|
||||||
pull: 'always',
|
pull: 'always',
|
||||||
environment: {
|
environment: {
|
||||||
CGO_ENABLED: '0',
|
CGO_ENABLED: '0',
|
||||||
@@ -123,7 +95,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'executable',
|
name: 'executable',
|
||||||
image: 'golang:1.13',
|
image: 'golang:1.18',
|
||||||
pull: 'always',
|
pull: 'always',
|
||||||
commands: [
|
commands: [
|
||||||
'./release/' + os + '/' + arch + '/' + name + ' --help',
|
'./release/' + os + '/' + arch + '/' + name + ' --help',
|
||||||
@@ -188,9 +160,10 @@
|
|||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
name: 'build-all-binary',
|
name: 'build-all-binary',
|
||||||
image: 'golang:1.13',
|
image: 'techknowlogick/xgo:go-1.18.x',
|
||||||
pull: 'always',
|
pull: 'always',
|
||||||
commands: [
|
commands: [
|
||||||
|
'export PATH=$PATH:$GOPATH/bin',
|
||||||
'make release'
|
'make release'
|
||||||
],
|
],
|
||||||
when: {
|
when: {
|
||||||
|
|||||||
@@ -23,20 +23,24 @@ var (
|
|||||||
type (
|
type (
|
||||||
// Config for the plugin.
|
// Config for the plugin.
|
||||||
Config struct {
|
Config struct {
|
||||||
Key string
|
Key string
|
||||||
KeyPath string
|
Passphrase string
|
||||||
Username string
|
KeyPath string
|
||||||
Password string
|
Username string
|
||||||
Host []string
|
Password string
|
||||||
Port int
|
Host []string
|
||||||
Timeout time.Duration
|
Port int
|
||||||
CommandTimeout time.Duration
|
Fingerprint string
|
||||||
Script []string
|
Timeout time.Duration
|
||||||
ScriptStop bool
|
CommandTimeout time.Duration
|
||||||
Envs []string
|
Script []string
|
||||||
Proxy easyssh.DefaultConfig
|
ScriptStop bool
|
||||||
Debug bool
|
Envs []string
|
||||||
Sync bool
|
Proxy easyssh.DefaultConfig
|
||||||
|
Debug bool
|
||||||
|
Sync bool
|
||||||
|
Ciphers []string
|
||||||
|
UseInsecureCipher bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin structure
|
// Plugin structure
|
||||||
@@ -50,24 +54,44 @@ func escapeArg(arg string) string {
|
|||||||
return "'" + strings.Replace(arg, "'", `'\''`, -1) + "'"
|
return "'" + strings.Replace(arg, "'", `'\''`, -1) + "'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p Plugin) hostPort(host string) (string, string) {
|
||||||
|
hosts := strings.Split(host, ":")
|
||||||
|
port := strconv.Itoa(p.Config.Port)
|
||||||
|
if len(hosts) > 1 {
|
||||||
|
host = hosts[0]
|
||||||
|
port = hosts[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return host, port
|
||||||
|
}
|
||||||
|
|
||||||
func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) {
|
func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) {
|
||||||
|
host, port := p.hostPort(host)
|
||||||
// Create MakeConfig instance with remote username, server address and path to private key.
|
// Create MakeConfig instance with remote username, server address and path to private key.
|
||||||
ssh := &easyssh.MakeConfig{
|
ssh := &easyssh.MakeConfig{
|
||||||
Server: host,
|
Server: host,
|
||||||
User: p.Config.Username,
|
User: p.Config.Username,
|
||||||
Password: p.Config.Password,
|
Password: p.Config.Password,
|
||||||
Port: strconv.Itoa(p.Config.Port),
|
Port: port,
|
||||||
Key: p.Config.Key,
|
Key: p.Config.Key,
|
||||||
KeyPath: p.Config.KeyPath,
|
KeyPath: p.Config.KeyPath,
|
||||||
Timeout: p.Config.Timeout,
|
Passphrase: p.Config.Passphrase,
|
||||||
|
Timeout: p.Config.Timeout,
|
||||||
|
Ciphers: p.Config.Ciphers,
|
||||||
|
Fingerprint: p.Config.Fingerprint,
|
||||||
|
UseInsecureCipher: p.Config.UseInsecureCipher,
|
||||||
Proxy: easyssh.DefaultConfig{
|
Proxy: easyssh.DefaultConfig{
|
||||||
Server: p.Config.Proxy.Server,
|
Server: p.Config.Proxy.Server,
|
||||||
User: p.Config.Proxy.User,
|
User: p.Config.Proxy.User,
|
||||||
Password: p.Config.Proxy.Password,
|
Password: p.Config.Proxy.Password,
|
||||||
Port: p.Config.Proxy.Port,
|
Port: p.Config.Proxy.Port,
|
||||||
Key: p.Config.Proxy.Key,
|
Key: p.Config.Proxy.Key,
|
||||||
KeyPath: p.Config.Proxy.KeyPath,
|
KeyPath: p.Config.Proxy.KeyPath,
|
||||||
Timeout: p.Config.Proxy.Timeout,
|
Passphrase: p.Config.Proxy.Passphrase,
|
||||||
|
Timeout: p.Config.Proxy.Timeout,
|
||||||
|
Ciphers: p.Config.Proxy.Ciphers,
|
||||||
|
Fingerprint: p.Config.Proxy.Fingerprint,
|
||||||
|
UseInsecureCipher: p.Config.Proxy.UseInsecureCipher,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,11 +219,12 @@ func (p Plugin) scriptCommands() []string {
|
|||||||
commands := make([]string, 0)
|
commands := make([]string, 0)
|
||||||
|
|
||||||
for _, cmd := range scripts {
|
for _, cmd := range scripts {
|
||||||
|
cmd = strings.TrimSpace(cmd)
|
||||||
if strings.TrimSpace(cmd) == "" {
|
if strings.TrimSpace(cmd) == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
commands = append(commands, cmd)
|
commands = append(commands, cmd)
|
||||||
if p.Config.ScriptStop {
|
if p.Config.ScriptStop && cmd[(len(cmd)-1):] != "\\" {
|
||||||
commands = append(commands, "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;")
|
commands = append(commands, "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+186
-6
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -11,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/appleboy/easyssh-proxy"
|
"github.com/appleboy/easyssh-proxy"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMissingHostOrUser(t *testing.T) {
|
func TestMissingHostOrUser(t *testing.T) {
|
||||||
@@ -384,6 +386,78 @@ func TestCommandOutput(t *testing.T) {
|
|||||||
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWrongFingerprint(t *testing.T) {
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Host: []string{"localhost"},
|
||||||
|
Username: "drone-scp",
|
||||||
|
Port: 22,
|
||||||
|
KeyPath: "./tests/.ssh/id_rsa",
|
||||||
|
Script: []string{
|
||||||
|
"whoami",
|
||||||
|
},
|
||||||
|
Fingerprint: "wrong",
|
||||||
|
},
|
||||||
|
Writer: &buffer,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := plugin.Exec()
|
||||||
|
assert.NotNil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHostPublicKeyFile(keypath string) (ssh.PublicKey, error) {
|
||||||
|
var pubkey ssh.PublicKey
|
||||||
|
var err error
|
||||||
|
buf, err := ioutil.ReadFile(keypath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pubkey, _, _, _, err = ssh.ParseAuthorizedKey(buf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubkey, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFingerprint(t *testing.T) {
|
||||||
|
var (
|
||||||
|
buffer bytes.Buffer
|
||||||
|
expected = `
|
||||||
|
======CMD======
|
||||||
|
whoami
|
||||||
|
======END======
|
||||||
|
out: drone-scp
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
hostKey, err := getHostPublicKeyFile("/etc/ssh/ssh_host_rsa_key.pub")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Host: []string{"localhost"},
|
||||||
|
Username: "drone-scp",
|
||||||
|
Port: 22,
|
||||||
|
KeyPath: "./tests/.ssh/id_rsa",
|
||||||
|
Script: []string{
|
||||||
|
"whoami",
|
||||||
|
},
|
||||||
|
Fingerprint: ssh.FingerprintSHA256(hostKey),
|
||||||
|
CommandTimeout: 10 * time.Second,
|
||||||
|
},
|
||||||
|
Writer: &buffer,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = plugin.Exec()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
||||||
|
}
|
||||||
|
|
||||||
func TestScriptStop(t *testing.T) {
|
func TestScriptStop(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
buffer bytes.Buffer
|
buffer bytes.Buffer
|
||||||
@@ -494,12 +568,13 @@ func TestEnvOutput(t *testing.T) {
|
|||||||
|
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Host: []string{"localhost"},
|
Host: []string{"localhost"},
|
||||||
Username: "drone-scp",
|
Username: "drone-scp",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
KeyPath: "./tests/.ssh/id_rsa",
|
KeyPath: "./tests/.ssh/test",
|
||||||
Envs: []string{"env_1", "env_2", "env_3", "env_4", "env_5", "env_6", "env_7"},
|
Passphrase: "1234",
|
||||||
Debug: true,
|
Envs: []string{"env_1", "env_2", "env_3", "env_4", "env_5", "env_6", "env_7"},
|
||||||
|
Debug: true,
|
||||||
Script: []string{
|
Script: []string{
|
||||||
`echo "[${ENV_1}]"`,
|
`echo "[${ENV_1}]"`,
|
||||||
`echo "[${ENV_2}]"`,
|
`echo "[${ENV_2}]"`,
|
||||||
@@ -569,6 +644,17 @@ func TestPlugin_scriptCommands(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: []string{"mkdir a", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir c", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir b", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;"},
|
want: []string{"mkdir a", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir c", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir b", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;"},
|
||||||
},
|
},
|
||||||
|
// See: https://github.com/appleboy/ssh-action/issues/75#issuecomment-668314271
|
||||||
|
{
|
||||||
|
name: "Multiline SSH commands interpreted as single lines",
|
||||||
|
fields: fields{
|
||||||
|
Config: Config{
|
||||||
|
Script: []string{"ls \\ ", "-lah", "mkdir a"},
|
||||||
|
ScriptStop: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: []string{"ls \\", "-lah", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;", "mkdir a", "DRONE_SSH_PREV_COMMAND_EXIT_CODE=$? ; if [ $DRONE_SSH_PREV_COMMAND_EXIT_CODE -ne 0 ]; then exit $DRONE_SSH_PREV_COMMAND_EXIT_CODE; fi;"},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "trim space",
|
name: "trim space",
|
||||||
fields: fields{
|
fields: fields{
|
||||||
@@ -592,3 +678,97 @@ func TestPlugin_scriptCommands(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUseInsecureCipher(t *testing.T) {
|
||||||
|
var (
|
||||||
|
buffer bytes.Buffer
|
||||||
|
expected = `
|
||||||
|
======CMD======
|
||||||
|
mkdir a/b/c
|
||||||
|
mkdir d/e/f
|
||||||
|
======END======
|
||||||
|
err: mkdir: can't create directory 'a/b/c': No such file or directory
|
||||||
|
err: mkdir: can't create directory 'd/e/f': No such file or directory
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Host: []string{"localhost"},
|
||||||
|
Username: "drone-scp",
|
||||||
|
Port: 22,
|
||||||
|
KeyPath: "./tests/.ssh/id_rsa",
|
||||||
|
Script: []string{
|
||||||
|
"mkdir a/b/c",
|
||||||
|
"mkdir d/e/f",
|
||||||
|
},
|
||||||
|
CommandTimeout: 10 * time.Second,
|
||||||
|
UseInsecureCipher: true,
|
||||||
|
},
|
||||||
|
Writer: &buffer,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := plugin.Exec()
|
||||||
|
assert.NotNil(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPlugin_hostPort(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Config Config
|
||||||
|
Writer io.Writer
|
||||||
|
}
|
||||||
|
type args struct {
|
||||||
|
h string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
args args
|
||||||
|
wantHost string
|
||||||
|
wantPort string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "default host and port",
|
||||||
|
fields: fields{
|
||||||
|
Config: Config{
|
||||||
|
Port: 22,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
h: "localhost",
|
||||||
|
},
|
||||||
|
wantHost: "localhost",
|
||||||
|
wantPort: "22",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "different port",
|
||||||
|
fields: fields{
|
||||||
|
Config: Config{
|
||||||
|
Port: 22,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
h: "localhost:443",
|
||||||
|
},
|
||||||
|
wantHost: "localhost",
|
||||||
|
wantPort: "443",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
p := Plugin{
|
||||||
|
Config: tt.fields.Config,
|
||||||
|
Writer: tt.fields.Writer,
|
||||||
|
}
|
||||||
|
gotHost, gotPort := p.hostPort(tt.args.h)
|
||||||
|
if gotHost != tt.wantHost {
|
||||||
|
t.Errorf("Plugin.hostPort() gotHost = %v, want %v", gotHost, tt.wantHost)
|
||||||
|
}
|
||||||
|
if gotPort != tt.wantPort {
|
||||||
|
t.Errorf("Plugin.hostPort() gotPort = %v, want %v", gotPort, tt.wantPort)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
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
|
||||||
|
l4njcaMpg4tpQMHtCBOicGyV0=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDz6aZ1jY2onnuj2YNHJ/HhfvIu0B973v/+pFFOavnTUOhEEKEy3TASu+s9CkHrYZAtRc+QYIkNZI31mhHBhotdeP/7GoO2UirkFtrzyQKPNJxEcv0RBoG9ssN8jex0PyK6DHIYYFnIWadVBEEOh/H+rK7j7u2/big3oTzYBuFrCwmYFcz5na99MzFeAUhazF44gVBma+zO+1quGeqF51UDIg1SMGvX8I7LNEqrKEBaIUQJKFQcxlOWlRLQsjJCymrOujsXsRrXHAQWcnxDcNevv2ZMOUl0ybvv9yH0BiGbRBd1Hy8/QPILbAQaqu0oQE7fubN8Q8lqb3Jg0loID4x/5GPhSY8WAXpuLcXTOrb93SnCw1JsAgJDNqpuuRFy3BSZ7wBOr1jfeIoo7xk14OHiUjJ0uXDL9cLMkcw6ElWz81mrD2VCkXUz+qFyjJ+G7aGWRtctZoOzKln4yfNfUmwW8/8ra3QnmrMZ2xW2Ylw3ZhO+tLi7jINHYFb54bAdLVPUU1ctIuJns2qkWnjJCxxMiynIqCif20/OU1n8CTJuOWiURmRdmvKOH4PE3JxC2Qnk/3tV3Cf8hp1CH5VjBZ9AjGj5MDMHXyu34VY2WvYo5QyzfS3ySPoT8kCO0G0xpvjwCMHOK+G2RP4kqb/KKZguiKdgintBXuskTlJmD7kcMQ== deploy@easyssh
|
||||||
Reference in New Issue
Block a user