Skip to content

Commit

Permalink
Upgrade to Go 1.18+ (#38)
Browse files Browse the repository at this point in the history
We now have generics. Let's use them!
  • Loading branch information
lhchavez authored Sep 18, 2022
1 parent 2044100 commit 29a3e99
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
go:
- 1.17
- 1.19
name: Go ${{ matrix.go }}

runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19
id: go

- name: Install git2go
Expand All @@ -36,7 +36,7 @@ jobs:

- name: Bump version and push tag
id: bump-version
uses: anothrNick/github-tag-action@9885a4f9af674ba472de91fb3c0cb033ecb32b7e
uses: anothrNick/github-tag-action@43ed073f5c1445ca8b80d920ce2f8fa550ae4e8d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
Expand Down
54 changes: 27 additions & 27 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/omegaup/githttp/v2"
"github.com/omegaup/go-base/logging/log15"
"github.com/omegaup/go-base/logging/log15/v3"
"github.com/omegaup/go-base/v3/logging"

git "github.com/libgit2/git2go/v33"
Expand Down Expand Up @@ -110,15 +110,15 @@ func forcePushToBranch(remote *url.URL) error {
if err != nil {
log.Error(
"Error discovering references",
map[string]interface{}{
map[string]any{
"err": err,
},
)
return
}
log.Debug(
"Remote",
map[string]interface{}{
map[string]any{
"discovery": discovery,
},
)
Expand All @@ -136,7 +136,7 @@ func forcePushToBranch(remote *url.URL) error {
} else {
log.Error(
"Error getting descendantness",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -153,7 +153,7 @@ func forcePushToBranch(remote *url.URL) error {
)
log.Debug(
"Pushing",
map[string]interface{}{
map[string]any{
"oldOid": oldOid.String(),
"newOid": newOid.String(),
"line": line,
Expand All @@ -162,7 +162,7 @@ func forcePushToBranch(remote *url.URL) error {
if err := pw.WritePktLine([]byte(line)); err != nil {
log.Error(
"Error sending pktline",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -171,7 +171,7 @@ func forcePushToBranch(remote *url.URL) error {
if err := pw.Flush(); err != nil {
log.Error(
"Error flushing",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -189,14 +189,14 @@ func forcePushToBranch(remote *url.URL) error {
}
log.Debug(
"Inserting commit",
map[string]interface{}{
map[string]any{
"commit": current.Id(),
},
)
if err := pb.InsertCommit(current.Id()); err != nil {
log.Error(
"Error building pack",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -208,7 +208,7 @@ func forcePushToBranch(remote *url.URL) error {
if err := pb.Write(stdin); err != nil {
log.Error(
"Error writing pack",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -222,15 +222,15 @@ func forcePushToBranch(remote *url.URL) error {
} else if err != nil {
log.Error(
"Error reading remote response",
map[string]interface{}{
map[string]any{
"err": err,
},
)
break
}
log.Debug(
"Line",
map[string]interface{}{
map[string]any{
"line": string(line),
},
)
Expand All @@ -240,7 +240,7 @@ func forcePushToBranch(remote *url.URL) error {
cmd := fmt.Sprintf("git-receive-pack '%s'", remote.Path)
log.Info(
"Sending command",
map[string]interface{}{
map[string]any{
"command": cmd,
},
)
Expand All @@ -266,7 +266,7 @@ func pushToSubdirectory(remote *url.URL) error {
if err != nil {
log.Error(
"Could not create temporary directory for packfile",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand Down Expand Up @@ -336,15 +336,15 @@ func pushToSubdirectory(remote *url.URL) error {
if err != nil {
log.Error(
"Error discovering references",
map[string]interface{}{
map[string]any{
"err": err,
},
)
return
}
log.Debug(
"Remote",
map[string]interface{}{
map[string]any{
"discovery": discovery,
},
)
Expand All @@ -353,14 +353,14 @@ func pushToSubdirectory(remote *url.URL) error {
line := fmt.Sprintf("want %s\x00agent=gohttp ofs-delta shallow\n", oid.String())
log.Debug(
"Pulling",
map[string]interface{}{
map[string]any{
"line": line,
},
)
if err := pw.WritePktLine([]byte(line)); err != nil {
log.Error(
"Error sending pktline",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -369,7 +369,7 @@ func pushToSubdirectory(remote *url.URL) error {
if err := pw.WritePktLine([]byte("deepen 1")); err != nil {
log.Error(
"Error sending pktline",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -378,7 +378,7 @@ func pushToSubdirectory(remote *url.URL) error {
if err := pw.Flush(); err != nil {
log.Error(
"Error flushing",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -394,15 +394,15 @@ func pushToSubdirectory(remote *url.URL) error {
} else if err != nil {
log.Error(
"Error reading shallow negotiation",
map[string]interface{}{
map[string]any{
"err": err,
},
)
break
}
log.Debug(
"Line",
map[string]interface{}{
map[string]any{
"line": string(line),
},
)
Expand All @@ -411,7 +411,7 @@ func pushToSubdirectory(remote *url.URL) error {
if err := pw.WritePktLine([]byte("done\n")); err != nil {
log.Error(
"Error sending pktline",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -423,7 +423,7 @@ func pushToSubdirectory(remote *url.URL) error {
if err != nil {
log.Error(
"Error reading ACK/NAK response",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -440,7 +440,7 @@ func pushToSubdirectory(remote *url.URL) error {
if err != nil {
log.Error(
"Error reading packfile",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -449,7 +449,7 @@ func pushToSubdirectory(remote *url.URL) error {

log.Info(
"Wrote packfile",
map[string]interface{}{
map[string]any{
"packPath": packPath,
},
)
Expand All @@ -458,7 +458,7 @@ func pushToSubdirectory(remote *url.URL) error {
cmd := fmt.Sprintf("git-upload-pack '%s'", remote.Path)
log.Info(
"Sending command",
map[string]interface{}{
map[string]any{
"command": cmd,
},
)
Expand Down
24 changes: 12 additions & 12 deletions cmd/omegaup-gitserver/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (a *omegaupAuthorization) parseBearerToken(token string) (username, problem
if err := paseto.NewV2().Verify(token, a.publicKey, &jsonToken, &footer); err != nil {
a.log.Error(
"failed to verify token",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand All @@ -108,7 +108,7 @@ func (a *omegaupAuthorization) parseBearerToken(token string) (username, problem
if err := jsonToken.Validate(paseto.IssuedBy("omegaUp frontend"), paseto.ValidAt(time.Now())); err != nil {
a.log.Error(
"failed to validate token",
map[string]interface{}{
map[string]any{
"err": err,
},
)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (a *omegaupAuthorization) parseUsernameAndPassword(
// omegaup:system and friends can only log in using the auth token or the secret token.
a.log.Error(
"user tried to login with restricted user",
map[string]interface{}{
map[string]any{
"username": username,
},
)
Expand All @@ -170,7 +170,7 @@ func (a *omegaupAuthorization) parseUsernameAndPassword(
if err != nil {
a.log.Error(
"failed to query user",
map[string]interface{}{
map[string]any{
"username": username,
"err": err,
},
Expand All @@ -181,7 +181,7 @@ func (a *omegaupAuthorization) parseUsernameAndPassword(
if !gitToken.Valid {
a.log.Error(
"user is missing a git token",
map[string]interface{}{
map[string]any{
"username": username,
},
)
Expand All @@ -192,7 +192,7 @@ func (a *omegaupAuthorization) parseUsernameAndPassword(
if err != nil {
a.log.Error(
"failed to verify user's git token",
map[string]interface{}{
map[string]any{
"username": username,
"err": err,
},
Expand All @@ -206,7 +206,7 @@ func (a *omegaupAuthorization) parseUsernameAndPassword(
} else {
a.log.Error(
"user provided the wrong git token",
map[string]interface{}{
map[string]any{
"username": username,
},
)
Expand Down Expand Up @@ -334,7 +334,7 @@ func (a *omegaupAuthorization) authorize(
ok = false
a.log.Error(
"Mismatched Basic authentication username",
map[string]interface{}{
map[string]any{
"username": username,
"basic auth username": basicAuthUsername,
"repository": repositoryName,
Expand Down Expand Up @@ -362,7 +362,7 @@ func (a *omegaupAuthorization) authorize(
w.WriteHeader(http.StatusUnauthorized)
a.log.Error(
"Missing authentication",
map[string]interface{}{
map[string]any{
"username": username,
"repository": repositoryName,
},
Expand All @@ -374,7 +374,7 @@ func (a *omegaupAuthorization) authorize(
w.WriteHeader(http.StatusForbidden)
a.log.Error(
"Mismatched problem name",
map[string]interface{}{
map[string]any{
"username": username,
"repository": repositoryName,
"problem": problem,
Expand Down Expand Up @@ -417,7 +417,7 @@ func (a *omegaupAuthorization) authorize(
if err != nil {
a.log.Error(
"Auth",
map[string]interface{}{
map[string]any{
"username": username,
"repository": repositoryName,
"operation": operation,
Expand All @@ -434,7 +434,7 @@ func (a *omegaupAuthorization) authorize(
}
a.log.Info(
"Auth",
map[string]interface{}{
map[string]any{
"username": username,
"repository": repositoryName,
"operation": operation,
Expand Down
2 changes: 1 addition & 1 deletion cmd/omegaup-gitserver/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"testing"

"github.com/omegaup/go-base/logging/log15"
"github.com/omegaup/go-base/logging/log15/v3"

"golang.org/x/crypto/ed25519"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/omegaup-gitserver/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/omegaup/githttp/v2"
"github.com/omegaup/gitserver"
"github.com/omegaup/go-base/logging/log15"
"github.com/omegaup/go-base/logging/log15/v3"
)

var (
Expand Down
Loading

0 comments on commit 29a3e99

Please sign in to comment.