Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyler-W committed Jan 27, 2025
2 parents 5d3cd60 + 416e2f6 commit e4d3576
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
IMG_NAMESPACE = flag5
IMG_NAME = clustersecret
IMG_FQNAME = $(IMG_NAMESPACE)/$(IMG_NAME)
IMG_VERSION = 0.0.12
IMG_VERSION = 0.0.13

.PHONY: container push clean
all: container
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ClusterSecret
![CI](https://github.com/zakkg3/ClusterSecret/workflows/CI/badge.svg) [![Docker Repository on Quay](https://quay.io/repository/clustersecret/clustersecret/status "Docker Repository on Quay")](https://quay.io/repository/clustersecret/clustersecret) [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/clutersecret)](https://artifacthub.io/packages/search?repo=clutersecret)[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4283/badge)](https://bestpractices.coreinfrastructure.org/projects/4283) [![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![Kubernetes - v1.24.15 | v1.25.11 | v1.26.6 | v1.27.3](https://img.shields.io/static/v1?label=Kubernetes&message=v1.24.15+|+v1.25.11+|+v1.26.6+|+v1.27.3&color=2ea44f)](https://)
![CI](https://github.com/zakkg3/ClusterSecret/workflows/CI/badge.svg) [![Docker Repository on Quay](https://quay.io/repository/clustersecret/clustersecret/status "Docker Repository on Quay")](https://quay.io/repository/clustersecret/clustersecret) [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/clustersecret)](https://artifacthub.io/packages/search?repo=clutersecret)[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4283/badge)](https://bestpractices.coreinfrastructure.org/projects/4283) [![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![Kubernetes - v1.24.15 | v1.25.11 | v1.26.6 | v1.27.3](https://img.shields.io/static/v1?label=Kubernetes&message=v1.24.15+|+v1.25.11+|+v1.26.6+|+v1.27.3&color=2ea44f)](https://)
---

[*clustersecret.com*](https://clustersecret.com/)
Expand Down
4 changes: 2 additions & 2 deletions charts/cluster-secret/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: cluster-secret
description: ClusterSecret Operator
kubeVersion: '>= 1.25.0-0'
type: application
version: 0.4.5
version: 0.5.0
icon: https://clustersecret.com/assets/csninjasmall.png
sources:
- https://github.com/zakkg3/ClusterSecret
appVersion: "0.0.12"
appVersion: "0.0.13"
maintainers:
- email: [email protected]
name: zakkg3
1 change: 1 addition & 0 deletions charts/cluster-secret/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ spec:
{{- end }}
containers:
- env:
{{- .Values.env | toYaml | nindent 8 }}
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ .Values.kubernetesClusterDomain }}
- name: CLUSTER_SECRET_VERSION
Expand Down
4 changes: 4 additions & 0 deletions charts/cluster-secret/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ image:
# It can also be replaced, just set value to true.
replace_existing: 'false'

env:
- name: BLOCKED_LABELS
value: app.kubernetes.io # a comma (,) separated list

kubernetesClusterDomain: cluster.local

nodeSelector: {}
Expand Down
5 changes: 3 additions & 2 deletions src/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

CLUSTER_SECRET_LABEL = "clustersecret.io"

BLACK_LISTED_ANNOTATIONS = ["kopf.zalando.org", "kubectl.kubernetes.io"]
BLACK_LISTED_LABELS = ["app.kubernetes.io"]
BLOCKED_ANNOTATIONS = ["kopf.zalando.org", "kubectl.kubernetes.io"]

BLOCKED_LABELS = ["app.kubernetes.io"]
8 changes: 4 additions & 4 deletions src/kubernetes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from kubernetes.client import CoreV1Api, CustomObjectsApi, exceptions, V1ObjectMeta, V1OwnerReference, rest, V1Secret

from models import BaseClusterSecret
from os_utils import get_replace_existing, get_version
from consts import VERSION_ANNOTATION, BLACK_LISTED_ANNOTATIONS, BLACK_LISTED_LABELS, CLUSTER_SECRET_LABEL
from os_utils import get_blocked_labels, get_replace_existing, get_version
from consts import VERSION_ANNOTATION, BLOCKED_ANNOTATIONS, CLUSTER_SECRET_LABEL


def patch_clustersecret_status(
Expand Down Expand Up @@ -371,8 +371,8 @@ def filter_dict(
uid = csec_body.get('metadata', {}).get('uid', None)
)

_annotations = filter_dict(BLACK_LISTED_ANNOTATIONS, base_annotations, annotations)
_labels = filter_dict(BLACK_LISTED_LABELS, base_labels, labels)
_annotations = filter_dict(BLOCKED_ANNOTATIONS, base_annotations, annotations)
_labels = filter_dict(get_blocked_labels(), base_labels, labels)
return V1ObjectMeta(
name=name,
namespace=namespace,
Expand Down
15 changes: 14 additions & 1 deletion src/os_utils.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import os
from functools import cache

from consts import BLOCKED_LABELS


@cache
def get_version() -> str:
"""
Wrapper for CLUSTER_SECRET_VERSION variable environment
"""
return os.getenv('CLUSTER_SECRET_VERSION', '0')


@cache
def get_replace_existing() -> bool:

replace_existing = os.getenv('REPLACE_EXISTING', 'false')
return replace_existing.lower() == 'true'


@cache
def get_blocked_labels() -> list[str]:
if blocked_labels := os.getenv('BLOCKED_LABELS'):
return [label.strip() for label in blocked_labels.split(',')]

return BLOCKED_LABELS


@cache
def in_cluster() -> bool:
"""
Whether we are running in cluster (on the pod) or outside (debug mode.)
Expand Down
18 changes: 9 additions & 9 deletions src/tests/test_kubernetes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

from kubernetes.client import V1ObjectMeta

from consts import CREATE_BY_ANNOTATION, LAST_SYNC_ANNOTATION, VERSION_ANNOTATION, BLACK_LISTED_ANNOTATIONS, \
BLACK_LISTED_LABELS, CREATE_BY_AUTHOR, CLUSTER_SECRET_LABEL
from consts import CREATE_BY_ANNOTATION, LAST_SYNC_ANNOTATION, VERSION_ANNOTATION, BLOCKED_ANNOTATIONS, \
CREATE_BY_AUTHOR, CLUSTER_SECRET_LABEL
from kubernetes_utils import get_ns_list, create_secret_metadata
from os_utils import get_version
from os_utils import get_version, get_blocked_labels

USER_NAMESPACE_COUNT = 10
initial_namespaces = ['default', 'kube-node-lease', 'kube-public', 'kube-system']
Expand Down Expand Up @@ -99,9 +99,9 @@ def test_create_secret_metadata(self) -> None:
(LAST_SYNC_ANNOTATION, is_iso_format)
]

attributes_black_lists = dict(
labels=BLACK_LISTED_LABELS,
annotations=BLACK_LISTED_ANNOTATIONS,
attributes_blocked_lists = dict(
labels=get_blocked_labels(),
annotations=BLOCKED_ANNOTATIONS,
)

test_cases: list[Tuple[dict[str, str], dict[str, str]]] = [
Expand Down Expand Up @@ -140,15 +140,15 @@ def test_create_secret_metadata(self) -> None:

self.assertIsInstance(obj=subject, cls=V1ObjectMeta, msg='returned value has correct type')

for attribute, black_list in attributes_black_lists.items():
for attribute, blocked_list in attributes_blocked_lists.items():
attribute_object = subject.__getattribute__(attribute)
self.assertIsNotNone(obj=attribute_object, msg=f'attribute "{attribute}" is not None')

for key in attribute_object.keys():
self.assertIsInstance(obj=key, cls=str, msg=f'the {attribute} key is a string')
for black_listed_label_prefix in black_list:
for blocked_listed_label_prefix in blocked_list:
self.assertFalse(
expr=key.startswith(black_listed_label_prefix),
expr=key.startswith(blocked_listed_label_prefix),
msg=f'{attribute} key does not match black listed prefix'
)

Expand Down

0 comments on commit e4d3576

Please sign in to comment.