renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.41k stars 2.28k forks source link

Line breaks in K8s YAML files lead to missing update detection #26970

Open rarkins opened 8 months ago

rarkins commented 8 months ago

Discussed in https://github.com/renovatebot/renovate/discussions/26956

Originally posted by **ahuemmer** January 31, 2024 ### How are you running Renovate? Self-hosted Renovate ### If you're self-hosting Renovate, tell us what version of Renovate you run. 37.163 ### If you're self-hosting Renovate, select which platform you are using. GitHub Enterprise Server ### Was this something which used to work for you, and then stopped? I have not seen this working ### Describe the problem When using "allowed" line breaks line `>-` in a K8s deployment descriptor YAML file, updates for the corresponding lines are not found. E. g.: ```yaml spec: template: spec: initContainers: - image: >- legitgames/apm-agent-java:1.44.0 ``` The newer image version `1.45.0` will not be found. If I combine the last two lines like this ```yaml - image: legitgames/apm-agent-java:1.44.0 ``` it will. (I'm aware that this minimal file, which is also contained in the minimal example, does not really make sense as a K8s deployment descriptor. For us, the error happens with valid, big K8s files as well. Furthermore, I am in no way related to "legitgames", we just found this to be a good example on docker hub.) ### Relevant debug logs
Logs ```json packageFiles with updates (repository=local) "config": { "kubernetes": [ { "deps": [ { "depName": ">-", "replaceString": ">-", "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}", "datasource": "docker", "updates": [], "packageName": ">-", "versioning": "docker", "warnings": [], "skipReason": "invalid-value" }, { "depName": "Deployment", "currentValue": "apps/v1", "datasource": "kubernetes-api", "versioning": "kubernetes-api", "updates": [], "packageName": "Deployment", "warnings": [], "currentVersion": "apps/v1", "fixedVersion": "apps/v1" } ], "packageFile": "k8s/k8s-doesntwork.yml" }, { "deps": [ { "depName": "legitgames/apm-agent-java", "currentValue": "1.44.0", "replaceString": "legitgames/apm-agent-java:1.44.0", "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}", "datasource": "docker", "updates": [ { "bucket": "non-major", "newVersion": "1.45.0", "newValue": "1.45.0", "newMajor": 1, "newMinor": 45, "updateType": "minor", "branchName": "renovate/legitgames-apm-agent-java-1.x" } ], "packageName": "legitgames/apm-agent-java", "versioning": "docker", "warnings": [], "registryUrl": "https://hub.docker.com", "currentVersion": "1.44.0", "isSingleVersion": true, "fixedVersion": "1.44.0" }, { "depName": "Deployment", "currentValue": "apps/v1", "datasource": "kubernetes-api", "versioning": "kubernetes-api", "updates": [], "packageName": "Deployment", "warnings": [], "currentVersion": "apps/v1", "fixedVersion": "apps/v1" } ], "packageFile": "k8s/k8s-works.yml" } ] } ```
In these logs, you can see the debug output for two different files, one of which is using the `>-` linebreak (`k8s-doesntwork.yml`) and the other one not using it (`k8s-works.yml`). For the first one, the JSON contains no `updates` section, for the second one, it does, denoting the new `1.45.0` version. Please find a minimal example attached. [minimal-example.zip](https://github.com/renovatebot/renovate/files/14108560/minimal-example.zip) ### Have you created a minimal reproduction repository? https://github.com/renovate-reproductions/26956
viceice commented 8 months ago

this is probably happening because we use regex matching instead of yaml parsing 🤔