Skip to content

Commit

Permalink
Remove useless netInterface from controller
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneM committed Oct 25, 2018
1 parent 744a5d9 commit 2afeabb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 31 deletions.
8 changes: 1 addition & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/Scalingo/go-utils/logger/plugins/rollbarplugin"
"github.com/Scalingo/link/config"
"github.com/Scalingo/link/models"
"github.com/Scalingo/link/network"
"github.com/Scalingo/link/scheduler"
"github.com/Scalingo/link/web"
"github.com/sirupsen/logrus"
Expand All @@ -32,11 +31,6 @@ func main() {
panic(err)
}

netInterface, err := network.NewNetworkInterfaceFromName(config.Interface)
if err != nil {
panic(err)
}

storage := models.NewEtcdStorage(config)
scheduler := scheduler.NewIPScheduler(config, etcd, storage)

Expand All @@ -60,7 +54,7 @@ func main() {
}
}

controller := web.NewIPController(scheduler, netInterface)
controller := web.NewIPController(scheduler)
r := handlers.NewRouter(log)

if config.User != "" || config.Password != "" {
Expand Down
2 changes: 1 addition & 1 deletion mocks_sig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"github.com/Scalingo/link/api.Client":"62 a2 59 e0 47 34 c7 57 6c ee bf 94 e1 d7 45 65 38 29 f9 54","github.com/Scalingo/link/healthcheck.Checker":"1d f8 80 35 ac c7 d3 08 fd 14 96 d6 26 bd cb fd cf 5f af bc","github.com/Scalingo/link/locker.Locker":"a5 24 96 0f 1b f5 df b8 d8 dd 15 83 a1 d2 b2 d3 53 fa 25 0d","github.com/Scalingo/link/models.Storage":"6c 64 ff a2 f6 e0 72 82 d9 cd 56 6a 64 4b 8d 96 5d fe cd 7e","github.com/Scalingo/link/network.ARP":"20 bb b8 da 57 d8 84 21 24 36 cc 40 34 be f6 c3 e6 e9 f9 78","github.com/Scalingo/link/network.NetworkInterface":"0f c6 8d 68 bd 46 0d 9b 52 80 b5 7c 69 13 c0 dc 8a 44 cc 53","github.com/Scalingo/link/scheduler.Scheduler":"63 e6 1d f4 4a 3b e4 79 f8 98 23 ac 9f 11 91 fa b7 11 26 f6","github.com/coreos/etcd/clientv3.KV":"03 55 dc 9d 49 95 06 33 f3 03 cf d7 5b 47 3a 96 69 93 a2 de","github.com/coreos/etcd/clientv3.Lease":"1a b5 94 5c c5 bb d0 78 62 3e 7f 6d d2 74 aa ae 95 70 93 09","github.com/coreos/etcd/clientv3.Txn":"ed f4 4b 6f bf c7 79 91 fe a6 b9 5e 6d 1e 34 a0 6a 10 4d 51"}
{"github.com/Scalingo/link/api.Client":"56 fe 67 7b 99 0f 7b 6c cb 88 8c 20 a2 a1 84 26 6c 5a b1 f8","github.com/Scalingo/link/healthcheck.Checker":"1d f8 80 35 ac c7 d3 08 fd 14 96 d6 26 bd cb fd cf 5f af bc","github.com/Scalingo/link/locker.Locker":"a5 24 96 0f 1b f5 df b8 d8 dd 15 83 a1 d2 b2 d3 53 fa 25 0d","github.com/Scalingo/link/models.Storage":"6c 64 ff a2 f6 e0 72 82 d9 cd 56 6a 64 4b 8d 96 5d fe cd 7e","github.com/Scalingo/link/network.ARP":"20 bb b8 da 57 d8 84 21 24 36 cc 40 34 be f6 c3 e6 e9 f9 78","github.com/Scalingo/link/network.NetworkInterface":"02 61 47 58 85 b3 ce f2 ee 69 f8 58 4b ca cd eb 5b ed f9 3c","github.com/Scalingo/link/scheduler.Scheduler":"63 e6 1d f4 4a 3b e4 79 f8 98 23 ac 9f 11 91 fa b7 11 26 f6","github.com/coreos/etcd/clientv3.KV":"b5 dc 10 4e dc 95 f2 cf 0a 6c e7 c5 ac 0a 47 5f 60 44 31 40","github.com/coreos/etcd/clientv3.Lease":"f2 a5 ea a9 0e 16 01 d7 6c 2b 05 1c f1 e6 5b 1d a5 a2 87 27","github.com/coreos/etcd/clientv3.Txn":"2b d8 86 0c 62 87 e9 d4 e5 71 78 81 ef 89 ec 5a e8 30 43 e1"}
10 changes: 0 additions & 10 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
)

type NetworkInterface interface {
HasIP(string) (bool, error)
EnsureIP(string) error
RemoveIP(string) error
}
Expand All @@ -30,15 +29,6 @@ func NewNetworkInterfaceFromName(name string) (networkInterface, error) {
}, nil
}

func (i networkInterface) HasIP(ip string) (bool, error) {
addr, err := netlink.ParseAddr(ip)
if err != nil {
return false, errors.Wrapf(err, "invalid IP: %s", ip)
}

return i.hasIP(addr)
}

func (i networkInterface) hasIP(addr *netlink.Addr) (bool, error) {
addrs, err := netlink.AddrList(i.link, netlink.FAMILY_ALL)
if err != nil {
Expand Down
13 changes: 0 additions & 13 deletions network/networkmock/networkinterface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2afeabb

Please sign in to comment.