Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tls cleanup error on ingress with no tls #245

Merged
merged 1 commit into from
Oct 25, 2023
Merged

Conversation

rocketeerbkw
Copy link
Member

Fixes an error introduced in #241 where attempting to cleanup tls certificates for an ingress that already doesn't have any tls certificates will fail the build.

The build failure error is: jq: error (at <stdin>:175): Cannot iterate over null (null) which is thrown at https://github.com/uselagoon/build-deploy-tool/blob/main/legacy/build-deploy-docker-compose.sh#L1769. The jq sequence includes .spec.tls[] which is not guaranteed to exist.

The fix is to use []? to make jq treat it as optional.

Example ingress with a secret that needs to be cleaned

{
  "ingressClassName": "nginx",
  "rules": [
    {
      "host": "redacted",
      "http": {
        "paths": [
          {
            "backend": {
              "service": {
                "name": "nginx",
                "port": {
                  "name": "http"
                }
              }
            },
            "path": "/",
            "pathType": "Prefix"
          }
        ]
      }
    }
  ],
  "tls": [
    {
      "hosts": [
        "redacted"
      ],
      "secretName": "redacted-tls"
    }
  ]
}

Example ingress with no tls secrets

{
  "ingressClassName": "nginx",
  "rules": [
    {
      "host": "redacted",
      "http": {
        "paths": [
          {
            "backend": {
              "service": {
                "name": "nginx",
                "port": {
                  "name": "http"
                }
              }
            },
            "path": "/",
            "pathType": "Prefix"
          }
        ]
      }
    }
  ]
}

Copy link
Member

@shreddedbacon shreddedbacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@shreddedbacon shreddedbacon merged commit f367c37 into main Oct 25, 2023
@shreddedbacon shreddedbacon deleted the fix-tls-cleanup branch October 25, 2023 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants