allow overriding docker repo and image tag
Signed-off-by: Ava Hahn <a.hahn@f5.com>
This commit is contained in:
parent
6cf99b26ec
commit
4e32355923
2 changed files with 29 additions and 5 deletions
|
|
@ -34,13 +34,16 @@ Unitctl has many functions.
|
|||
|
||||
### Starting a running Unit instance
|
||||
```
|
||||
λ target/debug/unitctl start
|
||||
λ unitctl start
|
||||
|
||||
Usage: unitctl start --socket <SOCKET>
|
||||
Usage: unitctl start [OPTIONS] --socket <SOCKET>
|
||||
|
||||
Options:
|
||||
-s, --socket <SOCKET> path to desired control socket
|
||||
-i, --image <IMAGE> image tag for the unit container [default: latest]
|
||||
-r, --repo <REPO> alternate docker repository for custom unit images [default: nginx/unit]
|
||||
-h, --help Print help
|
||||
|
||||
```
|
||||
|
||||
Unitctl will load and start a local Unit container.
|
||||
|
|
@ -202,4 +205,4 @@ Example of a search for endpoints:
|
|||
- /config/listeners/{listenerName}/forwarded/recursive
|
||||
- /config/listeners/{listenerName}/forwarded/source
|
||||
- /config/listeners/{listenerName}/forwarded/source/{arrayIndex}
|
||||
```
|
||||
```
|
||||
|
|
|
|||
25
src/main.rs
25
src/main.rs
|
|
@ -41,7 +41,21 @@ struct StartArgs {
|
|||
required = true,
|
||||
help = "path to desired control socket"
|
||||
)]
|
||||
socket: String
|
||||
socket: String,
|
||||
|
||||
#[arg(
|
||||
short, long,
|
||||
help = "image tag for the unit container",
|
||||
default_value = "latest", // TODO : change to hardcoded git tag passed at build time
|
||||
)]
|
||||
image: String,
|
||||
|
||||
#[arg(
|
||||
short, long,
|
||||
help = "alternate docker repository for custom unit images",
|
||||
default_value = "nginx/unit"
|
||||
)]
|
||||
repo: String,
|
||||
}
|
||||
|
||||
#[derive(Args, Clone)]
|
||||
|
|
@ -110,8 +124,9 @@ struct SchemaArgs {
|
|||
}
|
||||
|
||||
fn do_start(args: StartArgs) {
|
||||
let image = format!("{}:{}", args.repo, args.image);
|
||||
Command::new("docker")
|
||||
.args(["pull", "unit"])
|
||||
.args(["pull", image.as_str()])
|
||||
.spawn()
|
||||
.expect("failed to call Docker")
|
||||
.wait()
|
||||
|
|
@ -171,6 +186,12 @@ fn do_api_call(args: APIArgs, mut curl: Easy) {
|
|||
curl.post_fields_copy(data.as_bytes());
|
||||
|
||||
if args.put {
|
||||
// do not actually use a put request
|
||||
// it will not use the copied post field
|
||||
// as of April 2024 there is a bug in the libcurl binding
|
||||
// where the data buffer gets sent multiple times when using
|
||||
// the read function callback.
|
||||
// this is simpler and safer.
|
||||
curl.custom_request("PUT");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue