Skip to content

Commit 841a757

Browse files
authored
Merge pull request #4267 from twz123/os-specific-cleanup
Consolidate network bridge cleanup
2 parents 29ae693 + f408377 commit 841a757

File tree

5 files changed

+16
-72
lines changed

5 files changed

+16
-72
lines changed

pkg/cleanup/bridge_darwin.go

-30
This file was deleted.

pkg/cleanup/bridge_linux.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ package cleanup
1818

1919
import (
2020
"fmt"
21-
"runtime"
2221

2322
"github.com/vishvananda/netlink"
2423
)
2524

26-
type bridge struct{}
25+
func newBridgeStep() Step {
26+
return linuxBridge{}
27+
}
28+
29+
type linuxBridge struct{}
2730

2831
// Name returns the name of the step
29-
func (b *bridge) Name() string {
32+
func (linuxBridge) Name() string {
3033
return "kube-bridge leftovers cleanup step"
3134
}
3235

3336
// Run removes found kube-bridge leftovers
34-
func (b *bridge) Run() error {
35-
if runtime.GOOS == "windows" {
36-
return nil
37-
}
38-
37+
func (linuxBridge) Run() error {
3938
lnks, err := netlink.LinkList()
4039
if err != nil {
4140
return fmt.Errorf("failed to get link list from netlink: %w", err)

pkg/cleanup/cleanup_windows.go renamed to pkg/cleanup/bridge_other.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright 2021 k0s authors
35
@@ -16,6 +18,6 @@ limitations under the License.
1618

1719
package cleanup
1820

19-
// no need to build unix specific funcs into windows
20-
func cleanupMount(path string) {}
21-
func cleanupNetworkNamespace(path string) {}
21+
func newBridgeStep() Step {
22+
return nil
23+
}

pkg/cleanup/bridge_windows.go

-30
This file was deleted.

pkg/cleanup/cleanup_unix.go renamed to pkg/cleanup/cleanup.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ func (c *Config) Cleanup() error {
7777
&services{Config: c},
7878
&directories{Config: c},
7979
&cni{},
80-
&bridge{},
80+
}
81+
82+
if bridge := newBridgeStep(); bridge != nil {
83+
cleanupSteps = append(cleanupSteps, bridge)
8184
}
8285

8386
for _, step := range cleanupSteps {

0 commit comments

Comments
 (0)