Skip to content

Commit 9d499b7

Browse files
committed
fix: address linters
fix: add custom binary
1 parent 225fe72 commit 9d499b7

File tree

19 files changed

+208
-129
lines changed

19 files changed

+208
-129
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,47 +27,45 @@ jobs:
2727
- name: Set SemVer Version
2828
uses: gittools/actions/gitversion/execute@v1
2929
id: gitversion
30+
3031
pr:
3132
runs-on: ubuntu-latest
32-
container:
33-
image: golang:1.24-bookworm
3433
needs: set-version
3534
env:
3635
REVISION: $GITHUB_SHA
3736
SEMVER: ${{ needs.set-version.outputs.semVer }}
3837
steps:
3938
- uses: actions/checkout@v4
40-
- name: install deps
39+
40+
- uses: ensono/actions/[email protected]
41+
with:
42+
version: latest
43+
isPrerelease: false
44+
45+
- name: prep-git
4146
run: |
42-
# Chromium dependencies
43-
apt-get update && apt-get install -y jq git \
44-
zip unzip \
45-
libnss3 \
46-
libxss1 \
47-
libasound2 \
48-
libxtst6 \
49-
libgtk-3-0 \
50-
libgbm1 \
51-
ca-certificates
5247
git config --global --add safe.directory "$GITHUB_WORKSPACE"
5348
git config user.email ${{ github.actor }}[email protected]
5449
git config user.name ${{ github.actor }}
55-
- name: make test
50+
- name: Run linters
5651
run: |
57-
make REVISION=$GITHUB_SHA test
52+
eirctl run vuln:check
53+
- name: Unit Tests
54+
run: |
55+
eirctl run test:unit
56+
5857
- name: Publish Junit style Test Report
5958
uses: mikepenz/action-junit-report@v3
6059
if: always() # always run even if the previous step fails
6160
with:
6261
report_paths: '**/report-junit.xml'
63-
- name: Analyze with SonarCloud
64-
# You can pin the exact commit or the version.
65-
uses: SonarSource/sonarcloud-github-action@master
62+
63+
- name: Analyze with SonarCloud
64+
uses: SonarSource/sonarqube-scan-action@v5
6665
env:
6766
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
6867
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
6968
with:
70-
args:
69+
projectBaseDir: .
70+
args: >
7171
-Dsonar.projectVersion=${{ needs.set-version.outputs.semVer }}
72-
-Dsonar.go.coverage.reportPaths=/github/workspace/.coverage/out
73-
-Dsonar.go.tests.reportPaths=/github/workspace/.coverage/report-junit.xml

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
- name: release binary
6565
run: |
6666
make REVISION=$GITHUB_SHA GIT_TAG=${SEMVER} PAT=${{ secrets.GITHUB_TOKEN }} cross-build
67+
6768
- name: Release
6869
uses: softprops/[email protected]
6970
with:
@@ -72,4 +73,4 @@ jobs:
7273
generate_release_notes: true
7374
token: ${{ secrets.GITHUB_TOKEN }}
7475
files: ./dist/*
75-
prerelease: false
76+
prerelease: true

aws-cli-auth.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ import (
1313
func main() {
1414
ctx, stop := signal.NotifyContext(context.Background(), []os.Signal{os.Interrupt, syscall.SIGTERM, os.Kill}...)
1515
defer stop()
16+
17+
go func() {
18+
<-ctx.Done()
19+
stop()
20+
log.Printf("\x1b[31minterrupted: %s\x1b[0m", ctx.Err())
21+
os.Exit(0)
22+
}()
23+
1624
c := cmd.New()
1725
c.WithSubCommands(cmd.SubCommands()...)
26+
1827
if err := c.Execute(ctx); err != nil {
19-
log.Fatalf("\x1b[31maws-cli-auth err:\n%s\x1b[0m", err)
28+
log.Fatalf("\x1b[31m%s\x1b[0m", err)
2029
}
2130
}

cmd/awscliauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Stores them under the $HOME/.aws/credentials file under a specified path or retu
5959
r.Cmd.PersistentFlags().IntVarP(&rf.duration, "max-duration", "d", 900, `Override default max session duration, in seconds, of the role session [900-43200].
6060
NB: This cannot be higher than the 3600 as the API does not allow for AssumeRole for sessions longer than an hour`)
6161
r.Cmd.PersistentFlags().BoolVarP(&rf.verbose, "verbose", "v", false, "Verbose output")
62-
r.dataDirInit()
62+
_ = r.dataDirInit()
6363
return r
6464
}
6565

cmd/clear.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os/user"
77

88
"github.com/DevLabFoundry/aws-cli-auth/internal/credentialexchange"
9-
"github.com/DevLabFoundry/aws-cli-auth/internal/web"
109
"github.com/spf13/cobra"
1110
)
1211

@@ -21,8 +20,7 @@ func newClearCmd(r *Root) {
2120
Use: "clear-cache <flags>",
2221
Short: "Clears any stored credentials in the OS secret store",
2322
Long: `Clears any stored credentials in the OS secret store
24-
25-
NB: Occassionally you may encounter a hanging chromium processes if not using own browser binary, you should kill all the instances of the chromium PIDs`,
23+
NB: Occassionally you may encounter a hanging chromium processes, you should kill all the instances of the chromium (or if using own browser binary) PIDs`,
2624
RunE: func(cmd *cobra.Command, args []string) error {
2725
user, err := user.Current()
2826
if err != nil {
@@ -40,11 +38,7 @@ NB: Occassionally you may encounter a hanging chromium processes if not using ow
4038
}
4139

4240
if flags.force {
43-
w := &web.Web{}
44-
if err := w.ForceKill(r.Datadir); err != nil {
45-
return err
46-
}
47-
fmt.Fprint(os.Stderr, "Chromium Cache cleared")
41+
fmt.Fprint(os.Stderr, "delete ~/.aws-cli-auth-data/ manually")
4842
}
4943

5044
if err := secretStore.ClearAll(); err != nil {

cmd/saml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func newSamlCmd(r *Root) {
133133
sc.cmd.PersistentFlags().StringVarP(&flags.providerUrl, "provider", "p", "", `Saml Entity StartSSO Url.
134134
This is the URL your Idp will make the first call to e.g.: https://company-xyz.okta.com/home/amazon_aws/12345SomeRandonId6789
135135
`)
136-
sc.cmd.MarkPersistentFlagRequired("provider")
136+
_ = sc.cmd.MarkPersistentFlagRequired("provider")
137137
sc.cmd.PersistentFlags().StringVarP(&flags.principalArn, "principal", "", "", `Principal Arn of the SAML IdP in AWS
138138
You should find it in the IAM portal e.g.: arn:aws:iam::1234567891012:saml-provider/MyCompany-Idp
139139
`)

cmd/specific.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ Returns the same JSON object as the call to the AWS CLI for any of the sts Assum
7575

7676
cmd.PersistentFlags().StringVarP(&flags.method, "method", "m", "WEB_ID", "Runs a specific credentialProvider as opposed to relying on the default chain provider fallback")
7777
cmd.PersistentFlags().StringVarP(&flags.role, "role", "r", "", `Set the role you want to assume when SAML or OIDC process completes`)
78-
cmd.MarkPersistentFlagRequired("role")
78+
_ = cmd.MarkPersistentFlagRequired("role")
7979
r.Cmd.AddCommand(cmd)
8080
}

eirctl.yaml

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import:
2-
- https://raw.githubusercontent.com/Ensono/eirctl/refs/heads/main/shared/build/go/eirctl.yaml
2+
- https://raw.githubusercontent.com/Ensono/eirctl/e71dd9d66293e27e70fd0620e63a6d627579c060/shared/build/go/eirctl.yaml
33

44
contexts:
55
unit:test:
@@ -13,14 +13,29 @@ contexts:
1313
exclude:
1414
- HOME
1515
- GO
16+
- TMP
1617

1718
pipelines:
1819
unit:test:run:
1920
- task: unit:test:prereqs
2021
- task: unit:test
2122
depends_on: unit:test:prereqs
2223

24+
release:
25+
- task: clean:dir
26+
- task: build
27+
depends_on: clean:dir
28+
2329
tasks:
30+
tag:
31+
command:
32+
- |
33+
git tag -a ${VERSION} -m "ci tag release" ${REVISION}
34+
git push origin ${VERSION}
35+
required:
36+
env:
37+
- VERSION
38+
- REVISION
2439
unit:test:
2540
context: unit:test
2641
description: |
@@ -41,3 +56,71 @@ tasks:
4156
go install github.com/jstemmer/[email protected]
4257
go install github.com/axw/gocov/[email protected]
4358
go install github.com/AlekSi/[email protected]
59+
60+
clean:dir:
61+
command:
62+
- |
63+
rm -rf dist/
64+
65+
build:
66+
context: go1x
67+
description: Builds Go binary
68+
command:
69+
- |
70+
mkdir -p .deps
71+
ldflags="-s -w -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd.Version={{.Version}}\" -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd.Revision={{.Revision}}\" -extldflags -static"
72+
CGO_ENABLED=0 GOPATH=$PWD/.deps GOOS=${BUILD_GOOS} go build -mod=readonly -buildvcs=false -ldflags="$ldflags" -o dist/{{.BinName}}-${BUILD_GOOS}${BUILD_GOARCH}${BINARY_SUFFIX} .
73+
variations:
74+
- BUILD_GOOS: windows
75+
BUILD_GOARCH: amd64
76+
BINARY_SUFFIX: ""
77+
- BUILD_GOOS: windows
78+
BUILD_GOARCH: "386"
79+
BINARY_SUFFIX: ""
80+
- BUILD_GOOS: darwin
81+
BUILD_GOARCH: ""
82+
BINARY_SUFFIX: ""
83+
- BUILD_GOOS: linux
84+
BUILD_GOARCH: ""
85+
BINARY_SUFFIX: ""
86+
variables:
87+
RepoOwner: DevLabFoundry
88+
BinName: aws-cli-auth
89+
90+
build:arch:
91+
context: go1x
92+
description: Builds Go binary per architecture
93+
command:
94+
- |
95+
mkdir -p .deps
96+
ldflags="-s -w -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd.Version={{.Version}}\" -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd.Revision={{.Revision}}\" -extldflags -static"
97+
CGO_ENABLED=0 GOPATH=$PWD/.deps GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} go build -mod=readonly -buildvcs=false -ldflags="$ldflags" -o dist/{{.BinName}}-${BUILD_GOOS}-${BUILD_GOARCH}${BINARY_SUFFIX} cmd/main.go
98+
variations:
99+
- BUILD_GOOS: windows
100+
BUILD_GOARCH: amd64
101+
BINARY_SUFFIX: .exe
102+
- BUILD_GOOS: windows
103+
BUILD_GOARCH: "386"
104+
BINARY_SUFFIX: .exe
105+
- BUILD_GOOS: windows
106+
BUILD_GOARCH: arm64
107+
BINARY_SUFFIX: .exe
108+
- BUILD_GOOS: darwin
109+
BUILD_GOARCH: amd64
110+
BINARY_SUFFIX: ""
111+
- BUILD_GOOS: darwin
112+
BUILD_GOARCH: arm64
113+
BINARY_SUFFIX: ""
114+
- BUILD_GOOS: linux
115+
BUILD_GOARCH: arm64
116+
BINARY_SUFFIX: ""
117+
- BUILD_GOOS: linux
118+
BUILD_GOARCH: amd64
119+
BINARY_SUFFIX: ""
120+
variables:
121+
RepoOwner: DevLabFoundry
122+
BinName: aws-cli-auth
123+
124+
build:container:
125+
description: Builds the docker image
126+
command: docker build --build-arg Version={{.Version}} --build-arg Revision={{.Revision}} -t eirctl:{{.Version}} .

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/aws/aws-sdk-go-v2/service/sts v1.38.0
99
github.com/aws/smithy-go v1.22.5
1010
github.com/go-rod/rod v0.116.2
11-
github.com/mitchellh/go-ps v1.0.0
1211
github.com/spf13/cobra v1.9.1
1312
github.com/werf/lockgate v0.1.1
1413
github.com/zalando/go-keyring v0.2.6

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
4343
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
4444
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
4545
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
46-
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
47-
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
4846
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4947
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5048
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@@ -63,8 +61,6 @@ github.com/werf/lockgate v0.1.1 h1:S400JFYjtWfE4i4LY9FA8zx0fMdfui9DPrBiTciCrx4=
6361
github.com/werf/lockgate v0.1.1/go.mod h1:0yIFSLq9ausy6ejNxF5uUBf/Ib6daMAfXuCaTMZJzIE=
6462
github.com/ysmood/fetchup v0.3.0 h1:UhYz9xnLEVn2ukSuK3KCgcznWpHMdrmbsPpllcylyu8=
6563
github.com/ysmood/fetchup v0.3.0/go.mod h1:hbysoq65PXL0NQeNzUczNYIKpwpkwFL4LXMDEvIQq9A=
66-
github.com/ysmood/fetchup v0.5.2 h1:P9w3OIA7RSNEEFvEmOiTq09IOu42C96PMyZ1MWd8TAs=
67-
github.com/ysmood/fetchup v0.5.2/go.mod h1:yCv8s8itjsCul1LGXJ1Q+8EQnZcVjfbZ4+l1zDm4StE=
6864
github.com/ysmood/goob v0.4.0 h1:HsxXhyLBeGzWXnqVKtmT9qM7EuVs/XOgkX7T6r1o1AQ=
6965
github.com/ysmood/goob v0.4.0/go.mod h1:u6yx7ZhS4Exf2MwciFr6nIM8knHQIE22lFpWHnfql18=
7066
github.com/ysmood/gop v0.2.0 h1:+tFrG0TWPxT6p9ZaZs+VY+opCvHU8/3Fk6BaNv6kqKg=

0 commit comments

Comments
 (0)