garden-io / garden

Automation for Kubernetes development and testing. Spin up production-like environments for development, testing, and CI on demand. Use the same configuration and workflows at every step of the process. Speed up your builds and test runs via shared result caching
https://garden.io
Mozilla Public License 2.0
3.39k stars 275 forks source link

[Bug]: deploymentRegistry.namespace None cause error in kubernetes provider #6635

Open phangiabao98 opened 12 hours ago

phangiabao98 commented 12 hours ago

Bug

deploymentRegistry.namespace None cause error in kubernetes provider

My build action

kind: Build
name: api
type: container
description: Build the vote API
allowPublish: False

Current behavior

### none workable project.garden.yml
providers:
  - name: kubernetes
    environments: [remote]
    context: "ink-k8s"
    ingressClass: "nginx"
    buildMode: cluster-buildkit
    imagePullSecrets:
      - name: "gitlab-container-registry"
        namespace: default
    deploymentRegistry:
      hostname: "gitlab.inter-k.com:5050/inter-k/internal-software/rnd/kguru"
      # namespace: ${var.userNamespace}
    namespace: ${var.userNamespace}
    defaultHostname: ${var.baseHostname}

workable project.garden.yml

providers:
  - name: kubernetes
    environments: [remote]
    context: "ink-k8s"
    ingressClass: "nginx"
    buildMode: cluster-buildkit
    imagePullSecrets:
      - name: "gitlab-container-registry"
        namespace: default
    deploymentRegistry:
      hostname: "gitlab.inter-k.com:5050/inter-k/internal-software/rnd/kguru"
      namespace: ${var.userNamespace}
    namespace: ${var.userNamespace}
    defaultHostname: ${var.baseHostname}

Error happend when i run garden build api

Expected behavior

Because providers[].deploymentRegistry.namespace is optional so expect that Build action still work even I don't define namespace value. image

The error is about parsing image with invalid _ character inside image

This error cause me plenty of time to trace and debug so hope that I can create a PR to help other spending less time on this issue.

phangiabao98 commented 11 hours ago

created MR https://github.com/garden-io/garden/pull/6636

twelvemo commented 1 hour ago

Hello @phangiabao98 , thank you very much for reporting and contributing to garden. I looked at your PR but there are a couple of additional places that need to be changed for this to work. I created another PR in #6638