From 19fe4d60b1d8521ddfed5bb353d5266ff430eb76 Mon Sep 17 00:00:00 2001 From: Vadim Gedz Date: Mon, 4 Jul 2022 10:48:14 +0300 Subject: [PATCH] fix: NoneType (#11) --- CHANGELOG.md | 4 ++++ pyproject.toml | 2 +- src/kubeseal_auto/cluster.py | 14 +++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afc87d3..9622e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.1] - 2022-07-04 +### Fixed +- TypeError: argument of type 'NoneType' is not iterable in _find_sealed_secrets_controller + ## [0.3.0] - 2022-07-01 ### Added - Support for SealedSecrets controller encryption secret backup diff --git a/pyproject.toml b/pyproject.toml index ec3233d..4094a7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "kubeseal-auto" -version = "0.3.0" +version = "0.3.1" description = "An interactive wrapper for kubeseal binary" authors = ["Vadim Gedz "] license = "MIT" diff --git a/src/kubeseal_auto/cluster.py b/src/kubeseal_auto/cluster.py index 106ac17..7f8d98a 100644 --- a/src/kubeseal_auto/cluster.py +++ b/src/kubeseal_auto/cluster.py @@ -36,11 +36,12 @@ def _find_sealed_secrets_controller() -> dict: expected_label = "app.kubernetes.io/instance" - for deployment in client.AppsV1Api().list_deployment_for_all_namespaces().items: - if ( - expected_label in deployment.metadata.labels - and deployment.metadata.labels[expected_label] == "sealed-secrets" - ): + for deployment in ( + client.AppsV1Api() + .list_deployment_for_all_namespaces(label_selector=expected_label) + .items + ): + if deployment.metadata.labels[expected_label] == "sealed-secrets": name = deployment.metadata.labels[expected_label] namespace = deployment.metadata.namespace click.echo( @@ -48,6 +49,9 @@ def _find_sealed_secrets_controller() -> dict: ) return {"name": name, "namespace": namespace} + click.echo("===> No controller found") + exit(1) + def find_latest_sealed_secrets_controller_certificate(self) -> str: res = client.CoreV1Api().list_namespaced_secret( self.controller.get("namespace")