Dagger
Search

image-updater

No long description provided.

Installation

dagger install github.com/matipan/daggerverse/image-updater@v0.0.1

Entrypoint

Return Type
ImageUpdater
Example
dagger -m github.com/matipan/daggerverse/image-updater@84cbdbe89185ad94690a9ada1cdfb79f1878ecd7 call \
func (m *myModule) example() *ImageUpdater  {
	return dag.
			ImageUpdater()
}
@function
def example() -> dag.ImageUpdater:
	return (
		dag.image_updater()
	)
@func()
example(): ImageUpdater {
	return dag
		.imageUpdater()
}

Types

ImageUpdater 🔗

image-updater is a dagger module that updates, commits and pushes a kubernetes deployment file with a new image-url. There are many alternatives to doing GitOps with kubernetes now a days, to name a few: - Automatically update the deployment with the new image using Kubectl or hitting the kubernetes API directly (no specific trace of the image deployed in the git repository) - Use tools such as Flux or ArgoCD to automatically watch a registry and deploy new images when they appear - Use Flux or ArgoCD as well but instead have them look for changes on specific manifests in a repository This module is useful for the last alternative. When you have CD tools that are watching kubernetes manifests on your repository you would need to change them explicitly. If you use Github or Gitlab there are actions that you can use to make this changes (for example, there is a yq action and a git-auto-commit action), but the problem is that those workflows cannot be tested locally and they become complicated. In the case of github actions, if you run your action as part of a workflow that takes a long time to run, it might happen that a new commit showed up and your push will fail. Solving this is possible, but it requires adding even more untestable bash. This is why this module exists. With image-updater you can implement this logic in a single step that is reproducible locally.

update() 🔗

Update updates the kubernetes deployment file in the specified repository with the new image URL. NOTE: this pushes a commit to your repository so make sure that you either don’t have a cyclic workflow trigger or that you use a token that prevents this from happening.

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
appNameString -name of the application that is being updated. appName is used on the commit message if no name is provided then a generic message is committed.
repoString !-repository to clone
branchString !-branch to checkout
files[String ! ] !-list of files that should be updated
imageUrlString !-full URL of the image to set
gitUserString !-username for the author of the commit
gitEmailString !-email used for both the commit and the authentication
gitPasswordSecret !-password to authenticate against git server.
forceWithLeaseBoolean -if specified then the push is made with --force-with-lease
containers[Integer ! ] -list of container IDs to update on each of the files
Example
dagger -m github.com/matipan/daggerverse/image-updater@84cbdbe89185ad94690a9ada1cdfb79f1878ecd7 call \
 update --repo string --branch string --files string1 --files string2 --image-url string --git-user string --git-email string --git-password env:MYSECRET
func (m *myModule) example(ctx context.Context, repo string, branch string, files []string, imageUrl string, gitUser string, gitEmail string, gitPassword *Secret)   {
	return dag.
			ImageUpdater().
			Update(ctxrepo, branch, files, imageUrl, gitUser, gitEmail, gitPassword)
}
@function
async def example(repo: str, branch: str, files: List[str], image_url: str, git_user: str, git_email: str, git_password: dagger.Secret) -> None:
	return await (
		dag.image_updater()
		.update(repo, branch, files, image_url, git_user, git_email, git_password)
	)
@func()
async example(repo: string, branch: string, files: string[], imageUrl: string, gitUser: string, gitEmail: string, gitPassword: Secret): Promise<void> {
	return dag
		.imageUpdater()
		.update(repo, branch, files, imageUrl, gitUser, gitEmail, gitPassword)
}