Allow importing of manifest files with tutorial import script
Unblocks https://github.com/kubernetes/examples/pull/38. Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>reviewable/pr4466/r1^2
parent
17c045577c
commit
fe5f08a28e
|
@ -27,22 +27,26 @@ import urllib.request
|
||||||
SRC_TREE = 'master' # Revision for kubernetes/examples used
|
SRC_TREE = 'master' # Revision for kubernetes/examples used
|
||||||
|
|
||||||
# mapping of tutorials in kubernetes/examples to their
|
# mapping of tutorials in kubernetes/examples to their
|
||||||
# equivalent files here: (examples-path, docs-path, new-title)
|
# equivalent files here: (examples-path, docs-path, new-title, imports-map)
|
||||||
TUTORIALS = [
|
TUTORIALS = [
|
||||||
('guestbook/README.md',
|
('guestbook/README.md',
|
||||||
'./docs/tutorials/stateless-application/guestbook.md',
|
'./docs/tutorials/stateless-application/guestbook.md',
|
||||||
"Example: Deploying PHP Guestbook application with Redis"),
|
"Example: Deploying PHP Guestbook application with Redis", {}),
|
||||||
('mysql-wordpress-pd/README.md',
|
('mysql-wordpress-pd/README.md',
|
||||||
'./docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md',
|
'./docs/tutorials/stateful-application/mysql-wordpress-persistent-volume.md',
|
||||||
"Example: WordPress and MySQL with Persistent Volumes"),
|
"Example: WordPress and MySQL with Persistent Volumes", {}),
|
||||||
('cassandra/README.md',
|
('cassandra/README.md',
|
||||||
'./docs/tutorials/stateful-application/cassandra.md',
|
'./docs/tutorials/stateful-application/cassandra.md',
|
||||||
"Example: Deploying Cassandra with Stateful Sets"),
|
"Example: Deploying Cassandra with Stateful Sets",
|
||||||
|
{
|
||||||
|
"cassandra/cassandra-service.yaml": "./docs/tutorials/stateful-application/cassandra-service.yaml",
|
||||||
|
"cassandra/cassandra-statefulset.yaml": "./docs/tutorials/stateful-application/cassandra-statefulset.yaml",
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for (src_path, dst_path, new_title) in TUTORIALS:
|
for (src_path, dst_path, new_title, imports) in TUTORIALS:
|
||||||
print('Processing {0}'.format(src_path))
|
print('Processing {0}'.format(src_path))
|
||||||
dst_dir = os.path.dirname(dst_path)
|
dst_dir = os.path.dirname(dst_path)
|
||||||
if not os.path.exists(dst_dir):
|
if not os.path.exists(dst_dir):
|
||||||
|
@ -50,6 +54,9 @@ def main():
|
||||||
os.makedirs(dst_dir)
|
os.makedirs(dst_dir)
|
||||||
if os.path.exists(dst_path):
|
if os.path.exists(dst_path):
|
||||||
os.remove(dst_path)
|
os.remove(dst_path)
|
||||||
|
|
||||||
|
imports[src_path] = dst_path # add source itself as import file
|
||||||
|
for src_path, dst_path in imports.items():
|
||||||
src_url = 'https://github.com/kubernetes/examples/raw/{0}/{1}'.format(SRC_TREE, src_path)
|
src_url = 'https://github.com/kubernetes/examples/raw/{0}/{1}'.format(SRC_TREE, src_path)
|
||||||
print('Downloading {0}'.format(src_url))
|
print('Downloading {0}'.format(src_url))
|
||||||
with urllib.request.urlopen(src_url) as resp, \
|
with urllib.request.urlopen(src_url) as resp, \
|
||||||
|
|
Loading…
Reference in New Issue