Skip to content

Commit

Permalink
Revert "pkg/ipnet: Add DeepCopy and DeepCopyInto for IPNet"
Browse files Browse the repository at this point in the history
This reverts commit 06739c6, #276.

Devan's forking the config in Hive [1], so they no longer need us to
support embedding in Kubernetes objects.

[1]: #256 (comment)
  • Loading branch information
wking committed Sep 20, 2018
1 parent c855611 commit ca6f619
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 59 deletions.
20 changes: 0 additions & 20 deletions pkg/ipnet/ipnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ func (ipnet *IPNet) String() string {
return ipnet.IPNet.String()
}

// DeepCopyInto copies the receiver into out. out must be non-nil.
func (ipnet *IPNet) DeepCopyInto(out *IPNet) {
if ipnet == nil {
*out = *new(IPNet)
} else {
*out = *ipnet
}
return
}

// DeepCopy copies the receiver, creating a new IPNet.
func (ipnet *IPNet) DeepCopy() *IPNet {
if ipnet == nil {
return nil
}
out := new(IPNet)
ipnet.DeepCopyInto(out)
return out
}

// MarshalJSON interface for an IPNet
func (ipnet IPNet) MarshalJSON() (data []byte, err error) {
if reflect.DeepEqual(ipnet.IPNet, emptyIPNet) {
Expand Down
39 changes: 0 additions & 39 deletions pkg/ipnet/ipnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,42 +56,3 @@ func TestUnmarshal(t *testing.T) {
})
}
}

func TestDeepCopy(t *testing.T) {
for _, ipNetIn := range []*IPNet{
{},
{IPNet: net.IPNet{
IP: net.IP{192, 168, 0, 10},
Mask: net.IPv4Mask(255, 255, 255, 0),
}},
} {
t.Run(ipNetIn.String(), func(t *testing.T) {
t.Run("DeepCopyInto", func(t *testing.T) {
ipNetOut := &IPNet{IPNet: net.IPNet{
IP: net.IP{10, 0, 0, 0},
Mask: net.IPv4Mask(255, 0, 0, 0),
}}

ipNetIn.DeepCopyInto(ipNetOut)
if ipNetOut.String() != ipNetIn.String() {
t.Fatalf("%v != %v", ipNetOut, ipNetIn)
}
})

t.Run("DeepCopy", func(t *testing.T) {
ipNetOut := ipNetIn.DeepCopy()
if ipNetOut.String() != ipNetIn.String() {
t.Fatalf("%v != %v", ipNetOut, ipNetIn)
}

ipNetIn.IPNet = net.IPNet{
IP: net.IP{192, 168, 10, 10},
Mask: net.IPv4Mask(255, 255, 255, 255),
}
if ipNetOut.String() == ipNetIn.String() {
t.Fatalf("%v (%q) == %v (%q)", ipNetOut, ipNetOut.String(), ipNetIn, ipNetIn.String())
}
})
})
}
}

0 comments on commit ca6f619

Please sign in to comment.