mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-14 05:12:37 +08:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0745e13d39 | |||
| f1301199ca | |||
| 6fd87e0460 | |||
| cf09357b85 | |||
| 9bfb71b9ef | |||
| 9d8fc691c1 | |||
| 244d28d58a | |||
| 42d07ba823 | |||
| dd5f3b500f | |||
| 95b01590dc | |||
| c42b26f044 | |||
| 244b0a9e58 | |||
| 8b578d1df8 | |||
| ea5c04f515 | |||
| f4da147fda | |||
| 54bc4f9c50 | |||
| 2f24f092e0 | |||
| c66c78f88f | |||
| 9723eea384 | |||
| 14ec2704bd | |||
| a1482e89a3 | |||
| 9bf9ed00a4 | |||
| 6bc14e020b | |||
| c309cf901d | |||
| 4c5df18366 | |||
| 5ec7c1ddf8 | |||
| 1c9314ed83 | |||
| 5672c1219f |
@@ -1,24 +0,0 @@
|
|||||||
name: Release Binary
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: techknowlogick/xgo:go-1.19.x
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
# - name: Release binary
|
|
||||||
# run: |
|
|
||||||
# ls -al
|
|
||||||
# make release
|
|
||||||
@@ -6,13 +6,16 @@ on:
|
|||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1'
|
go-version: '^1'
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -23,16 +26,12 @@ jobs:
|
|||||||
- name: Build binary
|
- name: Build binary
|
||||||
run : |
|
run : |
|
||||||
make build_linux_amd64
|
make build_linux_amd64
|
||||||
make build_linux_arm64
|
|
||||||
make build_linux_arm
|
make build_linux_arm
|
||||||
|
make build_linux_arm64
|
||||||
- name: Check binary
|
|
||||||
run : |
|
|
||||||
./release/linux/amd64/drone-scp --help
|
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
@@ -53,86 +52,26 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Docker meta for linux amd64
|
name: Docker meta
|
||||||
id: meta-linux-amd64
|
id: docker-meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
suffix=linux-amd64
|
|
||||||
images: |
|
images: |
|
||||||
appleboy/drone-scp
|
${{ github.repository }}
|
||||||
ghcr.io/appleboy/drone-scp
|
ghcr.io/${{ github.repository }}
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
type=raw,value=latest,suffix=,enable={{is_default_branch}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,event=tag,pattern={{version}},suffix=-linux-amd64
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-amd64
|
type=semver,pattern={{major}}
|
||||||
type=semver,event=tag,pattern={{major}},suffix=-linux-amd64
|
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Build and push linux amd64
|
name: Build and push
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/Dockerfile.linux.amd64
|
platforms: linux/amd64,linux/arm,linux/arm64
|
||||||
platforms: linux/amd64
|
file: docker/Dockerfile
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta-linux-amd64.outputs.tags }}
|
tags: ${{ steps.docker-meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta-linux-amd64.outputs.labels }}
|
labels: ${{ steps.docker-meta.outputs.labels }}
|
||||||
|
|
||||||
-
|
|
||||||
name: Docker meta for linux arm64
|
|
||||||
id: meta-linux-arm64
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
suffix=linux-arm64
|
|
||||||
images: |
|
|
||||||
appleboy/drone-scp
|
|
||||||
ghcr.io/appleboy/drone-scp
|
|
||||||
tags: |
|
|
||||||
type=raw,value=,enable={{is_default_branch}}
|
|
||||||
type=semver,event=tag,pattern={{version}},suffix=-linux-arm64
|
|
||||||
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm64
|
|
||||||
type=semver,event=tag,pattern={{major}},suffix=-linux-arm64
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Build and push linux arm64
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: docker/Dockerfile.linux.arm64
|
|
||||||
platforms: linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta-linux-arm64.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-linux-arm64.outputs.labels }}
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Docker meta for linux arm
|
|
||||||
id: meta-linux-arm
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
suffix=linux-arm
|
|
||||||
images: |
|
|
||||||
appleboy/drone-scp
|
|
||||||
ghcr.io/appleboy/drone-scp
|
|
||||||
tags: |
|
|
||||||
type=raw,value=,enable={{is_default_branch}}
|
|
||||||
type=semver,event=tag,pattern={{version}},suffix=-linux-arm
|
|
||||||
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm
|
|
||||||
type=semver,event=tag,pattern={{major}},suffix=-linux-arm
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Build and push linux arm
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: docker/Dockerfile.linux.arm
|
|
||||||
platforms: linux/arm
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta-linux-arm.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-linux-arm.outputs.labels }}
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
-
|
||||||
name: Setup go
|
name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1'
|
go-version: '^1'
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1'
|
go-version: '^1'
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -20,22 +20,14 @@ jobs:
|
|||||||
version: latest
|
version: latest
|
||||||
args: --verbose
|
args: --verbose
|
||||||
|
|
||||||
- uses: hadolint/hadolint-action@v3.0.0
|
- uses: hadolint/hadolint-action@v3.1.0
|
||||||
name: hadolint for Dockerfile.linux.amd64
|
name: hadolint for Dockerfile
|
||||||
with:
|
with:
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
dockerfile: docker/Dockerfile
|
||||||
- uses: hadolint/hadolint-action@v3.0.0
|
|
||||||
name: hadolint for Dockerfile.linux.arm64
|
|
||||||
with:
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
|
||||||
- uses: hadolint/hadolint-action@v3.0.0
|
|
||||||
name: hadolint for Dockerfile.linux.arm
|
|
||||||
with:
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
|
||||||
|
|
||||||
testing:
|
testing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: golang:1.19-alpine
|
container: golang:1.20-alpine
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
goarm:
|
||||||
|
- "5"
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
ignore:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm
|
||||||
|
- goos: darwin
|
||||||
|
goarch: ppc64le
|
||||||
|
- goos: darwin
|
||||||
|
goarch: s390x
|
||||||
|
- goos: windows
|
||||||
|
goarch: ppc64le
|
||||||
|
- goos: windows
|
||||||
|
goarch: s390x
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: "5"
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: ppc64le
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: s390x
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
goarm: "5"
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm64
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X main.Version={{.Version}}
|
||||||
|
binary: >-
|
||||||
|
{{ .ProjectName }}-
|
||||||
|
{{- if .IsSnapshot }}{{ .Branch }}-
|
||||||
|
{{- else }}{{- .Version }}-{{ end }}
|
||||||
|
{{- .Os }}-
|
||||||
|
{{- if eq .Arch "amd64" }}amd64
|
||||||
|
{{- else if eq .Arch "amd64_v1" }}amd64
|
||||||
|
{{- else if eq .Arch "386" }}386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}-{{ .Arm }}{{ end }}
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- format: binary
|
||||||
|
name_template: "{{ .Binary }}"
|
||||||
|
allow_different_binary_count: true
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}"
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
ignored:
|
|
||||||
- DL3018
|
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func rmcmd(os, target string) string {
|
||||||
|
switch os {
|
||||||
|
case "windows":
|
||||||
|
return "DEL /F /S " + target
|
||||||
|
case "unix":
|
||||||
|
return "rm -rf " + target
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func mkdircmd(os, target string) string {
|
||||||
|
switch os {
|
||||||
|
case "windows":
|
||||||
|
return "if not exist " + target + " mkdir " + target
|
||||||
|
case "unix":
|
||||||
|
return "mkdir -p " + target
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
FROM alpine:3.17
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||||
|
org.label-schema.name="SCP Plugin" \
|
||||||
|
org.label-schema.vendor="Bo-Yi Wu" \
|
||||||
|
org.label-schema.schema-version="1.0"
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/appleboy/drone-scp
|
||||||
|
LABEL org.opencontainers.image.description="Copy files and artifacts via SSH"
|
||||||
|
LABEL org.opencontainers.image.licenses=MIT
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates=20220614-r4 && \
|
||||||
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
COPY release/${TARGETOS}/${TARGETARCH}/drone-scp /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-scp"]
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
FROM plugins/base:linux-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone SCP" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates && \
|
|
||||||
rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
COPY release/linux/amd64/drone-scp /bin/
|
|
||||||
ENTRYPOINT ["/bin/drone-scp"]
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
FROM plugins/base:linux-arm
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone SCP" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates && \
|
|
||||||
rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
COPY release/linux/arm/drone-scp /bin/
|
|
||||||
ENTRYPOINT ["/bin/drone-scp"]
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
FROM plugins/base:linux-arm64
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone SCP" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates && \
|
|
||||||
rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
COPY release/linux/arm64/drone-scp /bin/
|
|
||||||
ENTRYPOINT ["/bin/drone-scp"]
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
FROM microsoft/nanoserver:10.0.14393.1884
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone SCP" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
COPY drone-scp.exe /drone-scp.exe
|
|
||||||
|
|
||||||
ENTRYPOINT [ "\\drone-scp.exe" ]
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
image: appleboy/drone-scp:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
|
||||||
{{#if build.tags}}
|
|
||||||
tags:
|
|
||||||
{{#each build.tags}}
|
|
||||||
- {{this}}
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
|
||||||
manifests:
|
|
||||||
-
|
|
||||||
image: appleboy/drone-scp:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
-
|
|
||||||
image: appleboy/drone-scp:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
||||||
-
|
|
||||||
image: appleboy/drone-scp:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
module github.com/appleboy/drone-scp
|
module github.com/appleboy/drone-scp
|
||||||
|
|
||||||
go 1.18
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/appleboy/com v0.1.6
|
github.com/appleboy/com v0.1.7
|
||||||
github.com/appleboy/easyssh-proxy v1.3.9
|
github.com/appleboy/easyssh-proxy v1.3.9
|
||||||
github.com/fatih/color v1.13.0
|
github.com/fatih/color v1.15.0
|
||||||
github.com/joho/godotenv v1.4.0
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.2
|
||||||
github.com/urfave/cli/v2 v2.23.7
|
github.com/urfave/cli/v2 v2.25.1
|
||||||
golang.org/x/crypto v0.4.0
|
golang.org/x/crypto v0.8.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -18,10 +18,10 @@ require (
|
|||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
|
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
golang.org/x/sys v0.3.0 // indirect
|
golang.org/x/sys v0.7.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
|
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
|
||||||
github.com/ScaleFT/sshkeys v1.2.0 h1:5BRp6rTVIhJzXT3VcUQrKgXR8zWA3sOsNeuyW15WUA8=
|
github.com/ScaleFT/sshkeys v1.2.0 h1:5BRp6rTVIhJzXT3VcUQrKgXR8zWA3sOsNeuyW15WUA8=
|
||||||
github.com/ScaleFT/sshkeys v1.2.0/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
|
github.com/ScaleFT/sshkeys v1.2.0/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
|
||||||
github.com/appleboy/com v0.1.6 h1:vP9ryTIbSFaXSrZcFTU7RRcgPbrpGJ0Oy5wpgEkQ2m8=
|
github.com/appleboy/com v0.1.7 h1:4lYTFNoMAAXGGIC8lDxVg/NY+1aXbYqfAWN05cZhd0M=
|
||||||
github.com/appleboy/com v0.1.6/go.mod h1:jnufjIC3opMlReyPPPye+8JqNvUzLm25o7h6SOy8nv0=
|
github.com/appleboy/com v0.1.7/go.mod h1:JUK+oH0SXCLRH57pDMJx6VWVsm8CPdajalmRSWwamBE=
|
||||||
github.com/appleboy/easyssh-proxy v1.3.9 h1:b+sVSTz+cVFvfA23HQywMMpm0s5g3gH7jYdBcQqaCQI=
|
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/appleboy/easyssh-proxy v1.3.9/go.mod h1:G1eQomBEME7NWKA3hE49s5HsT44S5fn0aBxX7k9Yjug=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||||
@@ -12,18 +12,15 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU=
|
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU=
|
||||||
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0=
|
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0=
|
||||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||||
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
||||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
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.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
@@ -35,30 +32,28 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
|||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY=
|
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
|
||||||
github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
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-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
|
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
|
||||||
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
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-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-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||||
|
golang.org/x/sys v0.7.0/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-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
|
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
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=
|
||||||
|
|||||||
@@ -264,6 +264,11 @@ func main() {
|
|||||||
Usage: "use --unlink-first flag with tar",
|
Usage: "use --unlink-first flag with tar",
|
||||||
EnvVars: []string{"PLUGIN_UNLINK_FIRST", "SCP_UNLINK_FIRST", "INPUT_UNLINK_FIRST"},
|
EnvVars: []string{"PLUGIN_UNLINK_FIRST", "SCP_UNLINK_FIRST", "INPUT_UNLINK_FIRST"},
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "tar.dereference",
|
||||||
|
Usage: "use --dereference flag with tar",
|
||||||
|
EnvVars: []string{"PLUGIN_TAR_DEREFERENCE", "SCP_TAR_DEREFERENCE", "INPUT_TAR_DEREFERENCE"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override a template
|
// Override a template
|
||||||
@@ -342,6 +347,7 @@ func run(c *cli.Context) error {
|
|||||||
UnlinkFirst: c.Bool("unlink.first"),
|
UnlinkFirst: c.Bool("unlink.first"),
|
||||||
Ciphers: c.StringSlice("ciphers"),
|
Ciphers: c.StringSlice("ciphers"),
|
||||||
UseInsecureCipher: c.Bool("useInsecureCipher"),
|
UseInsecureCipher: c.Bool("useInsecureCipher"),
|
||||||
|
TarDereference: c.Bool("tar.dereference"),
|
||||||
Proxy: easyssh.DefaultConfig{
|
Proxy: easyssh.DefaultConfig{
|
||||||
Key: c.String("proxy.ssh-key"),
|
Key: c.String("proxy.ssh-key"),
|
||||||
Passphrase: c.String("proxy.ssh-passphrase"),
|
Passphrase: c.String("proxy.ssh-passphrase"),
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
errMissingHost = errors.New("Error: missing server host")
|
errMissingHost = errors.New("Error: missing server host")
|
||||||
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
|
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
|
||||||
errSetPasswordandKey = errors.New("can't set password and key at the same time")
|
|
||||||
errMissingSourceOrTarget = errors.New("missing source or target config")
|
errMissingSourceOrTarget = errors.New("missing source or target config")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -66,6 +65,7 @@ type (
|
|||||||
UnlinkFirst bool
|
UnlinkFirst bool
|
||||||
Ciphers []string
|
Ciphers []string
|
||||||
UseInsecureCipher bool
|
UseInsecureCipher bool
|
||||||
|
TarDereference bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin values.
|
// Plugin values.
|
||||||
@@ -86,27 +86,12 @@ func (e copyError) Error() string {
|
|||||||
return fmt.Sprintf("error copy file to dest: %s, error message: %s\n", e.host, e.message)
|
return fmt.Sprintf("error copy file to dest: %s, error message: %s\n", e.host, e.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func trimPath(keys []string) []string {
|
|
||||||
var newKeys []string
|
|
||||||
|
|
||||||
for _, value := range keys {
|
|
||||||
value = strings.Trim(value, " ")
|
|
||||||
if len(value) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
newKeys = append(newKeys, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return newKeys
|
|
||||||
}
|
|
||||||
|
|
||||||
func globList(paths []string) fileList {
|
func globList(paths []string) fileList {
|
||||||
var list fileList
|
var list fileList
|
||||||
|
|
||||||
for _, pattern := range paths {
|
for _, pattern := range paths {
|
||||||
ignore := false
|
ignore := false
|
||||||
pattern = strings.Trim(pattern, " ")
|
pattern = strings.TrimSpace(pattern)
|
||||||
if string(pattern[0]) == "!" {
|
if string(pattern[0]) == "!" {
|
||||||
pattern = pattern[1:]
|
pattern = pattern[1:]
|
||||||
ignore = true
|
ignore = true
|
||||||
@@ -127,21 +112,6 @@ func globList(paths []string) fileList {
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildArgs(tar string, files fileList) []string {
|
|
||||||
args := []string{}
|
|
||||||
if len(files.Ignore) > 0 {
|
|
||||||
for _, v := range files.Ignore {
|
|
||||||
args = append(args, "--exclude")
|
|
||||||
args = append(args, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
args = append(args, "-cf")
|
|
||||||
args = append(args, getRealPath(tar))
|
|
||||||
args = append(args, files.Source...)
|
|
||||||
|
|
||||||
return args
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Plugin) log(host string, message ...interface{}) {
|
func (p Plugin) log(host string, message ...interface{}) {
|
||||||
if count := len(p.Config.Host); count == 1 {
|
if count := len(p.Config.Host); count == 1 {
|
||||||
fmt.Printf("%s", fmt.Sprintln(message...))
|
fmt.Printf("%s", fmt.Sprintln(message...))
|
||||||
@@ -150,9 +120,9 @@ func (p Plugin) log(host string, message ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) removeDestFile(ssh *easyssh.MakeConfig) error {
|
func (p *Plugin) removeDestFile(os string, ssh *easyssh.MakeConfig) error {
|
||||||
p.log(ssh.Server, "remove file", p.DestFile)
|
p.log(ssh.Server, "remove file", p.DestFile)
|
||||||
_, errStr, _, err := ssh.Run(fmt.Sprintf("rm -rf %s", p.DestFile), p.Config.CommandTimeout)
|
_, errStr, _, err := ssh.Run(rmcmd(os, p.DestFile), p.Config.CommandTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -165,7 +135,7 @@ func (p *Plugin) removeDestFile(ssh *easyssh.MakeConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) removeAllDestFile() error {
|
func (p *Plugin) removeAllDestFile() error {
|
||||||
for _, host := range p.Config.Host {
|
for _, host := range trimValues(p.Config.Host) {
|
||||||
ssh := &easyssh.MakeConfig{
|
ssh := &easyssh.MakeConfig{
|
||||||
Server: host,
|
Server: host,
|
||||||
User: p.Config.Username,
|
User: p.Config.Username,
|
||||||
@@ -193,8 +163,19 @@ func (p *Plugin) removeAllDestFile() error {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, _, _, err := ssh.Run("ver", p.Config.CommandTimeout)
|
||||||
|
systemType := "unix"
|
||||||
|
if err == nil {
|
||||||
|
systemType = "windows"
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, _, err = ssh.Run("uname", p.Config.CommandTimeout)
|
||||||
|
if err == nil {
|
||||||
|
systemType = "unix"
|
||||||
|
}
|
||||||
|
|
||||||
// remove tar file
|
// remove tar file
|
||||||
err := p.removeDestFile(ssh)
|
err = p.removeDestFile(systemType, ssh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -208,12 +189,33 @@ type fileList struct {
|
|||||||
Source []string
|
Source []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) buildArgs(target string) []string {
|
func (p *Plugin) buildTarArgs(src string) []string {
|
||||||
|
files := globList(trimValues(p.Config.Source))
|
||||||
|
args := []string{}
|
||||||
|
if len(files.Ignore) > 0 {
|
||||||
|
for _, v := range files.Ignore {
|
||||||
|
args = append(args, "--exclude")
|
||||||
|
args = append(args, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Config.TarDereference {
|
||||||
|
args = append(args, "--dereference")
|
||||||
|
}
|
||||||
|
|
||||||
|
args = append(args, "-zcf")
|
||||||
|
args = append(args, getRealPath(src))
|
||||||
|
args = append(args, files.Source...)
|
||||||
|
|
||||||
|
return args
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Plugin) buildUnTarArgs(target string) []string {
|
||||||
args := []string{}
|
args := []string{}
|
||||||
|
|
||||||
args = append(args,
|
args = append(args,
|
||||||
p.Config.TarExec,
|
p.Config.TarExec,
|
||||||
"-xf",
|
"-zxf",
|
||||||
p.DestFile,
|
p.DestFile,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -240,32 +242,28 @@ func (p *Plugin) buildArgs(target string) []string {
|
|||||||
|
|
||||||
// Exec executes the plugin.
|
// Exec executes the plugin.
|
||||||
func (p *Plugin) Exec() error {
|
func (p *Plugin) Exec() error {
|
||||||
if len(p.Config.Host) == 0 {
|
|
||||||
return errMissingHost
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(p.Config.Key) == 0 && len(p.Config.Password) == 0 && len(p.Config.KeyPath) == 0 {
|
if len(p.Config.Key) == 0 && len(p.Config.Password) == 0 && len(p.Config.KeyPath) == 0 {
|
||||||
return errMissingPasswordOrKey
|
return errMissingPasswordOrKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(p.Config.Key) != 0 && len(p.Config.Password) != 0 {
|
|
||||||
return errSetPasswordandKey
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(p.Config.Source) == 0 || len(p.Config.Target) == 0 {
|
if len(p.Config.Source) == 0 || len(p.Config.Target) == 0 {
|
||||||
return errMissingSourceOrTarget
|
return errMissingSourceOrTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
files := globList(trimPath(p.Config.Source))
|
hosts := trimValues(p.Config.Host)
|
||||||
p.DestFile = fmt.Sprintf("%s.tar", random.String(10))
|
if len(hosts) == 0 {
|
||||||
|
return errMissingHost
|
||||||
|
}
|
||||||
|
|
||||||
|
p.DestFile = fmt.Sprintf("%s.tar.gz", random.String(10))
|
||||||
|
|
||||||
// create a temporary file for the archive
|
// create a temporary file for the archive
|
||||||
dir := os.TempDir()
|
dir := os.TempDir()
|
||||||
tar := filepath.Join(dir, p.DestFile)
|
src := filepath.Join(dir, p.DestFile)
|
||||||
|
|
||||||
// run archive command
|
// run archive command
|
||||||
fmt.Println("tar all files into " + tar)
|
fmt.Println("tar all files into " + src)
|
||||||
args := buildArgs(tar, files)
|
args := p.buildTarArgs(src)
|
||||||
cmd := exec.Command(p.Config.TarExec, args...)
|
cmd := exec.Command(p.Config.TarExec, args...)
|
||||||
if p.Config.Debug {
|
if p.Config.Debug {
|
||||||
fmt.Println("$", strings.Join(cmd.Args, " "))
|
fmt.Println("$", strings.Join(cmd.Args, " "))
|
||||||
@@ -280,8 +278,9 @@ func (p *Plugin) Exec() error {
|
|||||||
wg.Add(len(p.Config.Host))
|
wg.Add(len(p.Config.Host))
|
||||||
errChannel := make(chan error)
|
errChannel := make(chan error)
|
||||||
finished := make(chan struct{})
|
finished := make(chan struct{})
|
||||||
for _, host := range p.Config.Host {
|
for _, host := range hosts {
|
||||||
go func(host string) {
|
go func(host string) {
|
||||||
|
defer wg.Done()
|
||||||
// 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,
|
||||||
@@ -310,32 +309,42 @@ func (p *Plugin) Exec() error {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, _, _, err := ssh.Run("ver", p.Config.CommandTimeout)
|
||||||
|
systemType := "unix"
|
||||||
|
if err == nil {
|
||||||
|
systemType = "windows"
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, _, err = ssh.Run("uname", p.Config.CommandTimeout)
|
||||||
|
if err == nil {
|
||||||
|
systemType = "unix"
|
||||||
|
}
|
||||||
|
|
||||||
// upload file to the tmp path
|
// upload file to the tmp path
|
||||||
p.DestFile = fmt.Sprintf("%s%s", p.Config.TarTmpPath, p.DestFile)
|
p.DestFile = fmt.Sprintf("%s%s", p.Config.TarTmpPath, p.DestFile)
|
||||||
|
|
||||||
// Call Scp method with file you want to upload to remote server.
|
// Call Scp method with file you want to upload to remote server.
|
||||||
p.log(host, "scp file to server.")
|
p.log(host, "scp file to server.")
|
||||||
err := ssh.Scp(tar, p.DestFile)
|
err = ssh.Scp(src, p.DestFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errChannel <- copyError{host, err.Error()}
|
errChannel <- copyError{host, err.Error()}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range p.Config.Target {
|
for _, target := range p.Config.Target {
|
||||||
// remove target before upload data
|
// remove target folder before upload data
|
||||||
if p.Config.Remove {
|
if p.Config.Remove {
|
||||||
p.log(host, "Remove target folder:", target)
|
p.log(host, "Remove target folder:", target)
|
||||||
|
|
||||||
_, _, _, err := ssh.Run(fmt.Sprintf("rm -rf %s", target), p.Config.CommandTimeout)
|
_, _, _, err := ssh.Run(rmcmd(systemType, target), p.Config.CommandTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errChannel <- err
|
errChannel <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mkdir path
|
|
||||||
p.log(host, "create folder", target)
|
p.log(host, "create folder", target)
|
||||||
_, errStr, _, err := ssh.Run(fmt.Sprintf("mkdir -p %s", target), p.Config.CommandTimeout)
|
_, errStr, _, err := ssh.Run(mkdircmd(systemType, target), p.Config.CommandTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errChannel <- err
|
errChannel <- err
|
||||||
return
|
return
|
||||||
@@ -348,7 +357,7 @@ func (p *Plugin) Exec() error {
|
|||||||
|
|
||||||
// untar file
|
// untar file
|
||||||
p.log(host, "untar file", p.DestFile)
|
p.log(host, "untar file", p.DestFile)
|
||||||
commamd := strings.Join(p.buildArgs(target), " ")
|
commamd := strings.Join(p.buildUnTarArgs(target), " ")
|
||||||
if p.Config.Debug {
|
if p.Config.Debug {
|
||||||
fmt.Println("$", commamd)
|
fmt.Println("$", commamd)
|
||||||
}
|
}
|
||||||
@@ -369,13 +378,11 @@ func (p *Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove tar file
|
// remove tar file
|
||||||
err = p.removeDestFile(ssh)
|
err = p.removeDestFile(systemType, ssh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errChannel <- err
|
errChannel <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Done()
|
|
||||||
}(host)
|
}(host)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,3 +413,18 @@ func (p *Plugin) Exec() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func trimValues(keys []string) []string {
|
||||||
|
var newKeys []string
|
||||||
|
|
||||||
|
for _, value := range keys {
|
||||||
|
value = strings.TrimSpace(value)
|
||||||
|
if len(value) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
newKeys = append(newKeys, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return newKeys
|
||||||
|
}
|
||||||
|
|||||||
+98
-52
@@ -51,35 +51,18 @@ func TestMissingSourceConfig(t *testing.T) {
|
|||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetPasswordAndKey(t *testing.T) {
|
|
||||||
plugin := Plugin{
|
|
||||||
Config: Config{
|
|
||||||
Host: []string{"example.com"},
|
|
||||||
Username: "ubuntu",
|
|
||||||
Port: "443",
|
|
||||||
Password: "1234",
|
|
||||||
Key: "test",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := plugin.Exec()
|
|
||||||
|
|
||||||
assert.NotNil(t, err)
|
|
||||||
assert.Equal(t, errSetPasswordandKey, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTrimElement(t *testing.T) {
|
func TestTrimElement(t *testing.T) {
|
||||||
var input, result []string
|
var input, result []string
|
||||||
|
|
||||||
input = []string{"1", " ", "3"}
|
input = []string{"1", " ", "3"}
|
||||||
result = []string{"1", "3"}
|
result = []string{"1", "3"}
|
||||||
|
|
||||||
assert.Equal(t, result, trimPath(input))
|
assert.Equal(t, result, trimValues(input))
|
||||||
|
|
||||||
input = []string{"1", "2"}
|
input = []string{"1", "2"}
|
||||||
result = []string{"1", "2"}
|
result = []string{"1", "2"}
|
||||||
|
|
||||||
assert.Equal(t, result, trimPath(input))
|
assert.Equal(t, result, trimValues(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSCPFileFromPublicKey(t *testing.T) {
|
func TestSCPFileFromPublicKey(t *testing.T) {
|
||||||
@@ -435,12 +418,12 @@ func TestIgnoreList(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// check file exist
|
// check file exist
|
||||||
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/c.txt")); err == nil {
|
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/c.txt")); !os.IsNotExist(err) {
|
||||||
t.Fatal("c.txt file exist")
|
t.Fatal("c.txt file exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
// check file exist
|
// check file exist
|
||||||
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/e.txt")); err == nil {
|
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/e.txt")); !os.IsNotExist(err) {
|
||||||
t.Fatal("c.txt file exist")
|
t.Fatal("c.txt file exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,25 +555,6 @@ func TestGlobList(t *testing.T) {
|
|||||||
assert.Equal(t, expectIgnores, result.Ignore)
|
assert.Equal(t, expectIgnores, result.Ignore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildArgs(t *testing.T) {
|
|
||||||
list := fileList{
|
|
||||||
Source: []string{"tests/a.txt", "tests/b.txt", "tests/c.txt"},
|
|
||||||
Ignore: []string{"tests/a.txt", "tests/b.txt"},
|
|
||||||
}
|
|
||||||
|
|
||||||
result := buildArgs("test.tar.gz", list)
|
|
||||||
expects := []string{"--exclude", "tests/a.txt", "--exclude", "tests/b.txt", "-cf", "test.tar.gz", "tests/a.txt", "tests/b.txt", "tests/c.txt"}
|
|
||||||
assert.Equal(t, expects, result)
|
|
||||||
|
|
||||||
list = fileList{
|
|
||||||
Source: []string{"tests/a.txt", "tests/b.txt"},
|
|
||||||
}
|
|
||||||
|
|
||||||
result = buildArgs("test.tar.gz", list)
|
|
||||||
expects = []string{"-cf", "test.tar.gz", "tests/a.txt", "tests/b.txt"}
|
|
||||||
assert.Equal(t, expects, result)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRemoveDestFile(t *testing.T) {
|
func TestRemoveDestFile(t *testing.T) {
|
||||||
ssh := &easyssh.MakeConfig{
|
ssh := &easyssh.MakeConfig{
|
||||||
Server: "localhost",
|
Server: "localhost",
|
||||||
@@ -607,18 +571,29 @@ func TestRemoveDestFile(t *testing.T) {
|
|||||||
DestFile: "/etc/resolv.conf",
|
DestFile: "/etc/resolv.conf",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, _, _, err := ssh.Run("ver", plugin.Config.CommandTimeout)
|
||||||
|
systemType := "unix"
|
||||||
|
if err == nil {
|
||||||
|
systemType = "windows"
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, _, err = ssh.Run("uname", plugin.Config.CommandTimeout)
|
||||||
|
if err == nil {
|
||||||
|
systemType = "unix"
|
||||||
|
}
|
||||||
|
|
||||||
// ssh io timeout
|
// ssh io timeout
|
||||||
err := plugin.removeDestFile(ssh)
|
err = plugin.removeDestFile(systemType, ssh)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
ssh.Timeout = 0
|
ssh.Timeout = 0
|
||||||
|
|
||||||
// permission denied
|
// permission denied
|
||||||
err = plugin.removeDestFile(ssh)
|
err = plugin.removeDestFile(systemType, ssh)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPlugin_buildArgs(t *testing.T) {
|
func TestPlugin_buildUnTarArgs(t *testing.T) {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
Repo Repo
|
Repo Repo
|
||||||
Build Build
|
Build Build
|
||||||
@@ -642,12 +617,12 @@ func TestPlugin_buildArgs(t *testing.T) {
|
|||||||
UnlinkFirst: false,
|
UnlinkFirst: false,
|
||||||
TarExec: "tar",
|
TarExec: "tar",
|
||||||
},
|
},
|
||||||
DestFile: "foo.tar",
|
DestFile: "foo.tar.gz",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
target: "foo",
|
target: "foo",
|
||||||
},
|
},
|
||||||
want: []string{"tar", "-xf", "foo.tar", "-C", "foo"},
|
want: []string{"tar", "-zxf", "foo.tar.gz", "-C", "foo"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "strip components",
|
name: "strip components",
|
||||||
@@ -658,12 +633,12 @@ func TestPlugin_buildArgs(t *testing.T) {
|
|||||||
TarExec: "tar",
|
TarExec: "tar",
|
||||||
StripComponents: 2,
|
StripComponents: 2,
|
||||||
},
|
},
|
||||||
DestFile: "foo.tar",
|
DestFile: "foo.tar.gz",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
target: "foo",
|
target: "foo",
|
||||||
},
|
},
|
||||||
want: []string{"tar", "-xf", "foo.tar", "--strip-components", "2", "-C", "foo"},
|
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "-C", "foo"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "overwrite",
|
name: "overwrite",
|
||||||
@@ -674,12 +649,12 @@ func TestPlugin_buildArgs(t *testing.T) {
|
|||||||
Overwrite: true,
|
Overwrite: true,
|
||||||
UnlinkFirst: false,
|
UnlinkFirst: false,
|
||||||
},
|
},
|
||||||
DestFile: "foo.tar",
|
DestFile: "foo.tar.gz",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
target: "foo",
|
target: "foo",
|
||||||
},
|
},
|
||||||
want: []string{"tar", "-xf", "foo.tar", "--strip-components", "2", "--overwrite", "-C", "foo"},
|
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "-C", "foo"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unlink first",
|
name: "unlink first",
|
||||||
@@ -690,12 +665,12 @@ func TestPlugin_buildArgs(t *testing.T) {
|
|||||||
Overwrite: true,
|
Overwrite: true,
|
||||||
UnlinkFirst: true,
|
UnlinkFirst: true,
|
||||||
},
|
},
|
||||||
DestFile: "foo.tar",
|
DestFile: "foo.tar.gz",
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
target: "foo",
|
target: "foo",
|
||||||
},
|
},
|
||||||
want: []string{"tar", "-xf", "foo.tar", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "foo"},
|
want: []string{"tar", "-zxf", "foo.tar.gz", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "foo"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@@ -706,9 +681,80 @@ func TestPlugin_buildArgs(t *testing.T) {
|
|||||||
Config: tt.fields.Config,
|
Config: tt.fields.Config,
|
||||||
DestFile: tt.fields.DestFile,
|
DestFile: tt.fields.DestFile,
|
||||||
}
|
}
|
||||||
if got := p.buildArgs(tt.args.target); !reflect.DeepEqual(got, tt.want) {
|
if got := p.buildUnTarArgs(tt.args.target); !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("Plugin.buildArgs() = %v, want %v", got, tt.want)
|
t.Errorf("Plugin.buildArgs() = %v, want %v", got, tt.want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPlugin_buildTarArgs(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Config Config
|
||||||
|
}
|
||||||
|
type args struct {
|
||||||
|
src string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
args args
|
||||||
|
want []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "default command",
|
||||||
|
fields: fields{
|
||||||
|
Config: Config{
|
||||||
|
TarExec: "tar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
src: "foo.tar.gz",
|
||||||
|
},
|
||||||
|
want: []string{"-zcf", "foo.tar.gz"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ignore list",
|
||||||
|
fields: fields{
|
||||||
|
Config: Config{
|
||||||
|
TarExec: "tar",
|
||||||
|
Source: []string{
|
||||||
|
"tests/*.txt",
|
||||||
|
"!tests/a.txt",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
src: "foo.tar.gz",
|
||||||
|
},
|
||||||
|
want: []string{"--exclude", "tests/a.txt", "-zcf", "foo.tar.gz", "tests/a.txt", "tests/b.txt"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "dereference flag",
|
||||||
|
fields: fields{
|
||||||
|
Config: Config{
|
||||||
|
TarExec: "tar",
|
||||||
|
TarDereference: true,
|
||||||
|
Source: []string{
|
||||||
|
"tests/*.txt",
|
||||||
|
"!tests/a.txt",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
src: "foo.tar.gz",
|
||||||
|
},
|
||||||
|
want: []string{"--exclude", "tests/a.txt", "--dereference", "-zcf", "foo.tar.gz", "tests/a.txt", "tests/b.txt"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
p := &Plugin{
|
||||||
|
Config: tt.fields.Config,
|
||||||
|
}
|
||||||
|
if got := p.buildTarArgs(tt.args.src); !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("Plugin.buildTarArgs() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user