image-push supports renaming via -t (#750)

fix nu-complete of `docker registry show`

Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
fj0r 2024-01-26 20:48:51 +08:00 committed by GitHub
parent 73955cd4cf
commit 302fd84fed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,9 +257,19 @@ export def image-tag [from: string@"nu-complete docker images" to: string -n: s
} }
# push image # push image
export def image-push [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns" -i] { export def image-push [
img: string@"nu-complete docker images"
--tag(-t): string
-n: string@"nu-complete docker ns" -i
] {
let $insecure = if $i {[--insecure-registry]} else {[]} let $insecure = if $i {[--insecure-registry]} else {[]}
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $img if ($tag | is-empty) {
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $img
} else {
^$env.docker-cli ...($n | with-flag -n) tag $img $tag
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $tag
^$env.docker-cli ...($n | with-flag -n) rmi $tag
}
} }
# pull image # pull image
@ -395,9 +405,9 @@ def has [name] {
def "nu-complete registry show" [cmd: string, offset: int] { def "nu-complete registry show" [cmd: string, offset: int] {
let new = $cmd | str ends-with ' ' let new = $cmd | str ends-with ' '
let cmd = $cmd | split row ' ' let cmd = $cmd | split row ' '
let url = $cmd.2? let url = $cmd.3?
let reg = $cmd.3? let reg = $cmd.4?
let tag = $cmd.4? let tag = $cmd.5?
let auth = if ($env | has 'REGISTRY_TOKEN') { let auth = if ($env | has 'REGISTRY_TOKEN') {
[-H $"Authorization: Basic ($env.REGISTRY_TOKEN)"] [-H $"Authorization: Basic ($env.REGISTRY_TOKEN)"]
} else { } else {