Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,32 @@ jobs:
exit 1
fi

echo "*****VERIFYING CUSTOM LABELS*****"

# Array of resource types to check for custom labels
resource_types=("deployment" "service" "serviceaccount" "configmap")
failed_resources=()

# Loop through each resource type and verify custom labels
for resource_type in "${resource_types[@]}"; do
echo "Checking $resource_type for custom labels..."
labels=$(kubectl get "$resource_type" -l app.kubernetes.io/name=sm-operator -o jsonpath='{.items[0].metadata.labels}')
echo "$resource_type labels: $labels"

if ! echo "$labels" | grep -q "test-label"; then
echo "::error::Custom label 'test-label' not found on $resource_type."
failed_resources+=("$resource_type")
fi
done

# Exit if any resources failed the check
if [ ${#failed_resources[@]} -gt 0 ]; then
echo "::error::Custom labels verification failed for: ${failed_resources[*]}"
exit 1
fi

echo "Custom labels verified successfully on all resources!"

echo "*****CREATING AUTH SECRET*****"
kubectl create secret generic bw-auth-token -n bitwarden --from-literal=token="$AUTH_TOKEN"
echo "*****CREATING BW SECRET*****"
Expand Down
5 changes: 5 additions & 0 deletions charts/sm-operator/ci/test-values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Custom labels to be applied to all resources created by the operator
# These labels are used in CI testing to verify the custom label feature works correctly
commonLabels:
test-label: test-value

settings:
# How often the secrets synchronize in seconds. Minimum value is 180.
bwSecretsManagerRefreshInterval: 300
Expand Down
3 changes: 3 additions & 0 deletions charts/sm-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ helm.sh/chart: {{ include "sm-operator.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.commonLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Expand Down
7 changes: 7 additions & 0 deletions charts/sm-operator/values.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"commonLabels": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"default": {}
},
"containers": {
"properties": {
"manager": {
Expand Down
7 changes: 7 additions & 0 deletions charts/sm-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ settings:
# The number of operator pod replicas to run. When in doubt, leave at 1
replicas: 1

# Optional: Custom labels to be applied to all resources created by the operator
# This can be used to identify the Bitwarden Secrets Manager project or for any other labeling needs
# Example:
# commonLabels:
# custom-label: custom-label-value
commonLabels: {}

# Settings specific to the pod containers
containers:
manager:
Expand Down
Loading