Skip to content

Commit

Permalink
Merge pull request #17 from homedepot/update-go-1-21
Browse files Browse the repository at this point in the history
Update to Go 1.21
  • Loading branch information
ryanjohnsontv authored Jan 9, 2024
2 parents b033c46 + dcdd624 commit 542924f
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 547 deletions.
34 changes: 16 additions & 18 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@ name: Go
on:
workflow_dispatch:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.21
id: go

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Get dependencies
run: ./get-dependencies.sh
- name: Get dependencies
run: make setup

- name: Build
run: ./build.sh -v
- name: Test
run: make test

- name: Test
run: go test -v ./...
- name: Build
run: make build

golangci:
name: Lint
Expand All @@ -41,6 +39,6 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.40
version: v1.55

args: --skip-files .*_test.go --enable wsl --enable misspell --timeout 180s
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ on:
version:
type: string
description: version to tag image

jobs:
release:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.event.inputs.version }}
steps:
- name: Setup - checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.13
go-version: ^1.21
id: go

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: docker
shell: bash
shell: bash
run: docker/docker-build.sh -v ${VERSION}
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: build test setup lint

build:
CGO_ENABLED=0 go build -o arcade cmd/arcade/arcade.go

test:
go test ./...

setup:
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then \
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
dep ensure; \
fi; \
go mod tidy; \
go mod verify; \

lint:
golangci-lint run --skip-files .*_test.go --enable wsl --enable misspell --timeout 180s
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Using google's [Workload Identity](https://cloud.google.com/kubernetes-engine/do

```json5
{
"type": "", // Required, set to 'google'
"name": "" // Required, set to a unique name identifying this token provider
type: "", // Required, set to 'google'
name: "", // Required, set to a unique name identifying this token provider
}
```

Expand All @@ -29,12 +29,12 @@ Use this JSON structure to configure a Microsoft token provider

```json5
{
"type": "", // Required, set to 'microsoft'
"name": "", // Required, set to a unique name identifying this token provider
"loginEndpoint": "", // Reqoured, set to the 'login' endpoint, such as https://login.microsoftonline.com/someone.onmicrosoft.com/oauth2/token
"clientId": "", // Required, set to your Microsoft Client ID
"clientSecret": "", // Required, set to your Microsoft Client Secret
"resource": "" // Optional, set to the resource you are requesting, such as 'https://graph.microsoft.com'
type: "", // Required, set to 'microsoft'
name: "", // Required, set to a unique name identifying this token provider
loginEndpoint: "", // Reqoured, set to the 'login' endpoint, such as https://login.microsoftonline.com/someone.onmicrosoft.com/oauth2/token
clientId: "", // Required, set to your Microsoft Client ID
clientSecret: "", // Required, set to your Microsoft Client Secret
resource: "", // Optional, set to the resource you are requesting, such as 'https://graph.microsoft.com'
}
```

Expand All @@ -44,12 +44,12 @@ Use this JSON structure to configure a Rancher token provider

```json5
{
"type": "", // Required, set to 'rancher'
"name": "", // Required, set to a unique name identifying this token provider
"url": "", // Reqoured, set to the 'login' endpoint of your Rancher instance
"username": "", // Required, set to your Rancher username
"password": "", // Required, set to your Rancher upassword
"rootCA": "" // Optional, set to a certificate to add to the trusted root CAs
type: "", // Required, set to 'rancher'
name: "", // Required, set to a unique name identifying this token provider
url: "", // Reqoured, set to the 'login' endpoint of your Rancher instance
username: "", // Required, set to your Rancher username
password: "", // Required, set to your Rancher upassword
rootCA: "", // Optional, set to a certificate to add to the trusted root CAs
}
```

Expand All @@ -58,6 +58,7 @@ Rancher kubeconfig tokens have an expiration time and Arcade will cache the toke
## Run Locally

Prerequisites:

- the [gcloud CLI](https://cloud.google.com/sdk/gcloud#download_and_install_the) must be installed
- you'll need [Application Default Credentials](https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login) set up and run `gcloud auth application-default login`

Expand All @@ -66,8 +67,8 @@ Run the following commands to build and generate a token.
### Build

```bash
./get-dependencies.sh
./build.sh
make setup
make build
```

### Run
Expand Down Expand Up @@ -106,18 +107,25 @@ echo '{
### Test

**Google**

```bash
curl localhost:1982/tokens?provider=google -H "Api-Key: test"
```

The default token provider is google, so this is equivalent to the call above

```bash
curl localhost:1982/tokens -H "Api-Key: test"
```

**Microsoft**

```bash
curl localhost:1982/tokens?provider=microsoftonline -H "Api-Key: test"
```

**Rancher**

```bash
curl localhost:1982/tokens?provider=rancher.example.com -H "Api-Key: test"
```
5 changes: 0 additions & 5 deletions build.sh

This file was deleted.

1 change: 1 addition & 0 deletions cmd/arcade/arcade.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func mustGetenv(env string) (s string) {
// Run arcade on port 1982.
func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.Lshortfile)

if err := r.Run(":1982"); err != nil {
log.Fatal(err)
}
Expand Down
10 changes: 5 additions & 5 deletions docker/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

set -o errexit


# Builds the base image including the solver dependencies
build_and_publish_image(){
build_and_publish_image() {
export PATH=.:$PATH
get-dependencies.sh >/dev/null
GOOS=linux GOARCH=amd64 build.sh
make setup >/dev/null
GOOS=linux GOARCH=amd64 make build
GCR_TAG="oshomedepot/arcade:${TAG_VERSION}"
docker build . -f docker/Dockerfile -t ${GCR_TAG}
echo "Image ${GCR_TAG} built..."
docker push ${GCR_TAG}
}

print_help(){
print_help() {
echo ""
echo "docker/build.sh -v [VERSION] - Builds the docker image"
echo ""
Expand Down Expand Up @@ -44,7 +45,6 @@ while [[ $# -gt 0 ]]; do
exit 0
;;
--help)
shift
print_help
exit 0
;;
Expand Down
9 changes: 0 additions & 9 deletions get-dependencies.sh

This file was deleted.

46 changes: 41 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
module github.com/homedepot/arcade

go 1.14
go 1.21

require (
github.com/gin-gonic/gin v1.6.3
github.com/onsi/ginkgo v1.15.0
github.com/onsi/gomega v1.10.5
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
github.com/gin-gonic/gin v1.9.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.30.0
golang.org/x/oauth2 v0.15.0
)

require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/bytedance/sonic v1.10.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.16.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.6.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 542924f

Please sign in to comment.