Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Fix annotations and labels with int and bool #9

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

mathieu-benoit
Copy link
Contributor

@mathieu-benoit mathieu-benoit commented Mar 7, 2024

When running this:

helm upgrade \
    workload \
    ./charts/workload/ \
    --values values.yaml \
    --set workload.containers.annotations."dapr\.io/enabled"=true \
    --set workload.containers.annotations."dapr\.io/app-port"=3000 \
    --set workload.containers.annotations."dapr\.io/app-id"=nodeapp

We are getting this error:

Error: INSTALLATION FAILED: 1 error occurred:
        * Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal number into Go struct field ObjectMeta.spec.template.metadata.annotations of type string

This is a known issue/feature about toYaml not meant to translate bool nor int properly.

Before the fix, this:

helm template charts/workload/ \
--set workload.containers.annotations."dapr\.io/enabled"=true \
--set workload.containers.annotations."dapr\.io/app-port"=3000 \
--set workload.containers.annotations."dapr\.io/app-id"=nodeapp

Was generating this:

  template:
    metadata:
      annotations:
        dapr.io/app-id: nodeapp
        dapr.io/app-port: 3000
        dapr.io/enabled: true

Now with the fix it's generating this:

  template:
    metadata:
      annotations:
        dapr.io/app-id: "nodeapp"
        dapr.io/app-port: "3000"
        dapr.io/enabled: "true"

And can now be installed properly in Kubernetes via helm upgrade|install.

Signed-off-by: Mathieu Benoit <[email protected]>
Signed-off-by: Mathieu Benoit <[email protected]>
@mathieu-benoit mathieu-benoit marked this pull request as draft March 7, 2024 23:29
@mathieu-benoit mathieu-benoit changed the title Update deployment.yaml Fix annotations and labels with int and bool Mar 8, 2024
@mathieu-benoit mathieu-benoit marked this pull request as ready for review March 8, 2024 00:15
@mathieu-benoit
Copy link
Contributor Author

Ready for your review, thanks!

Copy link
Member

@astromechza astromechza left a comment

Choose a reason for hiding this comment

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

LGTM

@mathieu-benoit mathieu-benoit merged commit 3cc1496 into main Mar 8, 2024
2 checks passed
@mathieu-benoit mathieu-benoit deleted the mathieu-benoit-patch-1 branch March 8, 2024 11:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants