Skip to content

Commit 678bd5b

Browse files
authored
Merge pull request #5554 from grafana/dev
v1.16.3
2 parents dc9acea + e11366d commit 678bd5b

File tree

10 files changed

+61
-42
lines changed

10 files changed

+61
-42
lines changed

.github/actions/setup-python/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
env:
1919
PYTHON_REQUIREMENTS_PATHS: ${{ inputs.python-requirements-paths }}
2020
with:
21-
python-version: "3.12.10"
21+
python-version: "3.12.11"
2222
cache: "pip"
2323
cache-dependency-path: ${{ env.PYTHON_REQUIREMENTS_PATHS }}
2424
- name: Install Python dependencies

.github/workflows/on-release-published.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,3 @@ jobs:
107107
"version": "${{ steps.prepare-version-tags.outputs.version }}",
108108
"appVersion": "${{ steps.prepare-version-tags.outputs.app-version }}"
109109
}
110-
111-
merge-helm-release-pr:
112-
name: Merge Helm release PR
113-
needs:
114-
- create-helm-release-pr
115-
runs-on: ubuntu-latest
116-
# These permissions are needed to assume roles from Github's OIDC.
117-
# https://github.com/grafana/shared-workflows/tree/main/actions/get-vault-secrets
118-
permissions:
119-
id-token: write
120-
contents: read
121-
steps:
122-
- name: Get Vault secrets
123-
uses: grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets-v1.2.0
124-
with:
125-
repo_secrets: |
126-
GH_APP_ID=github-app:app-id
127-
GH_APP_PRIVATE_KEY=github-app:private-key
128-
129-
- name: Generate Github App token
130-
id: generate-token
131-
uses: actions/create-github-app-token@v1
132-
with:
133-
app-id: ${{ env.GH_APP_ID }}
134-
private-key: ${{ env.GH_APP_PRIVATE_KEY }}
135-
owner: grafana
136-
repositories: "oncall"
137-
138-
- name: Merge pull Request
139-
uses: juliangruber/merge-pull-request-action@d4773803fdc1d1fd46801ab0c56c135df9075de8 #v1.1.1
140-
with:
141-
github-token: ${{ steps.generate-token.outputs.token }}
142-
number: ${{ needs.create-helm-release-pr.outputs.helm_release_pr_number }}

.github/workflows/publish-technical-documentation-release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ jobs:
2020
- uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
23+
# yamllint disable rule:line-length
2324
# publish-technical-documentation-release/v2.2.4
24-
- uses: grafana/writers-toolkit/publish-technical-documentation-release@8cc658b604c6e05c275af30163a1c7728dfe19b2
25+
# yamllint disable rule:line-length
26+
- uses: grafana/writers-toolkit/publish-technical-documentation-release@publish-technical-documentation-release/v2 # zizmor: ignore[unpinned-uses]
27+
# yamllint enable rule:line-length
2528
with:
2629
release_tag_regexp: "^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
2730
release_branch_regexp: "^release-(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
2831
release_branch_with_patch_regexp: "^release-(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
2932
website_directory: content/docs/oncall
33+
# yamllint enable rule:line-length

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@ repos:
110110
name: yamllint
111111
entry: yamllint -c .yamllint.yml
112112
types: [yaml]
113+
args: [--no-warnings]

engine/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12.10-alpine3.21 AS base
1+
FROM python:3.12.11-alpine3.21 AS base
22
ARG TARGETPLATFORM
33

44
# Create a group and user to run an app

tools/migrators/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12.10-alpine3.21
1+
FROM python:3.12.11-alpine3.21
22

33
ENV PYTHONUNBUFFERED=1
44
WORKDIR /app

tools/migrators/lib/pagerduty/resources/services.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,19 @@ def _transform_service(
450450
is_technical = isinstance(service, TechnicalService)
451451
service_type = "service" if is_technical else "business_service"
452452

453+
service_name = re.sub("[^-a-zA-Z0-9.]", "-", service.name)
454+
service_name = re.sub(
455+
"-+", "-", service_name
456+
) # Collapse multiple dashes to single dash
457+
service_name = re.sub(
458+
"^-+|-+$", "", service_name
459+
) # Remove leading and trailing dashes
453460
# Create the base component structure
454461
component = {
455462
"apiVersion": "servicemodel.ext.grafana.com/v1alpha1",
456463
"kind": "Component",
457464
"metadata": {
458-
"name": service.name.lower().replace(
459-
" ", "-"
460-
), # Convert to k8s-friendly name
465+
"name": service_name.lower(), # Convert to k8s-friendly name
461466
"annotations": {"pagerduty.com/service-id": service.id},
462467
},
463468
"spec": {"type": service_type, "description": service.description},

tools/migrators/lib/tests/pagerduty/resources/test_services.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,48 @@ def test_transform_business_service(business_service):
324324
)
325325

326326

327+
@pytest.mark.parametrize(
328+
"input_name,expected_name",
329+
[
330+
# Basic cases
331+
("Simple Service", "simple-service"),
332+
("Test_Service", "test-service"),
333+
("Service.Name", "service.name"),
334+
# Edge cases that would cause issues with old logic
335+
(" Leading spaces", "leading-spaces"),
336+
("Trailing spaces ", "trailing-spaces"),
337+
(" Both sides ", "both-sides"),
338+
("Multiple spaces", "multiple-spaces"),
339+
# Special characters
340+
("Service@Name", "service-name"),
341+
("Service!@#$%Name", "service-name"),
342+
("Service(with)parens", "service-with-parens"),
343+
# Mixed cases
344+
(" Service@Name ", "service-name"),
345+
("##Service Name##", "service-name"),
346+
("!!!Service!!!Name!!!", "service-name"),
347+
],
348+
)
349+
def test_service_name_normalization(input_name, expected_name):
350+
"""Test service name normalization handles various edge cases correctly."""
351+
# Create a mock technical service
352+
service = Mock(spec=TechnicalService)
353+
service.name = input_name
354+
service.description = "Test description"
355+
service.id = "P123456"
356+
service.status = "active"
357+
service.html_url = "https://pagerduty.com/services/P123456"
358+
service.self_url = "https://api.pagerduty.com/services/P123456"
359+
360+
# Transform the service
361+
component = _transform_service(service)
362+
363+
# Check that the name was normalized correctly
364+
assert (
365+
component["metadata"]["name"] == expected_name
366+
), f"Expected '{expected_name}' for input '{input_name}', got '{component['metadata']['name']}'"
367+
368+
327369
def test_validate_component():
328370
"""Test component validation."""
329371
# Test valid component

tools/migrators/requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
requests==2.32.3
1+
requests==2.32.4
22
pdpyras==4.5.0
33
pytest==8.2.2
44
pytest-env==0.6.2

tools/migrators/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ python-dateutil==2.9.0.post0
4646
# via kubernetes
4747
pyyaml==6.0.2
4848
# via kubernetes
49-
requests==2.32.3
49+
requests==2.32.4
5050
# via
5151
# -r requirements.in
5252
# kubernetes

0 commit comments

Comments
 (0)