mirror of
https://github.com/kelseyhightower/kubernetes-the-hard-way.git
synced 2025-12-14 16:58:58 +03:00
Refresh and add Apple Silicon (#338)
* Delete CKA stuff. It's covered in CKA repo * Rename nodes * Cluster up again * Update issue template * Update README * Begin rearranging docs * Update links * Initial mac instructions * iterm2 image * update ssh-copy-id to be cross platform * remove vagrant specific * Apple scripts WIP * Add var for architecture * order input files * Apple build working! * auto-locate docs * install sshpass * Set execute bit * apple done! * install sshpass * edits * Corrections * kube version output * Adjustments * Adjustments
This commit is contained in:
@@ -24,17 +24,14 @@ class State(Enum):
|
||||
NONE = 0
|
||||
SCRIPT = 1
|
||||
|
||||
parser = argparse.ArgumentParser(description="Extract scripts from markdown")
|
||||
parser.add_argument("--path", '-p', required=True, help='Path to markdown docs')
|
||||
args = parser.parse_args()
|
||||
|
||||
docs_path = os.path.abspath(args.path)
|
||||
this_file_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
docs_path = os.path.abspath(os.path.join(this_file_dir, '../docs'))
|
||||
|
||||
if not os.path.isdir(docs_path):
|
||||
print (f'Invalid path: {docs_path}')
|
||||
print (f'Expected "docs" at: {docs_path}')
|
||||
exit(1)
|
||||
|
||||
qs_path = os.path.abspath(os.path.join(docs_path, '../quick-steps'))
|
||||
qs_path = os.path.abspath(os.path.join(this_file_dir, '../quick-steps'))
|
||||
|
||||
if not os.path.isdir(qs_path):
|
||||
os.makedirs(qs_path)
|
||||
@@ -43,6 +40,8 @@ newline = chr(10) # In case running on Windows (plus writing files as bina
|
||||
file_number_rx = re.compile(r'^(?P<number>\d+)')
|
||||
comment_rx = re.compile(r'^\[//\]:\s\#\s\((?P<token>\w+):(?P<value>.*)\)\s*$')
|
||||
choice_rx = re.compile(r'^\s*-+\s+OR\s+-+')
|
||||
ssh_copy_id_rx = re.compile(r'(?P<indent>\s*)ssh-copy-id.*@(?P<host>\w+)')
|
||||
script_begin_rx = re.compile(r'^(?P<indent>\s*)```bash')
|
||||
script_begin = '```bash'
|
||||
script_end = '```'
|
||||
script_open = ('{' + newline).encode('utf-8')
|
||||
@@ -60,8 +59,12 @@ def write_script(filename: str, script: list):
|
||||
|
||||
output_file_no = 1
|
||||
script = []
|
||||
indent = 0
|
||||
output_file = None
|
||||
for doc in glob.glob(os.path.join(docs_path, '*.md')):
|
||||
for doc in sorted(glob.glob(os.path.join(docs_path, '*.md'))):
|
||||
if 'e2e-tests' in doc:
|
||||
# Skip this for scripted install
|
||||
continue
|
||||
print(doc)
|
||||
state = State.NONE
|
||||
ignore_next_script = False
|
||||
@@ -128,12 +131,14 @@ for doc in glob.glob(os.path.join(docs_path, '*.md')):
|
||||
'#######################################################################',
|
||||
newline
|
||||
])
|
||||
elif line == script_begin:
|
||||
elif script_begin_rx.match(line):
|
||||
m = script_begin_rx.match(line)
|
||||
indent = len(m['indent'])
|
||||
state = State.SCRIPT
|
||||
elif choice_rx.match(line):
|
||||
ignore_next_script = True
|
||||
elif state == State.SCRIPT:
|
||||
if line == script_end:
|
||||
if line == (' ' * indent) + script_end:
|
||||
state = State.NONE
|
||||
script.append(newline)
|
||||
ignore_next_script = False
|
||||
@@ -141,8 +146,12 @@ for doc in glob.glob(os.path.join(docs_path, '*.md')):
|
||||
# script.append('}')
|
||||
# script.append(line)
|
||||
# script.append('{')
|
||||
elif not (ignore_next_script or line == '{' or line == '}'):
|
||||
script.append(line)
|
||||
elif not (ignore_next_script or line == (' ' * indent) + '{' or line == (' ' * indent) + '}'):
|
||||
m = ssh_copy_id_rx.match(line)
|
||||
if m:
|
||||
script.append(f'{m["indent"]}echo $(whoami) | sshpass ssh-copy-id -f -o StrictHostKeyChecking=no $(whoami)@{m["host"]}')
|
||||
else:
|
||||
script.append(line[indent:])
|
||||
if script:
|
||||
# fns = '-'.join(file_nos[1:])
|
||||
output_file = os.path.join(qs_path, f'{output_file_no}-{current_host}.sh')
|
||||
|
||||
Reference in New Issue
Block a user