I'm using a CLI tool called Okteto which deploys preview environments. I want to create a dagger function that outputs the URLs for the deployed preview environments. To do that I have to run the CLI commands for deploying a preview environment, then wait for that command to get finished, then run another command which retrieves the endpoints of the deployed preview environment.
Here's the code I have currently:
func (m *OktetodoDagger) PreviewEnv(ctx context.Context,
// Repo to deploy
repo string,
// Branch to deploy
branch string,
// URL of the pull request to attach in the Okteto Dashboard
pr string,
// Okteto context to be used for deployment
context string,
// Token to be used to authenticate with the Okteto context
token string) (string, error) {
c := m.SetContext(context, token)
c.WithExec([]string{
"okteto", "preview", "deploy", "--branch", branch, "--sourceUrl", pr, "--repository", repo, "--wait", branch,
})
c.WithExec([]string{
"okteto", "preview", "endpoints", branch,
})
return c.Stdout(ctx)
}
But when I run the function with dagger call preview-env --repo=https://github.com/okteto/todolist-pulumi-s3 --branch=name-change --pr=https://github.com/okteto/todolist-pulumi-s3/pull/2 --context=arsh.okteto.me --token=$OKTETO_TOKEN all I see as the output is:
! Initializing context with the value of OKTETO_TOKEN environment variable
✓ Context 'arsh.okteto.me' created
✓ Using rinkiyakedad @ arsh.okteto.me
Which is the output of the SetContext dagger function which the PreviewEnv function calls. I'm not sure how to debug this, can someone please help me figure out how to get this working? 🙏