Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(go): Update to Go 1.18 & remove Kaniko Dependencies #20

Merged
merged 8 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
prerelease:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
publish:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
release:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
diff-review:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand All @@ -27,7 +27,7 @@ jobs:
full-review:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
unit-test:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand All @@ -36,15 +36,21 @@ jobs:
uses: actions/checkout@v3

- name: build for integration test
run: make build
uses: docker://golang:1.18
with:
entrypoint: make
args: build-static-ci
env:
GOOS: linux
CGO_ENABLED: '0'

- name: integration test with fake server
run: make docker-build && make docker-test

gha-publish-test:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
validate:
runs-on: ubuntu-latest
container:
image: golang:1.17
image: golang:1.18
steps:
- name: clone
uses: actions/checkout@v3
Expand Down
23 changes: 4 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#
# Use of this source code is governed by the LICENSE file in this repository.

# capture the current date we build the application from
BUILD_DATE = $(shell date +%Y-%m-%dT%H:%M:%SZ)

# Versions installed for OpenSSH and SSHPass binaries.
# This is the ONLY place these hardcoded versions are set.
# They're used in the Dockerfile the GitHub Actions workflow,
Expand All @@ -15,29 +12,17 @@ OPENSSH_VERSION=8.8_p1-r1
# renovate: datasource=repology depName=alpine_3_15/sshpass versioning=loose
SSHPASS_VERSION=1.09-r0

# check if a git commit sha is already set
ifndef GITHUB_SHA
# capture the current git commit sha we build the application from
GITHUB_SHA = $(shell git rev-parse HEAD)
endif

# check if a git tag is already set
ifndef GITHUB_TAG
# capture the current git tag we build the application from
GITHUB_TAG = $(shell git describe --tag --abbrev=0)
endif

# check if a go version is already set
ifndef GOLANG_VERSION
# capture the current go version we build the application from
GOLANG_VERSION = $(shell go version | awk '{ print $$3 }')
endif

# create a list of linker flags for building the golang application
# The reference here to Kaniko is so that this repo doesn't need to duplicate
# the version.go file across multiple plugin repositories. Ideally that file would
# migrate into its own repository at some point so that it can be widely used.
LD_FLAGS = -X github.com/go-vela/vela-openssh/internal/openssh.OpenSSHVersion=${OPENSSH_VERSION} -X github.com/go-vela/vela-openssh/internal/openssh.SSHPassVersion=${SSHPASS_VERSION} -X github.com/go-vela/vela-kaniko/version.Commit=${GITHUB_SHA} -X github.com/go-vela/vela-kaniko/version.Date=${BUILD_DATE} -X github.com/go-vela/vela-kaniko/version.Go=${GOLANG_VERSION} -X github.com/go-vela/vela-kaniko/version.Tag=${GITHUB_TAG}
LD_FLAGS = \
-X github.com/go-vela/vela-openssh/internal/openssh.OpenSSHVersion=${OPENSSH_VERSION} \
-X github.com/go-vela/vela-openssh/internal/openssh.SSHPassVersion=${SSHPASS_VERSION} \
-X github.com/go-vela/vela-openssh/internal/openssh.PluginVersion=${GITHUB_TAG}

# The `clean` target is intended to clean the workspace
# and prepare the local changes for submission.
Expand Down
10 changes: 7 additions & 3 deletions cmd/vela-scp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
// The version field looks gross but in practice is really only seen and used in integration tests
// or when a plugin is misconfigured. We should log the version information of dependent binaries
// to assist with debugging why a plugin might be failing to operate in a way users expect.
Version: fmt.Sprintf("Plugin: %s - OpenSSH: %s - SSHPass: %s", openssh.PluginVersion.Semantic(), openssh.OpenSSHVersion, openssh.SSHPassVersion),
Version: fmt.Sprintf("Plugin: %s - OpenSSH: %s - SSHPass: %s", openssh.PluginVersion, openssh.OpenSSHVersion, openssh.SSHPassVersion),
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "source",
Expand Down Expand Up @@ -110,12 +110,16 @@ func run(c *cli.Context) error {
})
}

if openssh.DirtyBuild {
logrus.Warnf("binary built from modified commit %s", openssh.GitCommit)
}

logrus.WithFields(logrus.Fields{
"code": "https://github.com/go-vela/vela-openssh",
"docs": "https://go-vela.github.io/docs/plugins/registry/scp",
"registry": "https://hub.docker.com/r/target/vela-scp",
"commit": openssh.PluginVersion.Metadata.GitCommit,
"version-plugin": openssh.PluginVersion.Semantic(),
"commit": openssh.GitCommit,
"version-plugin": openssh.PluginVersion,
"version-openssh": openssh.OpenSSHVersion,
"version-sshpass": openssh.SSHPassVersion,
}).Info("Vela SCP Plugin")
Expand Down
10 changes: 7 additions & 3 deletions cmd/vela-ssh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
// The version field looks gross but in practice is really only seen and used in integration tests
// or when a plugin is misconfigured. We should log the version information of dependent binaries
// to assist with debugging why a plugin might be failing to operate in a way users expect.
Version: fmt.Sprintf("Plugin: %s - OpenSSH: %s - SSHPass: %s", openssh.PluginVersion.Semantic(), openssh.OpenSSHVersion, openssh.SSHPassVersion),
Version: fmt.Sprintf("Plugin: %s - OpenSSH: %s - SSHPass: %s", openssh.PluginVersion, openssh.OpenSSHVersion, openssh.SSHPassVersion),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "destination",
Expand Down Expand Up @@ -110,12 +110,16 @@ func run(c *cli.Context) error {
})
}

if openssh.DirtyBuild {
logrus.Warnf("binary built from modified commit %s", openssh.GitCommit)
}

logrus.WithFields(logrus.Fields{
"code": "https://github.com/go-vela/vela-openssh",
"docs": "https://go-vela.github.io/docs/plugins/registry/ssh",
"registry": "https://hub.docker.com/r/target/vela-ssh",
"commit": openssh.PluginVersion.Metadata.GitCommit,
"version-plugin": openssh.PluginVersion.Semantic(),
"commit": openssh.GitCommit,
"version-plugin": openssh.PluginVersion,
"version-openssh": openssh.OpenSSHVersion,
"version-sshpass": openssh.SSHPassVersion,
}).Info("Vela SSH Plugin")
Expand Down
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
module github.com/go-vela/vela-openssh

go 1.17
go 1.18

require (
github.com/go-vela/vela-kaniko v0.8.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/afero v1.8.2
github.com/urfave/cli/v2 v2.4.0
)

require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/go-vela/types v0.11.1-0.20211209165039-76b75a4cd961 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
golang.org/x/text v0.3.7 // indirect
)
Loading