Action outputs not resolved in manifests
# 💻|contributing
g
This works fine with other vars like
${environment.namespace}
Example below...
Copy code
Kind: Build
name: web
type: container
...
...
---
Kind: Deploy
type: Kubernetes
name: web
source:
  path: ../manifets
spec:
  files:
    - deployment.yaml
---
# deployment yaml in manifests dir
apiVersion: apps/v1
Kind: Deployment
....
...
spec
  image: ${actions.build.web.outputs.deploymentImageId} #literally prints this
  image: ${environment.namespace} #this interpolates just fine
b
Hi @gifted-addition-77467 ! I think this is because your missing the dependency declaration between your Deploy and Build action. Your Deploy action should look like this:
Copy code
yaml
Kind: Deploy
type: Kubernetes
name: web
source:
  path: ../manifets
depedencies: [build.web] # <--- Add this
That being said, Garden should throw a proper error here. I'll bring that up with the team! And just FYI, we had a small bug around the
source.path
field which has been fixed but not released yet. It should work fine in your case but I'd recommend you update the Garden CLI to the latest release once it's out, probably a few days from now.
g
Thank you, I will try that out in a bit and get back to you
that did not work @brief-restaurant-63679 FWIW I am on 0.13.17
s
The final resolution of the action spec should definitely resolve all remaining template strings, or throw an error otherwise. Not sure what's going on here, but I suspect it's a simple fix. Might this have something to do with the fixes around partial resolution that @big-spring-14945 and @polite-fountain-28010 were working on recently?
b
Hey again @gifted-addition-77467 We have an example that uses the same pattern and that works fine on my end. https://github.com/garden-io/garden/tree/main/examples/k8s-deploy-shared-manifests Could you check and see if this works? If you run
garden deploy -l4
(that is set the log level to debug) then you can the rendered manifest in the logs before it's applied.
a
@swift-garage-61180 For resolving the manifests, we allow partial resolution https://github.com/garden-io/garden/blob/main/core/src/plugins/kubernetes/kubernetes-type/common.ts#L428 And this might be on purpose to not throw error if manifest file has a custom string that looks like a template string but is not a Garden template string.
s
Ah, of course—didn't notice that these were manifests outside the action config.
For context, what was the command that was being run? A
garden deploy
?
b
Can we move this to a separate thread so @gifted-addition-77467 won't get lost in all the context 🙂
g
@brief-restaurant-63679 thanks for taking a look, so I ran with the debug flag and I see it rendered literally
${actions.build.web.outputs.deploymentImageId}
in the output. If I try and use a different variable like this one
${environment.namespace}
in the manifest it works just fine
a
@gifted-addition-77467 Any chance you are escaping something in your manifest files using
$$
? Wondering if you might be running into this bug? https://github.com/garden-io/garden/issues/3989#issuecomment-1672955747 One of the side effects of the escape bug is that some of the template strings in the manifest files might not be resolved.
g
@astonishing-tomato-18259 nope, it is a very basic deployment manifest
Copy code
---
apiVersion: apps/v1
kind: Deployment metadata:
  name: web 
replicas: 1
  spec:
  selector:
    matchLabels:
      app: web template:
  metadata:
    labels:
    app: web
    namespace: web-${environment.namespace} #works 
  spec:
    containers:
      - name: web
        image: ${actions.web.outputs.deployment-image-id} #doesn't expand
        #image: ${variables.DOCKER_IMAGE} #works 
      ports:
        - containerPort: 3000
          name: http
      envFrom:
        - secretRef:
          name: web-externalsecret 
      livenessProbe: 
        httpGet:
          path: /health 
          port: http
        initialDelaySeconds: 30
        periodSeconds: 10
a
@gifted-addition-77467 Thank you for sharing that. I think this is not right
Copy code
${actions.web.outputs.deployment-image-id} #doesn't expand
Can you please try replacing that line with
Copy code
${actions.<action-kind-of-web>.web.outputs.deployment-image-id} #doesn't expand
The syntax for referencing an action output is
Copy code
${actions.<action-kind>.<action-name>.outputs.<output-name>}
g
yeah sorry, that was typed hastily as I am not on the same computer I am trying this on
ok...well that worked, I added back in , sorry for the troubles
a
Glad that it worked 🙂 Garden should tell you that in first place so it's not your fault. Not the best experience and we can definitely improve it. I'll start a thread for this. edit: seems like @User already has started a thread.