Skip to content

Commit e296a69

Browse files
No more IP validation as it is more likely a URL (#1555)
Dropped IP validation as server takes URL.
1 parent d5f5382 commit e296a69

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

config/kube.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import click
2-
import socket
32

43
from utilities_common.cli import AbbreviationGroup, pass_db
54

@@ -21,22 +20,6 @@
2120
KUBE_LABEL_TABLE = "KUBE_LABELS"
2221
KUBE_LABEL_SET_KEY = "SET"
2322

24-
def is_valid_ip4_addr(address):
25-
try:
26-
socket.inet_pton(socket.AF_INET, address)
27-
except socket.error: # not a valid address
28-
return False
29-
return True
30-
31-
32-
def is_valid_ip6_addr(address):
33-
try:
34-
socket.inet_pton(socket.AF_INET6, address)
35-
except socket.error: # not a valid address
36-
return False
37-
return True
38-
39-
4023
def _update_kube_server(db, field, val):
4124
db_data = db.cfgdb.get_entry(KUBE_SERVER_TABLE_NAME, KUBE_SERVER_TABLE_KEY)
4225
def_data = {
@@ -82,9 +65,7 @@ def server():
8265
@pass_db
8366
def ip(db, vip):
8467
"""Specify a kubernetes cluster VIP"""
85-
if vip and not is_valid_ip4_addr(vip) and not is_valid_ip6_addr(vip):
86-
click.echo('Invalid IP address %s' % vip)
87-
sys.exit(1)
68+
8869
_update_kube_server(db, KUBE_SERVER_IP, vip)
8970

9071

tests/kube_test.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,11 @@ def test_set_server_ip(self, get_cmd_module):
125125
self.__check_res(result, "check server IP", show_server_output_1)
126126

127127

128-
def test_set_server_invalid_ip_port(self, get_cmd_module):
128+
def test_set_server_invalid_port(self, get_cmd_module):
129129
(config, show) = get_cmd_module
130130
db = Db()
131131
runner = CliRunner()
132132

133-
# test invalid IP
134-
result = runner.invoke(config.config.commands["kubernetes"].commands["server"], ["ip", "10101011"], obj=db)
135-
assert result.exit_code == 1
136-
137133
# test invalid port
138134
result = runner.invoke(config.config.commands["kubernetes"].commands["server"], ["port", "10101011"], obj=db)
139135
assert result.exit_code == 1

0 commit comments

Comments
 (0)