#Default img

1 messages ยท Page 1 of 1 (latest)

dawn osprey
#

Hi

#

It's totally possible, but in an easier way:

#

Here is a small repro only in Cue of a functional way of doing what you aim to do

#

Please tell me if it doesn't help ๐Ÿ˜‡

balmy mural
#

I have tested with the following snippet

// Helpers to run helm commands in containers
package helm

import (
    "dagger.io/dagger"
    "universe.dagger.io/docker"
)

// Permit to run helm lint
#Lint: {

  // The source directory that contain helm charts
  directory: dagger.#FS

  // The relative path from `directory` where to lint 
  chart: string | *"."

    // Environment variables
    env: [string]: string | dagger.#Secret

  // The docker image to use
  input: docker.#Image | *_defaultImage.output

  _defaultImage: #InstallTools & {
    "env": env
  }
  

  docker.#Run & {
    entrypoint: ["/bin/sh"]
    command: {
      name:   "-c"
      "args": ["helm lint \(chart)"]
    }
    mounts: "helm charts": {
      contents: directory
      dest:     "/src"
    }
    "env": {
      env
    }
    workdir: "/src"
    "input": input
  }
}
#

but the are 2 problem

#

1: cycle issue with env

#

2: event if I provide input, it will construct the _defaultImage (with all pull, curl to install extra script, etc)

dawn osprey
#

Ok I'm currently testing, the structural cycle is weird ๐Ÿ˜• It's a Cue thing

dawn osprey
#

@balmy mural. So, your way of doing should work, we check the plan's concreteness with a heuristic since the last release

#

I think there's an issue with that (it seems)

#

Regarding the env cycle issue, rename it with something else, it shall disappear. It's not normal

dawn osprey
#

It's something we are aware of. Basically, in Cue, if you call recursively the same definition with depth > 3 it breaks. By running the docker.#Run with the default in a docker.#Run, it leads to this error

dawn osprey
#

@balmy mural

#

I managed to make it work:

package main

import (
    "dagger.io/dagger"

    "universe.dagger.io/alpine"
    "universe.dagger.io/docker"
)

dagger.#Plan & {
    actions: {
        _defaultImage2: alpine.#Build

        #Lint: {
            // Environment variables
            env2: [string]: string | dagger.#Secret

            // The docker image to use
            // input: docker.#Image
            // inp?: docker.#Image
            inp?: docker.#Image

            docker.#Run & {
                if inp != _|_ {
                    "input": inp
                }

                if inp == _|_ {
                    _defaultImage: docker.#Build & {
                        steps: [
                            alpine.#Build,
                            docker.#Run & {
                                command: {
                                    name: "sh"
                                    flags: "-c": "echo -n $TEST >> /test.txt"
                                }
                                "env": env2
                            },
                        ]
                    }
                    "input": _defaultImage.output
                }

                entrypoint: ["/bin/sh"]
                command: {
                    name: "-c"
                    "args": ["echo oui"]
                }
                "env": env2
            }
        }

        foo: #Lint & {
            // inp: _defaultImage2.output
            env2: TEST: "test"
        }
    }
}