I'm stuck, trying to get 2 functions, to work together.
I'm also confused around what's the correct way to do this. Is it chaining or ?
So i'm publishing a container image in the function (build), and then i need the url in my return, to be pasted on to the function (update).
Both are of type str, so imho it should be a simple. But i can't get it to work.
Can anybody help or lead me in the right direction ?
Thanks.
My code
from typing import Annotated
import dagger
from dagger import Doc, dag, function, object_type
@object_type
class App:
@function
def build(
self,
src: Annotated[
dagger.Directory,
Doc("location of directory containing Dockerfile"),
],
) -> str:
"""Build and publish image from existing Dockerfile"""
image_url = (
dag.container()
.with_directory("/src", src)
.with_workdir("/src")
.directory("/src")
.docker_build() # build from Dockerfile
.publish("ttl.sh/my-shiny-app")
)
return image_url
@function
def update(self, repo: str, branch: str, deploy_filepath: str, image_url: str, git_user: str, git_email: str, git_password: dagger.Secret, force_with_lease: bool) -> None:
"""Update deployment file, with image name and version"""
return (
dag.image_updater()
.update(repo, branch, deploy_filepath, image_url, git_user, git_email, git_password, force_with_lease)
)