Skip to content

Commit

Permalink
Enforce double quotes with Black (canonical#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
joedborg authored Feb 4, 2021
1 parent be208dc commit 77d9c88
Show file tree
Hide file tree
Showing 30 changed files with 614 additions and 615 deletions.
4 changes: 2 additions & 2 deletions installer/cli/microk8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def _get_microk8s_commands() -> List:
if c.decode().startswith("microk8s.")
]
complete = mk8s
if 'dashboard-proxy' not in mk8s:
complete += ['dashboard-proxy']
if "dashboard-proxy" not in mk8s:
complete += ["dashboard-proxy"]
complete.sort()
return complete
else:
Expand Down
18 changes: 9 additions & 9 deletions installer/common/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _free_space() -> int:
:return: Integer free space
"""
return disk_usage(realpath('/')).free
return disk_usage(realpath("/")).free

def is_enough_space(self) -> bool:
"""
Expand Down Expand Up @@ -118,12 +118,12 @@ def check_hyperv() -> bool:
"""
try:
out = subprocess.check_output(
['DISM', '/Online', '/Get-FeatureInfo', '/FeatureName:Microsoft-Hyper-V']
["DISM", "/Online", "/Get-FeatureInfo", "/FeatureName:Microsoft-Hyper-V"]
)
except subprocess.CalledProcessError:
return False

if 'State : Disabled' in out.decode():
if "State : Disabled" in out.decode():
return False

return True
Expand All @@ -138,12 +138,12 @@ def enable_hyperv() -> None:
try:
subprocess.check_call(
[
'DISM',
'/Online',
'/Enable-Feature',
'/All',
'/NoRestart',
'/FeatureName:Microsoft-Hyper-V',
"DISM",
"/Online",
"/Enable-Feature",
"/All",
"/NoRestart",
"/FeatureName:Microsoft-Hyper-V",
]
)
except subprocess.CalledProcessError as e:
Expand Down
48 changes: 24 additions & 24 deletions installer/common/definitions.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
MAX_CHARACTERS_WRAP: int = 120
command_descriptions = {
'add-node': "Adds a node to a cluster",
'ambassador': "Ambassador API Gateway and Ingress",
'cilium': "The cilium client",
'config': "Print the kubeconfig",
'ctr': "The containerd client",
'dashboard-proxy': "Enable the Kubernetes dashboard and proxy to host",
'dbctl': "Backup and restore the Kubernetes datastore",
'disable': "Disables running add-ons",
'enable': "Enables useful add-ons",
'helm': "The helm client",
'helm3': "The helm3 client",
'inspect': "Checks the cluster and gathers logs",
'istioctl': "The istio client",
'join': "Joins this instance as a node to a cluster",
'juju': "The Juju client",
'kubectl': "The kubernetes client",
'leave': "Disconnects this node from any cluster it has joined",
'linkerd': "The linkerd client",
'refresh-certs': "Refresh the CA certificates in this deployment",
'remove-node': "Removes a node from the cluster",
'reset': "Cleans the cluster from all workloads",
'start': "Starts the kubernetes cluster",
'status': "Displays the status of the cluster",
'stop': "Stops the kubernetes cluster",
"add-node": "Adds a node to a cluster",
"ambassador": "Ambassador API Gateway and Ingress",
"cilium": "The cilium client",
"config": "Print the kubeconfig",
"ctr": "The containerd client",
"dashboard-proxy": "Enable the Kubernetes dashboard and proxy to host",
"dbctl": "Backup and restore the Kubernetes datastore",
"disable": "Disables running add-ons",
"enable": "Enables useful add-ons",
"helm": "The helm client",
"helm3": "The helm3 client",
"inspect": "Checks the cluster and gathers logs",
"istioctl": "The istio client",
"join": "Joins this instance as a node to a cluster",
"juju": "The Juju client",
"kubectl": "The kubernetes client",
"leave": "Disconnects this node from any cluster it has joined",
"linkerd": "The linkerd client",
"refresh-certs": "Refresh the CA certificates in this deployment",
"remove-node": "Removes a node from the cluster",
"reset": "Cleans the cluster from all workloads",
"start": "Starts the kubernetes cluster",
"status": "Displays the status of the cluster",
"stop": "Stops the kubernetes cluster",
}
DEFAULT_CORES: int = 2
DEFAULT_MEMORY: int = 4
Expand Down
4 changes: 2 additions & 2 deletions installer/common/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def get_kubectl_directory() -> str:
def get_kubeconfig_path():
"""Return a MicroK8s specific kubeconfig path."""
if sys.platform == "win32":
return os.path.join(os.environ.get('LocalAppData'), "MicroK8s", "config")
return os.path.join(os.environ.get("LocalAppData"), "MicroK8s", "config")
else:
return os.path.join(os.path.expanduser('~'), ".microk8s", "config")
return os.path.join(os.path.expanduser("~"), ".microk8s", "config")


def clear_kubeconfig():
Expand Down
2 changes: 1 addition & 1 deletion installer/microk8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

from cli import microk8s

if __name__ == '__main__':
if __name__ == "__main__":
microk8s.cli()
36 changes: 18 additions & 18 deletions installer/setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
from setuptools import setup

setup(
name='microk8s',
version='1.0.2',
url='https://github.com/ubuntu/microk8s',
license='Apache-2.0',
author='Joe Borg',
author_email='joseph.borg@canonical.com',
description='MicroK8s is a small, fast, single-package Kubernetes for developers, IoT and edge',
packages=['cli', 'common', 'vm_providers', 'vm_providers._multipass', 'vm_providers.repo'],
name="microk8s",
version="1.0.2",
url="https://github.com/ubuntu/microk8s",
license="Apache-2.0",
author="Joe Borg",
author_email="joseph.borg@canonical.com",
description="MicroK8s is a small, fast, single-package Kubernetes for developers, IoT and edge",
packages=["cli", "common", "vm_providers", "vm_providers._multipass", "vm_providers.repo"],
install_requires=[
'click~=7.0',
'progressbar33==2.4',
'requests==2.20.0',
'requests_unixsocket==0.1.5',
'simplejson==3.8.2',
'toml==0.10.0',
'urllib3==1.24.2',
"click~=7.0",
"progressbar33==2.4",
"requests==2.20.0",
"requests_unixsocket==0.1.5",
"simplejson==3.8.2",
"toml==0.10.0",
"urllib3==1.24.2",
],
platforms='any',
platforms="any",
entry_points={
'console_scripts': [
'microk8s=cli.microk8s:cli',
"console_scripts": [
"microk8s=cli.microk8s:cli",
]
},
)
10 changes: 5 additions & 5 deletions installer/tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

class TestClass:
@pytest.mark.skipif(
platform.system() != 'Linux', reason='Add/remove multipass is available on Linux'
platform.system() != "Linux", reason="Add/remove multipass is available on Linux"
)
@pytest.mark.skipif(os.getuid() != 0, reason='Add/remove multipass is possible to root')
@pytest.mark.skipif(os.getuid() != 0, reason="Add/remove multipass is possible to root")
@mock.patch("sys.stdin.isatty", return_value=True)
def test_install_remove_multipass(self, tty_mock):
"""
Expand All @@ -24,19 +24,19 @@ def test_install_remove_multipass(self, tty_mock):
# making sure we start on a clean machine with multipass
result = runner.invoke(cli, "uninstall")
subprocess.check_call("sudo snap install multipass --classic".split())
assert os.path.isfile('/snap/bin/multipass')
assert os.path.isfile("/snap/bin/multipass")
assert result.exit_code == 0

