Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

WIP: Better output for under the hood kubectl apply command #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions kuberender/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ def render(verbose, template_dir, should_apply, context_files, overriden_vars, t


def create_kubectl_apply_pipe():
return subprocess.Popen(['kubectl', 'apply', '-f', '-'],
stdin=subprocess.PIPE, encoding='utf-8')
return subprocess.Popen(
['kubectl', 'apply', '-f', '-'],
stdin=subprocess.PIPE,
stdout=sys.stdout,
stderr=sys.stderr,
encoding='utf-8'
)


def call_kubectl_apply(template):
Expand All @@ -85,9 +90,9 @@ def apply_template(content):
return 1
pipe = create_kubectl_apply_pipe()
str_content = yaml.safe_dump(content, default_flow_style=False, indent=2)
pipe.communicate(str_content)
return pipe.wait()
return all(map(apply_template, yaml.load_all(template.content)))
_stdout, stderr = pipe.communicate(str_content)
return 1 if stderr else 0
return all((apply_template(c) for c in yaml.load_all(template.content)))


def apply_templates(rendered_templates):
Expand Down