Merge "Fix Lint warnings: Use of basic type string as key"
This commit is contained in:
commit
5f4193e3f5
@ -26,11 +26,16 @@ import (
|
||||
"opendev.org/airship/airshipctl/pkg/log"
|
||||
)
|
||||
|
||||
// contextKey is used by the redfish package as a unique key type in order to prevent collisions
|
||||
// with context keys in other packages.
|
||||
type contextKey string
|
||||
|
||||
const (
|
||||
// ClientType is used by other packages as the identifier of the Redfish client.
|
||||
ClientType string = "redfish"
|
||||
systemActionRetries = 30
|
||||
systemRebootDelay = 30 * time.Second
|
||||
ClientType string = "redfish"
|
||||
systemActionRetries = 30
|
||||
systemRebootDelay = 30 * time.Second
|
||||
ctxKeyNumRetries contextKey = "numRetries"
|
||||
)
|
||||
|
||||
// Client holds details about a Redfish out-of-band system required for out-of-band management.
|
||||
@ -49,7 +54,7 @@ func (c *Client) NodeID() string {
|
||||
func (c *Client) EjectVirtualMedia(ctx context.Context) error {
|
||||
waitForEjectMedia := func(managerID string, mediaID string) error {
|
||||
// Check if number of retries is defined in context
|
||||
totalRetries, ok := ctx.Value("numRetries").(int)
|
||||
totalRetries, ok := ctx.Value(ctxKeyNumRetries).(int)
|
||||
if !ok {
|
||||
totalRetries = systemActionRetries
|
||||
}
|
||||
@ -108,7 +113,7 @@ func (c *Client) EjectVirtualMedia(ctx context.Context) error {
|
||||
func (c *Client) RebootSystem(ctx context.Context) error {
|
||||
waitForPowerState := func(desiredState redfishClient.PowerState) error {
|
||||
// Check if number of retries is defined in context
|
||||
totalRetries, ok := ctx.Value("numRetries").(int)
|
||||
totalRetries, ok := ctx.Value(ctxKeyNumRetries).(int)
|
||||
if !ok {
|
||||
totalRetries = systemActionRetries
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ func TestEjectVirtualMedia(t *testing.T) {
|
||||
client.nodeID = nodeID
|
||||
|
||||
// Normal retries are 30. Limit them here for test time.
|
||||
ctx := context.WithValue(context.Background(), "numRetries", 2)
|
||||
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 2)
|
||||
|
||||
// Mark CD and DVD test media as inserted
|
||||
inserted := true
|
||||
@ -131,7 +131,7 @@ func TestEjectVirtualMediaRetriesExceeded(t *testing.T) {
|
||||
|
||||
client.nodeID = nodeID
|
||||
|
||||
ctx := context.WithValue(context.Background(), "numRetries", 1)
|
||||
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
|
||||
|
||||
// Mark test media as inserted
|
||||
inserted := true
|
||||
@ -260,7 +260,7 @@ func TestRebootSystemTimeout(t *testing.T) {
|
||||
|
||||
client.nodeID = nodeID
|
||||
|
||||
ctx := context.WithValue(context.Background(), "numRetries", 1)
|
||||
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
|
||||
resetReq := redfishClient.ResetRequestBody{}
|
||||
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
|
||||
|
||||
@ -363,7 +363,7 @@ func TestSetVirtualMediaEjectExistingMedia(t *testing.T) {
|
||||
client.nodeID = nodeID
|
||||
|
||||
// Normal retries are 30. Limit them here for test time.
|
||||
ctx := context.WithValue(context.Background(), "numRetries", 1)
|
||||
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
|
||||
|
||||
// Mark test media as inserted
|
||||
inserted := true
|
||||
@ -408,7 +408,7 @@ func TestSetVirtualMediaEjectExistingMediaFailure(t *testing.T) {
|
||||
client.nodeID = nodeID
|
||||
|
||||
// Normal retries are 30. Limit them here for test time.
|
||||
ctx := context.WithValue(context.Background(), "numRetries", 1)
|
||||
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
|
||||
|
||||
// Mark test media as inserted
|
||||
inserted := true
|
||||
|
Loading…
Reference in New Issue
Block a user