Skip to content

Commit 149d0ad

Browse files
authored
Merge pull request #35 from kubernetes-incubator/o1
Separate package util into config and watch package
2 parents 44395d4 + 26ac2c4 commit 149d0ad

File tree

11 files changed

+38
-22
lines changed

11 files changed

+38
-22
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ list all pods:
1111
```python
1212
import os
1313

14-
from kubernetes import client, util
14+
from kubernetes import client, config
1515

1616
# Configs can be set in Configuration class directly or using helper utility
17-
util.load_kube_config(os.environ["HOME"] + '/.kube/config')
17+
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
1818

1919
v1=client.CoreV1Api()
2020
print("Listing pods with their IPs:")
@@ -28,19 +28,19 @@ watch on namespace object:
2828
```python
2929
import os
3030

31-
from kubernetes import client, util
31+
from kubernetes import client, config, watch
3232

3333
# Configs can be set in Configuration class directly or using helper utility
34-
util.load_kube_config(os.environ["HOME"] + '/.kube/config')
34+
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
3535

3636
v1 = client.CoreV1Api()
3737
count = 10
38-
watch = util.Watch()
39-
for event in watch.stream(v1.list_namespace, _request_timeout=60):
38+
w = watch.Watch()
39+
for event in w.stream(v1.list_namespace, _request_timeout=60):
4040
print("Event: %s %s" % (event['type'], event['object'].metadata.name))
4141
count -= 1
4242
if not count:
43-
watch.stop()
43+
w.stop()
4444

4545
print("Ended.")
4646
```

examples/example1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
import os
1616

17-
from kubernetes import client, util
17+
from kubernetes import client, config
1818

1919

2020
def main():
2121
# Configs can be set in Configuration class directly or using helper
2222
# utility
23-
util.load_kube_config(os.environ["HOME"] + '/.kube/config')
23+
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
2424

2525
v1 = client.CoreV1Api()
2626
print("Listing pods with their IPs:")

examples/example2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@
1414

1515
import os
1616

17-
from kubernetes import client, util
17+
from kubernetes import client, config, watch
1818

1919

2020
def main():
2121
# Configs can be set in Configuration class directly or using helper
2222
# utility
23-
util.load_kube_config(os.environ["HOME"] + '/.kube/config')
23+
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
2424

2525
v1 = client.CoreV1Api()
2626
count = 10
27-
watch = util.Watch()
28-
for event in watch.stream(v1.list_namespace, timeout_seconds=10):
27+
w = watch.Watch()
28+
for event in w.stream(v1.list_namespace, timeout_seconds=10):
2929
print("Event: %s %s" % (event['type'], event['object'].metadata.name))
3030
count -= 1
3131
if not count:
32-
watch.stop()
32+
w.stop()
3333

3434
print("Ended.")
3535

examples/example3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
import os
1616

17-
from kubernetes import client, util
17+
from kubernetes import client, config
1818

1919

2020
def main():
2121
# Configs can be set in Configuration class directly or using helper
2222
# utility
23-
util.load_kube_config(os.environ["HOME"] + '/.kube/config')
23+
config.load_kube_config(os.environ["HOME"] + '/.kube/config')
2424

2525
print("Supported APIs (* is preferred version):")
2626
print("%-20s %s" %

kubernetes/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# limitations under the License.
1414

1515
import kubernetes.client
16-
import kubernetes.util
16+
import kubernetes.config
17+
import kubernetes.watch

kubernetes/util/__init__.py renamed to kubernetes/config/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@
1313
# limitations under the License.
1414

1515
from .kube_config import load_kube_config
16-
from .watch import Watch
File renamed without changes.

kubernetes/watch/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2016 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from .watch import Watch

kubernetes/util/watch.py renamed to kubernetes/watch/watch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def stream(self, func, *args, **kwargs):
9898
'object' value will be the same as 'raw_object'.
9999
100100
Example:
101-
v1 = client.CoreV1Api()
102-
watch = util.Watch()
101+
v1 = kubernetes.client.CoreV1Api()
102+
watch = kubernetes.watch.Watch()
103103
for e in watch.stream(v1.list_namespace, resource_version=1127):
104104
type = e['type']
105105
object = e['object'] # object is one of type return_type
File renamed without changes.

0 commit comments

Comments
 (0)