Compare commits

...

4 Commits

Author SHA1 Message Date
renovate[bot]
61555d8ee2 chore(deps): update dependency go to v1.23.1 (#1148)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-24 15:19:54 +09:00
Hidetake Iwata
f22f6ee483 Update go directive in go.mod (#1147) 2024-09-24 15:11:20 +09:00
Hidetake Iwata
c2cbc47438 Lock dedicated file instead of token cache file (#1146)
* Run test on Windows

* Run integration_test on Windows and macOS

* Lock dedicated file instead of token cache file

* Add comment
2024-09-24 14:39:53 +09:00
Hidetake Iwata
765d97542c Use go-version-file (#1142) 2024-09-23 18:06:11 +09:00
7 changed files with 50 additions and 21 deletions

View File

@@ -2,9 +2,10 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>int128/renovate-base",
"github>int128/go-renovate-config",
"github>int128/go-renovate-config:github-actions",
"github>int128/go-renovate-config:kubernetes",
"github>int128/go-renovate-config:kustomization-github-releases",
"github>int128/go-renovate-config#v1.6.0",
"github>int128/go-renovate-config:go-directive#v1.6.0",
"github>int128/go-renovate-config:github-actions#v1.6.0",
"github>int128/go-renovate-config:kubernetes#v1.6.0",
"github>int128/go-renovate-config:kustomization-github-releases#v1.6.0",
],
}

View File

@@ -7,6 +7,8 @@ on:
paths:
- .github/workflows/go.yaml
- pkg/**
- integration_test/**
- mocks/**
- tools/**
- go.*
tags:
@@ -17,14 +19,17 @@ on:
paths:
- .github/workflows/go.yaml
- pkg/**
- integration_test/**
- mocks/**
- tools/**
- go.*
jobs:
check:
uses: int128/go-workflows/.github/workflows/check.yaml@v0.3.0
uses: int128/go-workflows/.github/workflows/check.yaml@v0.4.0
with:
go-version: 1.23.1
go-version-file: go.mod
cache-dependency-path: go.sum
golangci-lint-version: v1.61.0
test:
@@ -34,8 +39,27 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.1
- run: go test -v -race ./...
go-version-file: go.mod
cache-dependency-path: go.sum
- run: go test -v -race ./pkg/...
integration-test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- run: go test -v -race ./integration_test/...
generate:
runs-on: ubuntu-latest

View File

@@ -57,7 +57,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.1
go-version-file: go.mod
cache-dependency-path: go.sum
- run: go build -ldflags '-X main.version=${{ github.ref_name }}'
- uses: int128/go-release-action@v2
with:

View File

@@ -25,7 +25,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.1
go-version-file: go.mod
cache-dependency-path: go.sum
# for certutil
# https://packages.ubuntu.com/xenial/libnss3-tools

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/int128/kubelogin
go 1.22.2
go 1.23.1
require (
github.com/chromedp/chromedp v0.10.0

View File

@@ -83,20 +83,22 @@ func (r *Repository) Save(dir string, key tokencache.Key, tokenSet oidc.TokenSet
return nil
}
func (r *Repository) Lock(dir string, key tokencache.Key) (io.Closer, error) {
if err := os.MkdirAll(dir, 0700); err != nil {
return nil, fmt.Errorf("could not create directory %s: %w", dir, err)
func (r *Repository) Lock(tokenCacheDir string, key tokencache.Key) (io.Closer, error) {
if err := os.MkdirAll(tokenCacheDir, 0700); err != nil {
return nil, fmt.Errorf("could not create directory %s: %w", tokenCacheDir, err)
}
filename, err := computeFilename(key)
keyDigest, err := computeFilename(key)
if err != nil {
return nil, fmt.Errorf("could not compute the key: %w", err)
}
p := filepath.Join(dir, filename)
f := flock.New(p)
if err := f.Lock(); err != nil {
return nil, fmt.Errorf("could not lock the cache file %s: %w", p, err)
// Do not lock the token cache file.
// https://github.com/int128/kubelogin/issues/1144
lockFilepath := filepath.Join(tokenCacheDir, keyDigest+".lock")
lockFile := flock.New(lockFilepath)
if err := lockFile.Lock(); err != nil {
return nil, fmt.Errorf("could not lock the cache file %s: %w", lockFilepath, err)
}
return f, nil
return lockFile, nil
}
func computeFilename(key tokencache.Key) (string, error) {

View File

@@ -1,6 +1,6 @@
module github.com/int128/kubelogin/tools
go 1.22.5
go 1.23.1
require (
github.com/google/wire v0.6.0