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

chore: bump go to 1.18, all dependency versions and remove deprecated calls #1

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Go 1.16
- name: Setup Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18

- name: Cache Go modules
uses: actions/cache@v2
Expand Down
14 changes: 7 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -119,7 +119,7 @@ func (p *Client) Write(ctx context.Context, req *WriteRequest, options ...WriteO
defer httpResp.Body.Close()

if st := httpResp.StatusCode; st/100 != 2 {
msg, _ := ioutil.ReadAll(httpResp.Body)
msg, _ := io.ReadAll(httpResp.Body)
return nil, &WriteError{
err: fmt.Errorf("promwrite: expected status %d, got %d: %s", http.StatusOK, st, string(msg)),
code: st,
Expand All @@ -128,17 +128,17 @@ func (p *Client) Write(ctx context.Context, req *WriteRequest, options ...WriteO
return &WriteResponse{}, nil
}

func toProtoTimeSeries(timeSeries []TimeSeries) []*prompb.TimeSeries {
res := make([]*prompb.TimeSeries, len(timeSeries))
func toProtoTimeSeries(timeSeries []TimeSeries) []prompb.TimeSeries {
res := make([]prompb.TimeSeries, len(timeSeries))
for i, ts := range timeSeries {
labels := make([]*prompb.Label, len(ts.Labels))
labels := make([]prompb.Label, len(ts.Labels))
for j, lb := range ts.Labels {
labels[j] = &prompb.Label{
labels[j] = prompb.Label{
Name: lb.Name,
Value: lb.Value,
}
}
pbTs := &prompb.TimeSeries{
pbTs := prompb.TimeSeries{
Labels: labels,
Samples: []prompb.Sample{{
// Timestamp for remote write should be in milliseconds.
Expand Down
15 changes: 8 additions & 7 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package promwrite_test
import (
"context"
"errors"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
Expand All @@ -24,7 +25,7 @@ func TestClient(t *testing.T) {

receivedWriteRequest := make(chan *prompb.WriteRequest, 1)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
b, _ := ioutil.ReadAll(req.Body)
b, _ := io.ReadAll(req.Body)
parsed, err := parseWriteRequest(b)
r.NoError(err)
receivedWriteRequest <- parsed
Expand Down Expand Up @@ -75,8 +76,8 @@ func TestClient(t *testing.T) {

res := <-receivedWriteRequest
r.Len(res.Timeseries, 2)
r.Equal(&prompb.TimeSeries{
Labels: []*prompb.Label{
r.Equal(prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: "__name__",
Value: "metric_a",
Expand All @@ -93,8 +94,8 @@ func TestClient(t *testing.T) {
},
},
}, res.Timeseries[0])
r.Equal(&prompb.TimeSeries{
Labels: []*prompb.Label{
r.Equal(prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: "__name__",
Value: "metric_b",
Expand Down Expand Up @@ -161,8 +162,8 @@ func TestClient(t *testing.T) {

res := <-receivedWriteRequest
r.Len(res.Timeseries, 1)
r.Equal(&prompb.TimeSeries{
Labels: []*prompb.Label{
r.Equal(prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: "__name__",
Value: "metric_a",
Expand Down
19 changes: 6 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
module github.com/castai/promwrite

go 1.17
go 1.18

require (
github.com/gogo/protobuf v1.3.2
github.com/golang/snappy v0.0.4
github.com/prometheus/prometheus v2.5.0+incompatible
github.com/stretchr/testify v1.7.0
github.com/prometheus/prometheus v0.40.3
github.com/stretchr/testify v1.8.1
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20220204002441-d6cc3cc0770e // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading