blob: e892e6ac1fc64f3abff235ed218a9ee7a6908a7a [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package resultstore
import (
"context"
"fuchsia.googlesource.com/infra/infra/fxctx"
)
const (
// TestUUIDKey references a UUID to use for testing.
TestUUIDKey = fxctx.ContextKey("test-uuid")
// AuthTokenKey references the auth token to use in ResultStore requests.
AuthTokenKey = fxctx.ContextKey("auth-token")
)
// TestUUID gets the test UUID, if present. Errors if the value is missing or cannot be
// read from the Context.
func TestUUID(ctx context.Context) (string, error) {
var uuid string
err := fxctx.Get(ctx, TestUUIDKey, &uuid)
return uuid, err
}
// SetTestUUID sets a UUID to use for testing.
func SetTestUUID(ctx context.Context, uuid string) (context.Context, error) {
return fxctx.Set(ctx, TestUUIDKey, uuid)
}
// AuthToken gets the auth token to use in ResultStore requests.
func AuthToken(ctx context.Context) (string, error) {
var token string
err := fxctx.Get(ctx, AuthTokenKey, &token)
return token, err
}
// SetAuthToken sets the auth token to use in ResultStore requests.
func SetAuthToken(ctx context.Context, value string) (context.Context, error) {
return fxctx.Set(ctx, AuthTokenKey, value)
}