* update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2.6 KiB
slug |
---|
/1011/package-manager/ |
Manage packages using the package manager
This tutorial illustrates how to install and upgrade packages using Dagger package manager.
Installing a package
Initializing project
Create an empty directory for your new Dagger project:
mkdir project
cd project
As described in the previous tutorials, initialize your Dagger project:
dagger init
dagger new test
That will create 2 directories: .dagger
and cue.mod
where our package will reside:
.
├── cue.mod
│ ├── module.cue
│ ├── pkg
│ └── usr
├── .dagger
│ └── env
│ └── test
Install
In our example we will use gcpcloudrun
package from github
Let's first add it to our source.cue
file:
package main
import (
"github.com/dagger/packages/gcpcloudrun"
)
run: gcpcloudrun.#Run
To install it just run
dagger mod get github.com/dagger/packages/gcpcloudrun@v0.1
It should pull the v0.1
version from Github, leave a copy in cue.mod/pkg
and reflect the change in
cue.mod/dagger.mod
file:
cue.mod/pkg/github.com/
└── dagger
└── packages
└── gcpcloudrun
├── cue.mod
├── README.md
└── source.cue
github.com/dagger/packages/gcpcloudrun v0.1
Querying the current setup with dagger query
should return a valid result:
{
"run": {
"creds": {
"username": "oauth2accesstoken"
},
"deploy": {
"platform": "managed",
"port": "80"
},
"push": {
"auth": {
"username": "oauth2accesstoken"
},
"push": {}
}
}
}
Upgrading
Now that you've successfully installed a package, let's try to upgrade it.
dagger mod get github.com/dagger/packages/gcpcloudrun@v0.2
You should see similar output:
12:25PM INF system | downloading github.com/dagger/packages:v0.2
And cue.mod/dagger.mod
should reflect the new version:
github.com/dagger/packages/gcpcloudrun v0.2
Develop package locally
Currently, package manager cannot add local packages so a workaround is linking the package to cue.mod/pkg
.
Create a directory with your domain name, usually github.com/myuser, and link your package directory.
mkdir cue.mod/pkg/<mydomain>
ln -s <localpackage> cue.mod/pkg/<mydomain>/<mypackagename>