Skip to content

Commit

Permalink
Giant batch of ruff reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Aug 16, 2024
1 parent ed8e1d7 commit feb08d8
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/actions/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tempfile

import ops

from kubectl import kubectl


Expand Down
3 changes: 2 additions & 1 deletion src/actions/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import tempfile

import ops
from kubectl import kubectl
from yaml import safe_dump, safe_load

from kubectl import kubectl

os.environ["PATH"] += os.pathsep + os.path.join(os.sep, "snap", "bin")


Expand Down
3 changes: 2 additions & 1 deletion src/actions/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import re

import ops
from auth_webhook import create_token, delete_token, get_secrets
from charms import kubernetes_snaps

from auth_webhook import create_token, delete_token, get_secrets


def protect_resources(name: str, event: ops.ActionEvent) -> bool:
"""Do not allow the action to operate on names used by Charmed Kubernetes."""
Expand Down
3 changes: 2 additions & 1 deletion src/auth_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
import charms.contextual_status as status
import yaml
from jinja2 import Environment, FileSystemLoader
from kubectl import kubectl, kubectl_get
from ops import MaintenanceStatus

from kubectl import kubectl, kubectl_get

auth_secret_ns = "kube-system"
auth_secret_type = "juju.is/token-auth"
auth_webhook_root = "/root/cdk/auth-webhook"
Expand Down
3 changes: 2 additions & 1 deletion src/cdk_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import charms.contextual_status as status
import tenacity
from kubectl import ROOT_KUBECONFIG, get_service_ip, kubectl, kubectl_get
from ops import BlockedStatus

from kubectl import ROOT_KUBECONFIG, get_service_ip, kubectl, kubectl_get

kubeconfig_dir = "/root/snap/cdk-addons/common"
kubeconfig_path = f"{kubeconfig_dir}/kubeconfig"
log = logging.getLogger(__name__)
Expand Down
23 changes: 12 additions & 11 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@
from subprocess import CalledProcessError
from typing import Callable

import actions.general
import actions.namespace
import actions.restart
import actions.upgrade
import actions.users
import auth_webhook
import charms.contextual_status as status
import leader_data
import ops
import yaml
from cdk_addons import CdkAddons
from charms import kubernetes_snaps
from charms.grafana_agent.v0.cos_agent import COSAgentProvider
from charms.interface_container_runtime import ContainerRuntimeProvides
Expand All @@ -36,16 +28,25 @@
from charms.kubernetes_libs.v0.etcd import EtcdReactiveRequires
from charms.node_base import LabelMaker
from charms.reconciler import Reconciler
from loadbalancer_interface import LBProvider
from ops.interface_kube_control import KubeControlProvides
from ops.interface_tls_certificates import CertificatesRequires

import actions.general
import actions.namespace
import actions.restart
import actions.upgrade
import actions.users
import auth_webhook
import leader_data
from cdk_addons import CdkAddons
from cloud_integration import CloudIntegration
from cos_integration import COSIntegration
from encryption_at_rest import EncryptionAtRest
from hacluster import HACluster
from k8s_api_endpoints import K8sApiEndpoints
from k8s_kube_system import get_kube_system_pods_not_running
from kubectl import ROOT_KUBECONFIG, kubectl
from loadbalancer_interface import LBProvider
from ops.interface_kube_control import KubeControlProvides
from ops.interface_tls_certificates import CertificatesRequires

log = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions src/encryption/vault_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import hvac
import ops
import requests

from encryption import reactive

log = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions src/encryption/vaultlocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import charms.operator_libs_linux.v0.apt as apt
import ops

from encryption.fstab import Fstab
from encryption.vault_kv import VaultKV, VaultNotReadyError

Expand Down
3 changes: 2 additions & 1 deletion src/encryption_at_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import charms.contextual_status as status
import ops
import yaml
from auth_webhook import token_generator
from charms import kubernetes_snaps

from auth_webhook import token_generator
from encryption.vault_kv import VaultKV, VaultNotReadyError
from encryption.vaultlocker import VaultLocker, VaultLockerError

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_actions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from unittest import mock

import actions.restart
import actions.upgrade
import charms.contextual_status as status
import ops
import pytest

import actions.restart
import actions.upgrade
from charm import KubernetesControlPlaneCharm


Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import ops
import ops.testing
import pytest
from charm import KubernetesControlPlaneCharm
from ops import ActiveStatus

from charm import KubernetesControlPlaneCharm


@pytest.fixture
def harness():
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_cloud_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ops
import pytest

from charm import KubernetesControlPlaneCharm


Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_kubectl.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import subprocess
import unittest.mock as mock

import kubectl
import pytest
import tenacity

import kubectl


@pytest.fixture(params=["/root/.kube/config", "/home/ubuntu/config"])
def kubeconfig(request):
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_vault_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ops
import ops.testing
import pytest

from charm import KubernetesControlPlaneCharm
from encryption.reactive import retrieve_secret_id
from encryption.vault_kv import VaultNotReadyError
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_vaultlocker.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from pathlib import Path
from unittest import mock

import encryption.vaultlocker
import ops
import ops.testing
import pytest

import encryption.vaultlocker
from charm import KubernetesControlPlaneCharm


Expand Down
5 changes: 1 addition & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,23 @@ pass_env =
[testenv:format]
description = Apply coding style standards to code
deps =
black
ruff
commands =
black {[vars]all_path}
ruff format {[vars]all_path}
ruff check --fix --select I {[vars]all_path}

[testenv:lint]
description = Check code against coding style standards
deps =
black
ruff
tomli
codespell
commands =
# if this charm owns a lib, uncomment "lib_path" variable
# and uncomment the following line
# codespell {[vars]lib_path}
codespell {tox_root}
ruff check {[vars]all_path}
black --check --diff {[vars]all_path}

[testenv:unit]
description = Run unit tests
Expand Down

0 comments on commit feb08d8

Please sign in to comment.