From 72c4a75682f74457ceac98c83fbbae17d4a9a6d0 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Wed, 15 Jan 2020 12:18:39 +0100 Subject: [PATCH] Remove Result.String Closes #581 --- pkg/types/020/types.go | 14 -------------- pkg/types/current/types.go | 17 ----------------- pkg/types/types.go | 3 --- 3 files changed, 34 deletions(-) diff --git a/pkg/types/020/types.go b/pkg/types/020/types.go index 53256167f..36f31678a 100644 --- a/pkg/types/020/types.go +++ b/pkg/types/020/types.go @@ -86,20 +86,6 @@ func (r *Result) PrintTo(writer io.Writer) error { return err } -// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where -// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the -// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string. -func (r *Result) String() string { - var str string - if r.IP4 != nil { - str = fmt.Sprintf("IP4:%+v, ", *r.IP4) - } - if r.IP6 != nil { - str += fmt.Sprintf("IP6:%+v, ", *r.IP6) - } - return fmt.Sprintf("%sDNS:%+v", str, r.DNS) -} - // IPConfig contains values necessary to configure an interface type IPConfig struct { IP net.IPNet diff --git a/pkg/types/current/types.go b/pkg/types/current/types.go index 7267a2e6d..754cc6e72 100644 --- a/pkg/types/current/types.go +++ b/pkg/types/current/types.go @@ -207,23 +207,6 @@ func (r *Result) PrintTo(writer io.Writer) error { return err } -// String returns a formatted string in the form of "[Interfaces: $1,][ IP: $2,] DNS: $3" where -// $1 represents the receiver's Interfaces, $2 represents the receiver's IP addresses and $3 the -// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string. -func (r *Result) String() string { - var str string - if len(r.Interfaces) > 0 { - str += fmt.Sprintf("Interfaces:%+v, ", r.Interfaces) - } - if len(r.IPs) > 0 { - str += fmt.Sprintf("IP:%+v, ", r.IPs) - } - if len(r.Routes) > 0 { - str += fmt.Sprintf("Routes:%+v, ", r.Routes) - } - return fmt.Sprintf("%sDNS:%+v", str, r.DNS) -} - // Convert this old version result to the current CNI version result func (r *Result) Convert() (*Result, error) { return r, nil diff --git a/pkg/types/types.go b/pkg/types/types.go index 3e185c1ce..3fa757a5d 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -100,9 +100,6 @@ type Result interface { // Prints the result in JSON format to provided writer PrintTo(writer io.Writer) error - - // Returns a JSON string representation of the result - String() string } func PrintResult(result Result, version string) error {