move New* functions beneath the types they construct

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
Steffen Vogel
2023-01-09 22:15:19 +01:00
parent 8a4a0919d4
commit 46c6be91ef
6 changed files with 127 additions and 123 deletions

View File

@@ -42,16 +42,6 @@ type WireGuardInterface struct {
Agent *Agent
}
func (i *WireGuardInterface) Apply(a *Agent) {
if i.Agent != nil {
panic("can not assign interface to more than a single agent")
}
i.Agent = a
a.WireGuardInterfaces = append(a.WireGuardInterfaces, i)
}
func NewWireGuardInterface(name string) (*WireGuardInterface, error) {
lp := wg.DefaultPort
sk, err := crypto.GeneratePrivateKey()
@@ -70,6 +60,16 @@ func NewWireGuardInterface(name string) (*WireGuardInterface, error) {
}, nil
}
func (i *WireGuardInterface) Apply(a *Agent) {
if i.Agent != nil {
panic("can not assign interface to more than a single agent")
}
i.Agent = a
a.WireGuardInterfaces = append(a.WireGuardInterfaces, i)
}
func (i *WireGuardInterface) Create() error {
if i.WriteConfigFile {
if err := i.WriteConfig(); err != nil {