vendor: update all dependencies
This commit is contained in:
Generated
Vendored
+14
-2
@@ -60,6 +60,10 @@ type Controller struct {
|
||||
options Options
|
||||
uniquifier string
|
||||
description string
|
||||
// labels are included when registering the debuggee. They should contain
|
||||
// the module name, version and minorversion, and are used by the debug UI
|
||||
// to label the correct version active for debugging.
|
||||
labels map[string]string
|
||||
// mu protects debuggeeID
|
||||
mu sync.Mutex
|
||||
// debuggeeID is returned from the server on registration, and is passed back
|
||||
@@ -133,16 +137,18 @@ func NewController(ctx context.Context, o Options) (*Controller, error) {
|
||||
scJSON = nil
|
||||
o.SourceContexts = nil
|
||||
}
|
||||
const minorversion = "107157" // any arbitrary numeric string
|
||||
|
||||
// Compute a uniquifier string by hashing the project number, app module name,
|
||||
// app module version, debuglet version, and source context.
|
||||
// The choice of hash function is arbitrary.
|
||||
h := sha256.Sum256([]byte(fmt.Sprintf("%d %s %d %s %d %s %d %s %d %s",
|
||||
h := sha256.Sum256([]byte(fmt.Sprintf("%d %s %d %s %d %s %d %s %d %s %d %s",
|
||||
len(o.ProjectNumber), o.ProjectNumber,
|
||||
len(o.AppModule), o.AppModule,
|
||||
len(o.AppVersion), o.AppVersion,
|
||||
len(agentVersionString), agentVersionString,
|
||||
len(scJSON), scJSON)))
|
||||
len(scJSON), scJSON,
|
||||
len(minorversion), minorversion)))
|
||||
uniquifier := fmt.Sprintf("%X", h[0:16]) // 32 hex characters
|
||||
|
||||
description := o.ProjectID
|
||||
@@ -166,6 +172,11 @@ func NewController(ctx context.Context, o Options) (*Controller, error) {
|
||||
options: o,
|
||||
uniquifier: uniquifier,
|
||||
description: description,
|
||||
labels: map[string]string{
|
||||
"module": o.AppModule,
|
||||
"version": o.AppVersion,
|
||||
"minorversion": minorversion,
|
||||
},
|
||||
}
|
||||
|
||||
return c, nil
|
||||
@@ -256,6 +267,7 @@ func (c *Controller) register(ctx context.Context) error {
|
||||
Project: c.options.ProjectNumber,
|
||||
SourceContexts: c.options.SourceContexts,
|
||||
Uniquifier: c.uniquifier,
|
||||
Labels: c.labels,
|
||||
},
|
||||
}
|
||||
resp, err := c.s.Register(ctx, &req)
|
||||
|
||||
Generated
Vendored
+36
@@ -15,6 +15,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
@@ -168,6 +172,9 @@ func TestDebugletControllerClientLibrary(t *testing.T) {
|
||||
if c, err = NewController(ctx, opts); err != nil {
|
||||
t.Fatal("Initializing Controller client:", err)
|
||||
}
|
||||
if err := validateLabels(c, opts); err != nil {
|
||||
t.Fatalf("Invalid labels:\n%v", err)
|
||||
}
|
||||
if list, err = c.List(ctx); err != nil {
|
||||
t.Fatal("List:", err)
|
||||
}
|
||||
@@ -208,6 +215,35 @@ func TestDebugletControllerClientLibrary(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func validateLabels(c *Controller, o Options) error {
|
||||
errMsg := new(bytes.Buffer)
|
||||
if m, ok := c.labels["module"]; ok {
|
||||
if m != o.AppModule {
|
||||
errMsg.WriteString(fmt.Sprintf("label module: want %s, got %s\n", o.AppModule, m))
|
||||
}
|
||||
} else {
|
||||
errMsg.WriteString("Missing \"module\" label\n")
|
||||
}
|
||||
if v, ok := c.labels["version"]; ok {
|
||||
if v != o.AppVersion {
|
||||
errMsg.WriteString(fmt.Sprintf("label version: want %s, got %s\n", o.AppVersion, v))
|
||||
}
|
||||
} else {
|
||||
errMsg.WriteString("Missing \"version\" label\n")
|
||||
}
|
||||
if mv, ok := c.labels["minorversion"]; ok {
|
||||
if _, err := strconv.Atoi(mv); err != nil {
|
||||
errMsg.WriteString(fmt.Sprintln("label minorversion: not a numeric string:", mv))
|
||||
}
|
||||
} else {
|
||||
errMsg.WriteString("Missing \"minorversion\" label\n")
|
||||
}
|
||||
if errMsg.Len() != 0 {
|
||||
return errors.New(errMsg.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestIsAbortedError(t *testing.T) {
|
||||
if !isAbortedError(abortedError) {
|
||||
t.Errorf("isAborted(%+v): got false, want true", abortedError)
|
||||
|
||||
Reference in New Issue
Block a user