Skip to content

Commit

Permalink
BAAS-35424 pull in 1.17.2 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
kpatel71716 committed Feb 19, 2025
2 parents 1d01c7b + f132378 commit 85b2534
Show file tree
Hide file tree
Showing 502 changed files with 25,188 additions and 7,604 deletions.
516 changes: 374 additions & 142 deletions .evergreen/config.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fi

AUTH=${AUTH} \
SSL=${SSL} \
SKIP_CSOT_TESTS=${SKIP_CSOT_TESTS} \
MONGO_GO_DRIVER_CA_FILE=${MONGO_GO_DRIVER_CA_FILE} \
MONGO_GO_DRIVER_KEY_FILE=${MONGO_GO_DRIVER_KEY_FILE} \
MONGO_GO_DRIVER_PKCS8_ENCRYPTED_KEY_FILE=${MONGO_GO_DRIVER_PKCS8_ENCRYPTED_KEY_FILE} \
Expand Down
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
- package-ecosystem: gomod
directory: /
schedule:
interval: "weekly"
1 change: 0 additions & 1 deletion .github/reviewers.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
qingyang-hu
matthewdale
prestonvasquez
blink1073
51 changes: 51 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "CodeQL"

on:
push:
branches: [ "v1", "cloud-*", "master", "release/*" ]
pull_request:
branches: [ "v1", "cloud-*", "master", "release/*" ]
schedule:
- cron: '36 17 * * 0'
workflow_call:
inputs:
ref:
required: true
type: string

jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

strategy:
fail-fast: false
matrix:
include:
- language: go
build-mode: manual

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}

- if: matrix.build-mode == 'manual'
shell: bash
run: |
make build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: "The new version to set"
required: true
prev_version:
description: "The previous tagged version"
required: true
push_changes:
description: "Push changes?"
default: true
type: boolean

defaults:
run:
shell: bash -eux {0}

env:
# Changes per branch
SILK_ASSET_GROUP: mongodb-go-driver-v1
EVERGREEN_PROJECT: mongo-go-driver-v1

