Skip to content
This repository was archived by the owner on Jun 23, 2022. It is now read-only.

kube-client-agent: Allow empty --ipaddrs flag. #17

Merged
merged 1 commit into from
Apr 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions cmd/kube-client-agent/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ func validateRequestOpts(cmd *cobra.Command, args []string) error {

// runCmdRequest starts an instance of the agent which requests a CSR to be approved by the signer
func runCmdRequest(cmd *cobra.Command, args []string) error {
ipAddrs := strings.Split(requestOpts.ipAddresses, ",")
ips := make([]net.IP, len(ipAddrs))
for i, addr := range ipAddrs {
ip := net.ParseIP(addr)
if ip == nil {
return fmt.Errorf("invalid ipaddress: %s", addr)
var ips []net.IP

// Empty ip addresses are also allowed.
if requestOpts.ipAddresses != "" {
ipAddrs := strings.Split(requestOpts.ipAddresses, ",")
for _, addr := range ipAddrs {
ip := net.ParseIP(addr)
if ip == nil {
return fmt.Errorf("invalid ipaddress: %s", addr)
}
ips = append(ips, ip)
}
ips[i] = ip
}

c := agent.CSRConfig{
Expand Down