go.mod github.com/Microsoft/hcsshim v0.8.16
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
33
vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
generated
vendored
33
vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
generated
vendored
@ -1,34 +1,29 @@
|
||||
package wclayer
|
||||
|
||||
import (
|
||||
"github.com/Microsoft/hcsshim/internal/guid"
|
||||
"context"
|
||||
|
||||
"github.com/Microsoft/go-winio/pkg/guid"
|
||||
"github.com/Microsoft/hcsshim/internal/hcserror"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/Microsoft/hcsshim/internal/oc"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
// NameToGuid converts the given string into a GUID using the algorithm in the
|
||||
// Host Compute Service, ensuring GUIDs generated with the same string are common
|
||||
// across all clients.
|
||||
func NameToGuid(name string) (id guid.GUID, err error) {
|
||||
func NameToGuid(ctx context.Context, name string) (_ guid.GUID, err error) {
|
||||
title := "hcsshim::NameToGuid"
|
||||
fields := logrus.Fields{
|
||||
"name": name,
|
||||
}
|
||||
logrus.WithFields(fields).Debug(title)
|
||||
defer func() {
|
||||
if err != nil {
|
||||
fields[logrus.ErrorKey] = err
|
||||
logrus.WithFields(fields).Error(err)
|
||||
} else {
|
||||
logrus.WithFields(fields).Debug(title + " - succeeded")
|
||||
}
|
||||
}()
|
||||
ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
|
||||
defer span.End()
|
||||
defer func() { oc.SetSpanStatus(span, err) }()
|
||||
span.AddAttributes(trace.StringAttribute("name", name))
|
||||
|
||||
var id guid.GUID
|
||||
err = nameToGuid(name, &id)
|
||||
if err != nil {
|
||||
err = hcserror.New(err, title+" - failed", "")
|
||||
return
|
||||
return guid.GUID{}, hcserror.New(err, title+" - failed", "")
|
||||
}
|
||||
fields["guid"] = id.String()
|
||||
return
|
||||
span.AddAttributes(trace.StringAttribute("guid", id.String()))
|
||||
return id, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user