Skip to content

Commit a1e8cfc

Browse files
committed
Fix deprecated code
Signed-off-by: Jorge Turrado <[email protected]>
1 parent a05aaf6 commit a1e8cfc

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/cmd/builder.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package cmd
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"sync"
2223
"time"
@@ -360,11 +361,11 @@ func (b *AdapterBase) Informers() (informers.SharedInformerFactory, error) {
360361
}
361362

362363
// Run runs this custom metrics adapter until the given stop channel is closed.
363-
func (b *AdapterBase) Run(stopCh <-chan struct{}) error {
364+
func (b *AdapterBase) Run(ctx context.Context) error {
364365
server, err := b.Server()
365366
if err != nil {
366367
return err
367368
}
368369

369-
return server.GenericAPIServer.PrepareRun().Run(stopCh)
370+
return server.GenericAPIServer.PrepareRun().RunWithContext(ctx)
370371
}

test-adapter/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"context"
2021
"net/http"
2122
"os"
2223
"time"
2324

2425
"github.com/emicklei/go-restful/v3"
25-
"k8s.io/apimachinery/pkg/util/wait"
2626
"k8s.io/component-base/logs"
2727
"k8s.io/component-base/metrics/legacyregistry"
2828
"k8s.io/klog/v2"
@@ -86,7 +86,7 @@ func main() {
8686
}
8787
klog.Fatal(server.ListenAndServe())
8888
}()
89-
if err := cmd.Run(wait.NeverStop); err != nil {
89+
if err := cmd.Run(context.Background()); err != nil {
9090
klog.Fatalf("unable to run custom metrics adapter: %v", err)
9191
}
9292
}

0 commit comments

Comments
 (0)