2

How can I access t, which is the thing I get from the outer loop?

{
  ['applications-' + name + t]: kp.applications[name][t]
  for name in [t for t in std.objectFields(kp.applications)]
}

My array looks something like this:

applications :
    alertmanager-bot: { 
        deployment: {...},
        service: {...},
    go-import-redirector: {
        deployment: {...},
        service: {...},

I want to loop over all the deployments/services and put them in separate keys in order to get them into separate files.

Secespitus
  • 710
  • 2
  • 14
  • 22
jonaz
  • 3,764
  • 2
  • 20
  • 20

1 Answers1

2

Got it working with:

{
  ['applications-' + appname + '-' + kind]: kp.applications[appname][kind]
  for appname in std.objectFields(kp.applications)
  for kind in std.objectFields(kp.applications[appname])
}

I had misunderstood the order of the for loops.

jonaz
  • 3,764
  • 2
  • 20
  • 20