${environment.name} not resolving in Deploy action
# 🌱|help-and-getting-started
w
Hi all, not sure if this is a bug or just a bad config. I have the following Deploy action that sets up some kubernetes secrets
Copy code
yaml
kind: Deploy
name: secrets
type: kubernetes
spec:
  manifests:
    $forEach: ${var.secrets}
    $return:
      apiVersion: v1
      kind: Secret
      metadata:
        name: ${item.key}
      type: Opaque
      stringData:
        $merge: ${item.value}
varfiles: 
  - ./secrets.${environment.name}.yaml
I get the following error when I run garden deploy
Copy code
Error processing config for Deploy action secrets:
Could not find varfile at path './secrets.${environment.name}.yaml'
I have just recently updated to the latest release of garden and this previously worked with Modules. My file structure looks like the following:
Copy code
secrets/
  garden.yaml <-- file where module / action was defined
  secrets.local.yaml
I notice when i run garden deploy it says the following :
Copy code
ℹ garden               → Running in Garden environment local.aashelt
which is because I think i have this setup in my environment configuration in my project.yaml
Copy code
yaml
  - name: local
    defaultNamespace: ${local.username}
    variables:
      defaultHostname: ${project.name}.${local.username}.local.app.garden
      replicas: 1
      cpu: 100m
      mem: 1Gi
      volumeSize: 5Gi
      storageClass: ""
      cluster: ""
      timestamp: ""
so should the environment name resolve to "local"? or "local.aashelt" ? I ended up changing my file to match that and i received the same error, its like its not interpolating the template. Heres the old Module that worked before:
Copy code
yaml
kind: Module
name: secrets
type: kubernetes
manifests:
  $forEach: ${var.secrets}
  $return:
    apiVersion: v1
    kind: Secret
    metadata:
      name: ${item.key}
    type: Opaque
    stringData:
      $merge: ${item.value}
varfile: secrets.${environment.name}.yaml
Not sure what other information to provide but if theres anything else i need to provide let me know.
FYI I also tried to escape the special characters as mentioned in the reference documentation https://docs.garden.io/reference/action-types/deploy/kubernetes#varfiles but no luck
q
Hi @wide-flag-41451,
${environment.name}
should be just the bare environment name declared in your
project.garden.yml
, in this case
local
. can you try for testing purposes replace
${environment.name}
with the current path to the secret file you're trying to deploy? So
secrets.local.yaml
?
w
@quaint-dress-831 Hi so yes, specifying the file directly causes it to work.
w
yeah i mean i use this in other manifests and it works just fine, its just not working with this deploy action.
q
Are any of your other manifests using
$forEach:
?
w
no
but shouldn't varfiles be at the same level as the $foreach so it shouldn't impact it
sorry
its at the same level as spec
not foreach
q
Can we try and running
deploy
again with the log level turned up?
garden deploy -l5
And also try with
secrets.["${environment.name}"].yaml
please
w
sure give me a second
where does this log file go
nvm found it
what am i looking for
also tried with the above and still didn't work
q
We're looking for what varfile name garden is trying to fetch
w
Copy code
[2023-06-22T15:02:15.350Z] TreeCache: Setting value for key ["source","/Users/aashelt/repos/test99/frontend","exclude","dba27c31aa"]

[2023-06-22T15:02:15.368Z] Tracking Command Result event.
Payload:
  {"anonymousId":"1bc2b1d8-3fbc-40c5-a878-412a9b01dfcb","event":"Command Result","properties":{"projectId":"9a09885ca050300e637b0723f13ac5beaf831346d291731db1ec09a74b17139148e5f772a38ccafd98fb06c08e1422ad4c05dcc1c2edf0cddbc9dd0d32fdfaa3","projectIdV2":"torpid-infamous-member_9a09885ca050300e637b0723f13ac5be","projectName":"46fc4af214c25f3189a4553634781b089aef502e813d69d7b15b86878dd6170123525459b40b34c1feb7ad5073a4feef74ca8d9b285d8cec1bb9fe6ee69b86f3","projectNameV2":"quizzical-meek-phase_46fc4af214c25f3189a4553634781b08","enterpriseDomain":"2769c2abae62151b2ebb8658628f7c5f5d0dc0c29fdefdd19a23dec9cb0a7b96d74d82512d1f6906bef65b24a29d84685dfd2fd66964a56fbdaff39fabd69206","enterpriseDomainV2":"ratty-willing-science_2769c2abae62151b2ebb8658628f7c5f","isLoggedIn":false,"ciName":null,"system":{"platform":"darwin","platformVersion":"22.4.0","gardenVersion":"0.13.3"},"isCI":false,"sessionId":"8526d113-07c6-48e1-9b62-d3a9ba330f36","parentSessionId":"8526d113-07c6-48e1-9b62-d3a9ba330f36","projectMetadata":{"modulesCount":0,"moduleTypes":[],"tasksCount":0,"servicesCount":0,"testsCount":0,"actionsCount":13,"buildActionCount":3,"testActionCount":0,"deployActionCount":10,"runActionCount":0},"firstRunAt":"2023-03-21T19:43:33.000Z","latestRunAt":"2023-06-22T15:02:12.911Z","isRecurringUser":true,"name":"deploy","durationMsec":1547,"result":"failure","errors":["configuration"],"exitCode":1}}

[2023-06-22T15:02:15.394Z] 


Error processing config for Deploy action secrets:
Could not find varfile at path 'secrets.["${environment.name}"].yaml'

[2023-06-22T15:02:15.400Z] Error: 
Error processing config for Deploy action secrets:
Could not find varfile at path 'secrets.["${environment.name}"].yaml'
    at /snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/src/graph/actions.ts:163:13

Error Details:

config:
  kind: Deploy
  name: secrets
  type: kubernetes
  spec:
    manifests:
      $forEach: ${var.secrets}
      $return:
        apiVersion: v1
        kind: Secret
        metadata:
          name: ${item.key}
        type: Opaque
        stringData:
          $merge: ${item.value}
  varfiles:
    - secrets.["${environment.name}"].yaml
q
Yeah it looks like it's just trying to find a file without interpolating the variable
w
yeah basically what i was saying
8(
q
Before I declare this a bug, I'm just going to check a few more resources
w
sound good
q
Last try:
varfile: "secrets.\$\{environment.name\}.yaml
w
i had tried that before
q
If that doesn't work can you please open a bug?
Ah ok then yes, please open a GitHub issue with logs and a repro!
w
hokay
q
And I'll make sure to follow up with our core devs
w
i'll take me some time to get a repo up
q
Great, let me know if I can assist!
I do promise we'll be sure to surface our core developer team on this as soon as you've got the issue up
w
also I was running into another weird error with regex matching on action name, but i dunno whats different
q
Thank you so much, I will put this on the Core Weekly candidate board for next week's bug bash!
w
sounds good
I might have another one for ya
just wondering
are "-" allowed in action names? i'm pretty sure im using them all over the place but i'm getting an error about an action name not matching a regex
q
Yeah they sure are
w
hmmmm
q
I use them in my own
Like
my-pulumi-action
is one I use
w
yea
so leme see
somethin
hmm seems to be fine now, weird
cant reproduce it again
q
@wide-flag-41451 this is now fixed but not yet released. Hopefully we can get this out in a formal release in the next few days https://github.com/garden-io/garden/pull/4737
34 Views