jobs:
pre-publish:
environment: release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
outputs:
prev_version: ${{ steps.pre-publish.outputs.prev_version }}
steps:
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
with:
app_id: ${{ vars.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: mongodb-labs/drivers-github-tools/setup@v2
with:
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
aws_region_name: ${{ vars.AWS_REGION_NAME }}
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
- name: Pre Publish
id: pre-publish
uses: mongodb-labs/drivers-github-tools/golang/pre-publish@v2
with:
version: ${{ inputs.version }}
push_changes: ${{ inputs.push_changes }}

static-scan:
needs: [pre-publish]
permissions:
security-events: write
uses: ./.github/workflows/codeql.yml
with:
ref: ${{ github.ref }}

publish:
needs: [pre-publish, static-scan]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
security-events: read
steps:
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
with:
app_id: ${{ vars.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: mongodb-labs/drivers-github-tools/setup@v2
with:
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
aws_region_name: ${{ vars.AWS_REGION_NAME }}
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
- name: Publish
uses: mongodb-labs/drivers-github-tools/golang/publish@v2
with:
version: ${{ inputs.version }}
silk_asset_group: ${{ env.SILK_ASSET_GROUP }}
evergreen_project: ${{ env.EVERGREEN_PROJECT }}
prev_version: ${{ inputs.prev_version }}
push_changes: ${{ inputs.push_changes }}
token: ${{ env.GH_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
21 changes: 9 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
run:
timeout: 5m
skip-dirs-use-default: false
skip-dirs:
- (^|/)vendor($|/)
- (^|/)testdata($|/)
- (^|/)etc($|/)
# Disable all linters for "golang.org/x/exp/rand" package in internal/rand.
- internal/rand

linters:
disable-all: true
Expand Down Expand Up @@ -35,11 +28,7 @@ linters:

linters-settings:
errcheck:
exclude: .errcheck-excludes
gocritic:
enabled-checks:
# Detects suspicious append result assignments. E.g. "b := append(a, 1, 2, 3)"
- appendAssign
exclude-functions: .errcheck-excludes
govet:
disable:
- cgocall
Expand All @@ -55,6 +44,14 @@ linters-settings:
]

issues:
exclude-dirs-use-default: false
exclude-dirs:
- (^|/)testdata($|/)
- (^|/)etc($|/)
# Disable all linters for copied third-party code.
- internal/rand
- internal/aws
- internal/assert
exclude-use-default: false
exclude:
# Add all default excluded issues except issues related to exported types/functions not having
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-L", "te,fo,fle,alo,nin,compres,wil,collone,asess,sav,ot,wll,dne,nulll,hellow"]
args: ["-L", "te,fo,fle,alo,nin,compres,wil,collone,asess,sav,ot,wll,dne,nulll,hellow,aks"]
exclude: ^(vendor/|benchmark/operation_test.go)
exclude_types: [json,yaml,pem]

Expand All @@ -51,6 +51,6 @@ repos:
exclude: ^(vendor)

- repo: https://github.com/golangci/golangci-lint
rev: v1.55.1
rev: v1.60.1
hooks:
- id: golangci-lint
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ check-fmt: install-lll
check-modules:
go mod tidy -v
go mod vendor
git diff --exit-code go.mod go.sum ./vendor
git diff --exit-code go.mod go.sum ./vendor # Compare to the PR / WF Branch.

.PHONY: doc
doc:
Expand All @@ -72,7 +72,7 @@ fmt:

.PHONY: install-golangci-lint
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1

# Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect
# specific operating systems or architectures. For example, staticcheck will only check for 64-bit
Expand Down Expand Up @@ -106,7 +106,7 @@ test-race:

.PHONY: test-short
test-short:
go test $(BUILD_TAGS) -timeout 60s -short ./...
go test $(BUILD_TAGS) -timeout 60s -short -race ./...

### Local FaaS targets. ###
.PHONY: build-faas-awslambda
Expand All @@ -132,6 +132,11 @@ evg-test-atlas-data-lake:
evg-test-enterprise-auth:
go run -tags gssapi ./cmd/testentauth/main.go

.PHONY: evg-test-oidc-auth
evg-test-oidc-auth:
go run ./cmd/testoidcauth/main.go
go run -race ./cmd/testoidcauth/main.go

.PHONY: evg-test-kmip
evg-test-kmip:
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) DYLD_LIBRARY_PATH=$(MACOS_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionSpec/kmipKMS >> test.suite
Expand All @@ -158,7 +163,8 @@ evg-test-load-balancers:

.PHONY: evg-test-search-index
evg-test-search-index:
go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(TEST_TIMEOUT)s >> test.suite
# Double the timeout to wait for the responses from the server.
go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(shell echo "$$(( $(TEST_TIMEOUT) * 2))")s >> test.suite

.PHONY: evg-test-ocsp
evg-test-ocsp:
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@

The MongoDB supported driver for Go.

> \[!NOTE\]
>
> Go Driver 1.17.0 is the last planned 1.x version.
> It will receive critical bug fixes, but future development and features
> will be in the 2.x version of the driver.
______________________________________________________________________

## Requirements

- Go 1.18 or higher. We aim to support the latest versions of Go.
- Go 1.20 or higher is required to run the driver test suite.
- Go 1.22 or higher is required to run the driver test suite.
- MongoDB 3.6 and higher.

______________________________________________________________________
Expand Down
9 changes: 5 additions & 4 deletions bson/bson_corpus_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ func unescapeUnicode(s, bsonType string) string {

func formatDouble(f float64) string {
var s string
if math.IsInf(f, 1) {
switch {
case math.IsInf(f, 1):
s = "Infinity"
} else if math.IsInf(f, -1) {
case math.IsInf(f, -1):
s = "-Infinity"
} else if math.IsNaN(f) {
case math.IsNaN(f):
s = "NaN"
} else {
default:
// Print exactly one decimalType place for integers; otherwise, print as many are necessary to
// perfectly represent it.
s = strconv.FormatFloat(f, 'G', -1, 64)
Expand Down
4 changes: 2 additions & 2 deletions bson/bsoncodec/bsoncodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

func ExampleValueEncoder() {
var _ ValueEncoderFunc = func(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
var _ ValueEncoderFunc = func(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
if val.Kind() != reflect.String {
return ValueEncoderError{Name: "StringEncodeValue", Kinds: []reflect.Kind{reflect.String}, Received: val}
}
Expand All @@ -28,7 +28,7 @@ func ExampleValueEncoder() {
}

func ExampleValueDecoder() {
var _ ValueDecoderFunc = func(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
var _ ValueDecoderFunc = func(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
if !val.CanSet() || val.Kind() != reflect.String {
return ValueDecoderError{Name: "StringDecodeValue", Kinds: []reflect.Kind{reflect.String}, Received: val}
}
Expand Down
10 changes: 8 additions & 2 deletions bson/bsoncodec/default_value_decoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (DefaultValueDecoders) intDecodeType(dc DecodeContext, vr bsonrw.ValueReade
case reflect.Int64:
return reflect.ValueOf(i64), nil
case reflect.Int:
if int64(int(i64)) != i64 { // Can we fit this inside of an int
if i64 > math.MaxInt { // Can we fit this inside of an int
return emptyValue, fmt.Errorf("%d overflows int", i64)
}

Expand Down Expand Up @@ -434,7 +434,7 @@ func (dvd DefaultValueDecoders) UintDecodeValue(dc DecodeContext, vr bsonrw.Valu
return fmt.Errorf("%d overflows uint64", i64)
}
case reflect.Uint:
if i64 < 0 || int64(uint(i64)) != i64 { // Can we fit this inside of an uint
if i64 < 0 || uint64(i64) > uint64(math.MaxUint) { // Can we fit this inside of an uint
return fmt.Errorf("%d overflows uint", i64)
}
default:
Expand Down Expand Up @@ -1521,6 +1521,12 @@ func (dvd DefaultValueDecoders) ValueUnmarshalerDecodeValue(_ DecodeContext, vr
return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
}

if vr.Type() == bsontype.Null {
val.Set(reflect.Zero(val.Type()))

return vr.ReadNull()
}

if val.Kind() == reflect.Ptr && val.IsNil() {
if !val.CanSet() {
return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
Expand Down
4 changes: 2 additions & 2 deletions bson/bsoncodec/default_value_encoders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ func TestDefaultValueEncoders(t *testing.T) {
},
{
"WriteArrayElement Error",
bsoncore.Array(buildDocumentArray(func(doc []byte) []byte {
bsoncore.Array(buildDocumentArray(func([]byte) []byte {
return bsoncore.AppendNullElement(nil, "foo")
})),
nil,
Expand All @@ -1169,7 +1169,7 @@ func TestDefaultValueEncoders(t *testing.T) {
},
{
"encodeValue error",
bsoncore.Array(buildDocumentArray(func(doc []byte) []byte {
bsoncore.Array(buildDocumentArray(func([]byte) []byte {
return bsoncore.AppendNullElement(nil, "foo")
})),
nil,
Expand Down
Loading

0 comments on commit 85b2534

Please sign in to comment.