-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from VioletCranberry/refactoring
Refactor error handling and testing, optimize
- Loading branch information
Showing
22 changed files
with
1,821 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,40 @@ | ||
--- | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
|
||
release: | ||
name: release binary | ||
name: release binaries | ||
runs-on: "ubuntu-latest" | ||
strategy: | ||
matrix: | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
exclude: | ||
- goos: windows | ||
goarch: "" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
name: Checkout repository | ||
|
||
- uses: wangyoucao577/go-release-action@v1 | ||
name: Release go binaries | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
goversion: "https://go.dev/dl/go1.19.8.linux-amd64.tar.gz" | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
binary_name: "kubectl-node_ssm" | ||
build_flags: -v | ||
extra_files: LICENSE README.md | ||
sha256sum: TRUE | ||
|
||
update: | ||
needs: release | ||
name: update krew-index | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
name: Checkout repository | ||
- uses: actions/setup-go@v4 | ||
name: Setup go environment | ||
with: | ||
go-version: "1.20" | ||
- name: Install GoReleaser | ||
run: | | ||
curl -sfL https://goreleaser.com/static/run | bash | ||
- uses: rajatjindal/krew-release-bot@v0.0.46 | ||
name: Update new version in krew-index | ||
- name: Build libraries | ||
run: | | ||
./build.sh | ||
- name: Upload release assets | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
LATEST_RELEASE_TAG: ${{ env.LATEST_RELEASE_TAG }} | ||
run: | | ||
gh release upload "$LATEST_RELEASE_TAG" \ | ||
./dist/kubectl-node_ssm-"$LATEST_RELEASE_TAG"-*.tar.gz | ||
gh release upload "$LATEST_RELEASE_TAG" \ | ||
./dist/kubectl-node_ssm-"$LATEST_RELEASE_TAG"-*.zip | ||
gh release upload "$LATEST_RELEASE_TAG" \ | ||
./dist/kubectl-node_ssm-"$LATEST_RELEASE_TAG"-*.sha256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
kubectl-node_ssm | ||
.DS_Store | ||
.idea | ||
.idea | ||
dist/ | ||
kubectl-node_ssm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: 1 | ||
project_name: kubectl-node_ssm | ||
dist: ./dist | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
|
||
archives: | ||
- format: tar.gz | ||
name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}" | ||
files: | ||
- LICENSE | ||
- README.md | ||
format_overrides: | ||
- goos: windows | ||
format: zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
checksum_command="" | ||
# common on macOS | ||
if command -v shasum >/dev/null 2>&1; then | ||
checksum_command="shasum -a 256" | ||
# common on Linux | ||
elif command -v sha256sum >/dev/null 2>&1; then | ||
checksum_command="sha256sum" | ||
fi | ||
|
||
goreleaser release --timeout=1m --auto-snapshot --fail-fast --clean --skip=publish | ||
cd dist || exit 1 | ||
|
||
for archive in *.tar.gz *.zip; do | ||
if [ -f "$archive" ]; then | ||
$checksum_command "$archive" > "$archive.sha256" | ||
fi | ||
done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
) | ||
|
||
type cliOptions struct { | ||
flags *genericclioptions.ConfigFlags | ||
genericclioptions.IOStreams | ||
} | ||
|
||
func newCliOptions(streams genericclioptions.IOStreams) *cliOptions { | ||
return &cliOptions{ | ||
flags: genericclioptions.NewConfigFlags(true), | ||
IOStreams: streams, | ||
} | ||
} | ||
|
||
func NewRootCmd(streams genericclioptions.IOStreams) *cobra.Command { | ||
var target string | ||
var params []string | ||
cliOptions := newCliOptions(streams) | ||
|
||
rootCmd := &cobra.Command{Use: "node-ssm", SilenceUsage: true} | ||
rootCmd.PersistentFlags().StringVar(&target, "target", "", "EKS node name (private-dns-name)") | ||
_ = rootCmd.MarkPersistentFlagRequired("target") | ||
|
||
rootCmd.PersistentFlags().StringSliceVar(¶ms, "session-params", | ||
[]string{}, "SSM session parameters") | ||
|
||
cliOptions.flags.AddFlags(rootCmd.Flags()) | ||
rootCmd.AddCommand(newStartSessionCmd(cliOptions, &target, ¶ms)) | ||
|
||
return rootCmd | ||
} |
Oops, something went wrong.