#secret env var not found

1 messages · Page 1 of 1 (latest)

leaden vine
#

I am trying to publish a container image to ghcr.io. Below is my Publish functtion. It is very basic. Also below you can see where I export the GHCR_TOKEN environment variable on my workstation and call the publish function which gives secret env var not found: "GHC..." I am hoping this is something easy that I am not seeing. My best guess is it might have something to with the fact that I am running the Dagger Engine in a remote K8s cluster and I connect to it via _EXPERIMENTAL_DAGGER_RUNNER_HOST but I am not sure how to debug this?


func (m *SreAiAgent) Publish(
    ctx context.Context,
    // Registry address
    registry string,
    // Registry username
    username string,
    // Registry password
    password *dagger.Secret,
) (string, error) {

        return m.BuildEnv().
            WithRegistryAuth(registry, username, password).
            Publish(ctx, fmt.Sprintf("%s/%s/sre-ai-agent:dev", registry, username))

}

# Run this on my workstation
export GHCR_TOKEN=ghp_abc123mytoken
dagger -c 'publish ghcr.io tonygilkerson env://GHCR_TOKEN'

╰─✘ .withRegistryAuth(
    ┆ address: "ghcr.io"
    ┆ username: "tonygilkerson"
    ┆ secret: secret(uri: "env://GHCR_TOKEN"): Secret!
    ): Container! 0.0s ERROR
  ! secret env var not found: "GHC..."
sudden pelican
#

if that prints *** then it should work. If you get env var not found then something else is happening

leaden vine
#

that worked and stepping through that help me find the issue. I just had a typo in the GHCR_TOKEN env var... thanks

opal cove
#

Hey there. I have a similar issue to this one, however the above command does not work for me, and I get the ! secret env var not found: "GHC..." error.

#

I'm running Dagger on a Mac & Docker for Mac if that make a difference?