Skip to content

Commit

Permalink
fixup! Add kubernetes connector.
Browse files Browse the repository at this point in the history
  • Loading branch information
leahneukirchen committed Aug 21, 2020
1 parent 61893cb commit 82ee186
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pyinfra/api/connectors/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
import click
import six

from pyinfra import local, logger
from pyinfra import logger
from pyinfra.api import QuoteString, StringCommand
from pyinfra.api.exceptions import ConnectError, InventoryError, PyinfraError
from pyinfra.api.exceptions import InventoryError
from pyinfra.api.util import get_file_io, memoize
from pyinfra.progress import progress_spinner

from .local import run_shell_command as run_local_shell_command
from .util import make_unix_command


@memoize
def show_warning():
logger.warning('The @kubernetes connector is in beta!')


def make_names_data(pod=None):
if not pod:
raise InventoryError('No pod provided!')
Expand All @@ -32,12 +33,15 @@ def make_names_data(pod=None):
yield '@kubernetes/{0}/{1}'.format(namespace, pod), \
{'namespace': namespace, 'pod': pod}, ['@kubernetes']


def connect(state, host, for_fact=None):
return True


def disconnect(state, host):
return True


def run_shell_command(
state, host, command,
get_pty=False,
Expand Down Expand Up @@ -82,6 +86,7 @@ def run_shell_command(
return_combined_output=return_combined_output,
)


def put_file(
state, host, filename_or_io, remote_filename,
print_output=False, print_input=False,
Expand Down Expand Up @@ -112,7 +117,7 @@ def put_file(
container = []

kubectl_command = StringCommand(
'kubectl', 'cp',
'kubectl', 'cp',
temp_filename,
'{0}/{1}:{2}'.format(host.host_data['namespace'],
host.host_data['pod'],
Expand Down Expand Up @@ -159,7 +164,7 @@ def get_file(
container = []

kubectl_command = StringCommand(
'kubectl', 'cp',
'kubectl', 'cp',
'{0}/{1}:{2}'.format(host.host_data['namespace'],
host.host_data['pod'],
remote_filename),
Expand Down

0 comments on commit 82ee186

Please sign in to comment.