Skip to content

Commit

Permalink
fix(server): ID placeholder must not take a pointer anymore
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Henri Symoneaux <[email protected]>
  • Loading branch information
phsym committed Mar 5, 2025
1 parent 6ed9d0a commit 39c50f6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions kmipserver/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func PeerCertificates(ctx context.Context) []*x509.Certificate {

type ctxBatch struct{}
type batchData struct {
idPlaceholder *string
idPlaceholder string
header kmip.RequestHeader
}

Expand All @@ -50,20 +50,20 @@ func newBatchContext(parent context.Context, hdr kmip.RequestHeader) context.Con
return context.WithValue(parent, ctxBatch{}, bdata)
}

func IdPlaceholder(ctx context.Context) *string {
func IdPlaceholder(ctx context.Context) string {
bd, _ := ctx.Value(ctxBatch{}).(*batchData)
if bd == nil {
return nil
return ""
}
return bd.idPlaceholder
}

func GetIdOrPlaceholder(ctx context.Context, reqId *string) (string, error) {
if reqId != nil {
return *reqId, nil
func GetIdOrPlaceholder(ctx context.Context, reqId string) (string, error) {
if reqId != "" {
return reqId, nil
}
if idp := IdPlaceholder(ctx); idp != nil {
return *idp, nil
if idp := IdPlaceholder(ctx); idp != "" {
return idp, nil
}
//TODO: Proper error
return "", errors.New("ID Placeholder is empty")
Expand All @@ -74,7 +74,7 @@ func SetIdPlaceholder(ctx context.Context, id string) {
if bd == nil {
panic("not in a batch context")
}
bd.idPlaceholder = &id
bd.idPlaceholder = id
}

func ClearIdPlaceholder(ctx context.Context) {
Expand All @@ -83,7 +83,7 @@ func ClearIdPlaceholder(ctx context.Context) {
// Silently ignore if not in a batch context
return
}
bd.idPlaceholder = nil
bd.idPlaceholder = ""
}

func GetProtocolVersion(ctx context.Context) kmip.ProtocolVersion {
Expand Down

0 comments on commit 39c50f6

Please sign in to comment.