Skip to content

Commit

Permalink
Remove Result.String
Browse files Browse the repository at this point in the history
Closes #581
  • Loading branch information
jellonek committed Jan 15, 2020
1 parent a09ec7a commit 72c4a75
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
14 changes: 0 additions & 14 deletions pkg/types/020/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions pkg/types/current/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 72c4a75

Please sign in to comment.