Skip to content

Commit 460a7bf

Browse files
Add context to all calls:
The latest version includes context to all calls. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent 70dc9f1 commit 460a7bf

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

providers/goipmi/goipmi.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (c *Config) Name() string {
7272

7373
func (c *Config) Open(ctx context.Context) error {
7474
c.client.WithTimeout(getTimeout(ctx))
75-
return c.client.Connect()
75+
return c.client.Connect(ctx)
7676
}
7777

7878
func getTimeout(ctx context.Context) time.Duration {
@@ -84,12 +84,12 @@ func getTimeout(ctx context.Context) time.Duration {
8484
return time.Until(deadline)
8585
}
8686

87-
func (c *Config) Close(_ context.Context) error {
88-
return c.client.Close()
87+
func (c *Config) Close(ctx context.Context) error {
88+
return c.client.Close(ctx)
8989
}
9090

91-
func (c *Config) PowerStateGet(_ context.Context) (string, error) {
92-
r, err := c.client.GetChassisStatus()
91+
func (c *Config) PowerStateGet(ctx context.Context) (string, error) {
92+
r, err := c.client.GetChassisStatus(ctx)
9393
if err != nil {
9494
return "", err
9595
}
@@ -101,7 +101,7 @@ func (c *Config) PowerStateGet(_ context.Context) (string, error) {
101101
return state, nil
102102
}
103103

104-
func (c *Config) PowerSet(_ context.Context, state string) (bool, error) {
104+
func (c *Config) PowerSet(ctx context.Context, state string) (bool, error) {
105105
var action ipmi.ChassisControl
106106
switch strings.ToLower(state) {
107107
case "on":
@@ -111,7 +111,7 @@ func (c *Config) PowerSet(_ context.Context, state string) (bool, error) {
111111
case "soft":
112112
action = ipmi.ChassisControlSoftShutdown
113113
case "reset":
114-
action = ipmi.ChassisControlHardwareRest
114+
action = ipmi.ChassisControlHardReset
115115
case "cycle":
116116
action = ipmi.ChassisControlPowerCycle
117117
default:
@@ -120,15 +120,15 @@ func (c *Config) PowerSet(_ context.Context, state string) (bool, error) {
120120

121121
// ipmi.ChassisControlResponse is an empty struct.
122122
// No methods return any actual response. So we ignore it.
123-
_, err := c.client.ChassisControl(action)
123+
_, err := c.client.ChassisControl(ctx, action)
124124
if err != nil {
125125
return false, err
126126
}
127127

128128
return true, nil
129129
}
130130

131-
func (c *Config) BootDeviceSet(_ context.Context, bootDevice string, setPersistent, efiBoot bool) (ok bool, err error) {
131+
func (c *Config) BootDeviceSet(ctx context.Context, bootDevice string, setPersistent, efiBoot bool) (ok bool, err error) {
132132
d := ipmi.BootDeviceSelectorNoOverride
133133
switch strings.ToLower(bootDevice) {
134134
case "pxe":
@@ -151,15 +151,15 @@ func (c *Config) BootDeviceSet(_ context.Context, bootDevice string, setPersiste
151151
bt = ipmi.BIOSBootTypeEFI
152152
}
153153

154-
if err := c.client.SetBootDevice(d, bt, setPersistent); err != nil {
154+
if err := c.client.SetBootDevice(ctx, d, bt, setPersistent); err != nil {
155155
return false, err
156156
}
157157

158158
return true, nil
159159
}
160160

161-
func (c *Config) UserRead(_ context.Context) (users []map[string]string, err error) {
162-
u, err := c.client.ListUser(0)
161+
func (c *Config) UserRead(ctx context.Context) (users []map[string]string, err error) {
162+
u, err := c.client.ListUser(ctx, 0)
163163
if err != nil {
164164
return nil, err
165165
}

0 commit comments

Comments
 (0)