# making sure we start on a clean machine
result = runner.invoke(cli, "install")
assert result.exit_code == 0
assert os.path.isfile('/snap/bin/multipass')
assert os.path.isfile("/snap/bin/multipass")

result = runner.invoke(cli, "status --wait-ready --timeout=60")
assert result.exit_code == 0

result = runner.invoke(cli, "install")
assert os.path.isfile('/snap/bin/multipass')
assert os.path.isfile("/snap/bin/multipass")
assert result.exit_code == 0

def test_all_cli(self):
Expand Down
2 changes: 1 addition & 1 deletion installer/vm_providers/_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _copy_kubeconfig_to_kubectl(self, specs: Dict):
f.write(kubeconfig)

def _setup_microk8s(self, specs: Dict) -> None:
self.run("snap install microk8s --classic --channel {}".format(specs['channel']).split())
self.run("snap install microk8s --classic --channel {}".format(specs["channel"]).split())
if sys.platform == "win32":
self.run("snap install microk8s-integrator-windows".split())
elif sys.platform == "darwin":
Expand Down
6 changes: 3 additions & 3 deletions installer/vm_providers/_multipass/_multipass.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def run(self, command: Sequence[str], hide_output: bool = False) -> Optional[byt
def _launch(self, specs: Dict) -> None:
image = "18.04"

cpus = "{}".format(specs['cpu'])
mem = "{}G".format(specs['mem'])
disk = "{}G".format(specs['disk'])
cpus = "{}".format(specs["cpu"])
mem = "{}G".format(specs["mem"])
disk = "{}G".format(specs["disk"])

try_for = 10

Expand Down
Loading

0 comments on commit 77d9c88

Please sign in to comment.