Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump CI default version of Go to 1.20 #3733

Merged
merged 9 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ on:
env:
# Path to where test results will be saved.
TEST_RESULTS: /tmp/test-results
# Default minimum version of Go to support.
DEFAULT_GO_VERSION: 1.19
# Default version of Go to use by CI workflows. This should be the latest
# release of Go; developers likely use the latest release in development and
# we want to catch any bugs (e.g. lint errors, race detection) with the this
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
# release before they are merged. The Go compatibility guarantees ensure
# backwards compatibility with the previous two minor releases and we
# explicitly test our code for these versions so keeping this at prior
# versions does not add value.
DEFAULT_GO_VERSION: "1.20"
jobs:
lint:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- Ensure `go.opentelemetry.io/otel` does not use generics. (#3723, #3725)
- Remove use of deprectaed `"math/rand".Seed` in `go.opentelemetry.io/otel/example/prometheus`. (#3733)
MrAlias marked this conversation as resolved.
Show resolved Hide resolved

## [1.13.0/0.36.0] 2023-02-07

Expand Down
7 changes: 2 additions & 5 deletions example/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ import (
"go.opentelemetry.io/otel/sdk/metric"
)

func init() {
rand.Seed(time.Now().UnixNano())
}

func main() {
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
ctx := context.Background()

// The exporter embeds a default OpenTelemetry Reader and
Expand Down Expand Up @@ -70,7 +67,7 @@ func main() {
log.Fatal(err)
}
_, err = meter.RegisterCallback(func(_ context.Context, o api.Observer) error {
n := -10. + rand.Float64()*(90.) // [-10, 100)
n := -10. + rng.Float64()*(90.) // [-10, 100)
o.ObserveFloat64(gauge, n, attrs...)
return nil
}, gauge)
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/reconnecting_udp_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package jaeger

import (
"context"
"crypto/rand"
"fmt"
"math/rand"
"net"
"testing"
"time"
Expand Down
17 changes: 4 additions & 13 deletions exporters/otlp/otlpmetric/internal/otest/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
cryptorand "crypto/rand"
"crypto/rand"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix" // nolint:depguard // This is for testing.
Expand All @@ -29,7 +29,6 @@ import (
"fmt"
"io"
"math/big"
mathrand "math/rand"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -389,25 +388,17 @@ func (c *HTTPCollector) respond(w http.ResponseWriter, resp ExportResult) {
}
}

type mathRandReader struct{}

func (mathRandReader) Read(p []byte) (n int, err error) {
return mathrand.Read(p)
}

var randReader mathRandReader

// Based on https://golang.org/src/crypto/tls/generate_cert.go,
// simplified and weakened.
func weakCertificate() (tls.Certificate, error) {
priv, err := ecdsa.GenerateKey(elliptic.P256(), randReader)
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
return tls.Certificate{}, err
}
notBefore := time.Now()
notAfter := notBefore.Add(time.Hour)
max := new(big.Int).Lsh(big.NewInt(1), 128)
sn, err := cryptorand.Int(randReader, max)
sn, err := rand.Int(rand.Reader, max)
if err != nil {
return tls.Certificate{}, err
}
Expand All @@ -422,7 +413,7 @@ func weakCertificate() (tls.Certificate, error) {
DNSNames: []string{"localhost"},
IPAddresses: []net.IP{net.IPv6loopback, net.IPv4(127, 0, 0, 1)},
}
derBytes, err := x509.CreateCertificate(randReader, &tmpl, &tmpl, &priv.PublicKey, priv)
derBytes, err := x509.CreateCertificate(rand.Reader, &tmpl, &tmpl, &priv.PublicKey, priv)
if err != nil {
return tls.Certificate{}, err
}
Expand Down
17 changes: 4 additions & 13 deletions exporters/otlp/otlptrace/otlptracehttp/certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,15 @@ import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
cryptorand "crypto/rand"
"crypto/rand"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"math/big"
mathrand "math/rand"
"net"
"time"
)

type mathRandReader struct{}

func (mathRandReader) Read(p []byte) (n int, err error) {
return mathrand.Read(p)
}

var randReader mathRandReader

type pemCertificate struct {
Certificate []byte
PrivateKey []byte
Expand All @@ -44,15 +35,15 @@ type pemCertificate struct {
// Based on https://golang.org/src/crypto/tls/generate_cert.go,
// simplified and weakened.
func generateWeakCertificate() (*pemCertificate, error) {
priv, err := ecdsa.GenerateKey(elliptic.P256(), randReader)
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
return nil, err
}
keyUsage := x509.KeyUsageDigitalSignature
notBefore := time.Now()
notAfter := notBefore.Add(time.Hour)
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := cryptorand.Int(randReader, serialNumberLimit)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return nil, err
}
Expand All @@ -69,7 +60,7 @@ func generateWeakCertificate() (*pemCertificate, error) {
DNSNames: []string{"localhost"},
IPAddresses: []net.IP{net.IPv6loopback, net.IPv4(127, 0, 0, 1)},
}
derBytes, err := x509.CreateCertificate(randReader, &template, &template, &priv.PublicKey, priv)
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)
if err != nil {
return nil, err
}
Expand Down